+ * Supports two URI schemes: + *
+ * Note: {@code jar:} URIs are intentionally not exposed via + * {@code IURIEditorInput}. Eclipse EFS has no file-system provider for the + * {@code jar:} scheme, so LSP4E would fail (e.g. {@code EFS.getStore(jar:...)} + * in its outline adapter) if it tried to treat this editor input as a + * URI-backed resource. + *
+ */ + static final class JarEditorInput implements IStorageEditorInput { + + private final IStorage storage; + private final String name; + private final URI uri; + + JarEditorInput(IStorage storage, String name, String rawUri) { + this.storage = storage; + this.name = name; + this.uri = URI.create(rawUri); + } + + @Override + public IStorage getStorage() { + return storage; + } + + @Override + public boolean exists() { + return true; + } + + @Override + public ImageDescriptor getImageDescriptor() { + return null; + } + + @Override + public String getName() { + return name; + } + + @Override + public IPersistableElement getPersistable() { + return null; + } + + @Override + public String getToolTipText() { + return uri.toString(); + } + + @Override + public
+ * "command": {
+ * "title": "1 reference",
+ * "command": "xml.show.references",
+ * "arguments": [
+ * "file:///c%3A/Users/AngeloZerr/git/vscode-xml/foo.xsd",
+ * { "line": 3, "character": 20 }
+ * ]
+ * }
+ *
+ *
+ * @author Angelo ZERR
+ */
+public class ShowReferencesHandler extends LSPCommandHandler {
+
+ private static final String FIND_REFERENCES_COMMAND = "org.eclipse.ui.genericeditor.findReferences";
+
+ private static final Gson GSON = new Gson();
+
+ @Override
+ public Object execute(ExecutionEvent event, Command command, IPath path) throws ExecutionException {
+ String uri = (String) command.getArguments().get(0);
+ Position position = GSON.fromJson(GSON.toJsonTree(command.getArguments().get(1)), Position.class);
+ try {
+ IFileStore fileStore = EFS.getStore(URI.create(uri));
+ PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ // openEditorOnFileStore returns existing editor if already open.
+ IEditorPart editor = IDE.openEditorOnFileStore(page, fileStore);
+ revealAndFindReferences(editor, position);
+ } catch (Exception e) {
+ ILog.get().error("Error showing references for URI: " + uri, e);
+ }
+ });
+ } catch (Exception e) {
+ ILog.get().error("Error showing references for URI: " + uri, e);
+ }
+ return null;
+ }
+
+ private static void revealAndFindReferences(IEditorPart editor, Position position) throws Exception {
+ if (editor instanceof ITextEditor textEditor) {
+ IDocument document = LSPEclipseUtils.getDocument(textEditor);
+ if (document != null) {
+ int offset = LSPEclipseUtils.toOffset(position, document);
+ textEditor.selectAndReveal(offset, 0);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ handlerService.executeCommand(FIND_REFERENCES_COMMAND, null);
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java
index 96da4e7322..8159a2a2d4 100644
--- a/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java
+++ b/org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/debug/SelectionUtils.java
@@ -10,6 +10,7 @@
package org.eclipse.wildwebdeveloper.debug;
import java.io.File;
+import java.net.URI;
import java.util.function.Predicate;
import org.eclipse.core.resources.IFile;
@@ -117,9 +118,12 @@ public static File getFile(IEditorInput editorInput, Predicate