@Override
	public void install(@Nonnull Editor editor) {
		super.install(editor);
		CodeArea area = editor.getCodeArea();
		area.setOnContextMenuRequested(e -> {
			if (menu != null) {
				menu.hide();
				menu = null;
			}

			// Check AST model has been generated
			if (astElements == null) {
				logger.warn("Could not request context menu, AST model not available");
				return;
			}

			// Convert the event position to line/column
			CharacterHit hit = area.hit(e.getX(), e.getY());

			// Sync caret
			area.moveTo(hit.getInsertionIndex());

			// Create menu
			AssemblyResolution resolution = resolver.resolveAt(hit.getInsertionIndex());
			AssemblerPathData data = new AssemblerPathData(editor, resolution);
			menu = cellConfigurationService.contextMenuOf(ContextSource.DECLARATION, new AssemblerPathNode(path, data));

			// Show menu
			if (menu != null && !menu.getItems().isEmpty()) {
				menu.setAutoHide(true);
				menu.setHideOnEscape(true);
				menu.show(area.getScene().getWindow(), e.getScreenX(), e.getScreenY());
				menu.requestFocus();
			}
		});
	}
Enables context actions on an {@link Editor} within an {@link AssemblerPane}.
The AST of the last successful parse from the assembler is used to query for menus offered by {@link ContextMenuProviderService}.

@author Matt Coley
@see JavaContextActionSupport Alternative for context actions on Java source.
recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerContextActionSupport.java