org.eclipse.lsp4j.Location Java Examples
The following examples show how to use
org.eclipse.lsp4j.Location.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testConstructorDefinitionFromConstructorCall() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append(" public Definitions() {\n"); contents.append(" new Definitions()\n"); contents.append(" }\n"); contents.append("}"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(2, 10); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(1, location.getRange().getStart().getLine()); Assertions.assertEquals(2, location.getRange().getStart().getCharacter()); Assertions.assertEquals(3, location.getRange().getEnd().getLine()); Assertions.assertEquals(3, location.getRange().getEnd().getCharacter()); }
Example #2
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testParameterDefinitionFromDeclarationInMethod() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append(" public void memberMethod(int param) {\n"); contents.append(" }\n"); contents.append("}\n"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(1, 33); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(1, location.getRange().getStart().getLine()); Assertions.assertEquals(27, location.getRange().getStart().getCharacter()); Assertions.assertEquals(1, location.getRange().getEnd().getLine()); Assertions.assertEquals(36, location.getRange().getEnd().getCharacter()); }
Example #3
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testMemberVariableDefinitionFromAssignment() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append(" public int memberVar\n"); contents.append(" public Definitions() {\n"); contents.append(" memberVar = 123\n"); contents.append(" }\n"); contents.append("}\n"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(3, 6); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(1, location.getRange().getStart().getLine()); Assertions.assertEquals(2, location.getRange().getStart().getCharacter()); Assertions.assertEquals(1, location.getRange().getEnd().getLine()); Assertions.assertEquals(22, location.getRange().getEnd().getCharacter()); }
Example #4
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testMemberVariableDefinitionFromDeclaration() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append(" public int memberVar\n"); contents.append("}\n"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(1, 18); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(1, location.getRange().getStart().getLine()); Assertions.assertEquals(2, location.getRange().getStart().getCharacter()); Assertions.assertEquals(1, location.getRange().getEnd().getLine()); Assertions.assertEquals(22, location.getRange().getEnd().getCharacter()); }
Example #5
Source File: ImplementationsHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testMethodImplementation_includeDefinition() { URI uri = project.getFile("src/org/sample/FooService.java").getRawLocationURI(); String fileURI = ResourceUtils.fixURI(uri); TextDocumentPositionParams param = new TextDocumentPositionParams(); param.setPosition(new Position(11, 13)); //Position over someMethod() param.setTextDocument(new TextDocumentIdentifier(fileURI)); List<? extends Location> implementations = handler.findImplementations(param, monitor); assertNotNull("findImplementations should not return null", implementations); assertEquals(implementations.toString(), 2, implementations.size()); Location foo = implementations.get(0); assertTrue("Unexpected implementation : " + foo.getUri(), foo.getUri().contains("org/sample/Foo.java")); //check range points to someMethod() position assertEquals(new Position(8, 13), foo.getRange().getStart()); assertEquals(new Position(8, 23), foo.getRange().getEnd()); foo = implementations.get(1); assertTrue("Unexpected implementation : " + foo.getUri(), foo.getUri().contains("org/sample/FooChild.java")); //check range points to someMethod() position assertEquals(new Position(4, 13), foo.getRange().getStart()); assertEquals(new Position(4, 23), foo.getRange().getEnd()); }
Example #6
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testLocalVariableDefinitionFromMethodCallObjectExpression() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append(" public Definitions() {\n"); contents.append(" String localVar = \"hi\"\n"); contents.append(" localVar.charAt(0)\n"); contents.append(" }\n"); contents.append("}"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(3, 6); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(2, location.getRange().getStart().getLine()); Assertions.assertEquals(11, location.getRange().getStart().getCharacter()); Assertions.assertEquals(2, location.getRange().getEnd().getLine()); Assertions.assertEquals(19, location.getRange().getEnd().getCharacter()); }
Example #7
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testClassDefinitionFromDeclaration() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append("}"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(0, 8); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(0, location.getRange().getStart().getLine()); Assertions.assertEquals(0, location.getRange().getStart().getCharacter()); Assertions.assertEquals(1, location.getRange().getEnd().getLine()); Assertions.assertEquals(1, location.getRange().getEnd().getCharacter()); }
Example #8
Source File: DefinitionTest.java From n4js with Eclipse Public License 1.0 | 6 votes |
/***/ @Test public void testDefinition_04() throws Exception { testWorkspaceManager.createTestProjectOnDisk(Collections.emptyMap()); startAndWaitForLspServer(); TextDocumentPositionParams textDocumentPositionParams = new TextDocumentPositionParams(); textDocumentPositionParams.setTextDocument(new TextDocumentIdentifier("n4scheme:/builtin_js.n4ts")); // see position from test above textDocumentPositionParams.setPosition(new Position(838, 15)); CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> definitionsFuture = languageServer .definition(textDocumentPositionParams); Either<List<? extends Location>, List<? extends LocationLink>> definitions = definitionsFuture.get(); File root = getRoot(); String actualSignatureHelp = new StringLSP4J(root).toString4(definitions); assertEquals("(n4scheme:/builtin_js.n4ts, [838:15 - 838:21])", actualSignatureHelp.trim()); }
Example #9
Source File: NavigateToDefinitionHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static Location fixLocation(IJavaElement element, Location location, IJavaProject javaProject) { if (location == null) { return null; } if (!javaProject.equals(element.getJavaProject()) && element.getJavaProject().getProject().getName().equals(ProjectsManager.DEFAULT_PROJECT_NAME)) { // see issue at: https://github.com/eclipse/eclipse.jdt.ls/issues/842 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=541573 // for jdk classes, jdt will reuse the java model by altering project to share the model between projects // so that sometimes the project for `element` is default project and the project is different from the project for `unit` // this fix is to replace the project name with non-default ones since default project should be transparent to users. if (location.getUri().contains(ProjectsManager.DEFAULT_PROJECT_NAME)) { String patched = StringUtils.replaceOnce(location.getUri(), ProjectsManager.DEFAULT_PROJECT_NAME, javaProject.getProject().getName()); try { IClassFile cf = (IClassFile) JavaCore.create(JDTUtils.toURI(patched).getQuery()); if (cf != null && cf.exists()) { location.setUri(patched); } } catch (Exception ex) { } } } return location; }
Example #10
Source File: ImplementationsHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testMethodImplementation() { URI uri = project.getFile("src/org/sample/IFoo.java").getRawLocationURI(); String fileURI = ResourceUtils.fixURI(uri); TextDocumentPositionParams param = new TextDocumentPositionParams(); param.setPosition(new Position(4, 14)); //Position over IFoo#someMethod param.setTextDocument(new TextDocumentIdentifier(fileURI)); List<? extends Location> implementations = handler.findImplementations(param, monitor); assertNotNull("findImplementations should not return null", implementations); assertEquals(implementations.toString(), 1, implementations.size()); Location foo2 = implementations.get(0); assertTrue("Unexpected implementation : " + foo2.getUri(), foo2.getUri().contains("org/sample/Foo2.java")); //check range points to someMethod() position assertEquals(new Position(4, 16), foo2.getRange().getStart()); assertEquals(new Position(4, 26), foo2.getRange().getEnd()); }
Example #11
Source File: GroovyServicesTypeDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testMemberVariableTypeDefinitionFromAssignment() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class TypeDefinitions {\n"); contents.append(" TypeDefinitions memberVar\n"); contents.append(" public TypeDefinitions() {\n"); contents.append(" memberVar = null\n"); contents.append(" }\n"); contents.append("}"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(3, 6); List<? extends Location> locations = services .typeDefinition(new TextDocumentPositionParams(textDocument, position)).get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(0, location.getRange().getStart().getLine()); Assertions.assertEquals(0, location.getRange().getStart().getCharacter()); Assertions.assertEquals(5, location.getRange().getEnd().getLine()); Assertions.assertEquals(1, location.getRange().getEnd().getCharacter()); }
Example #12
Source File: XMLTextDocumentService.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Override public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> definition( DefinitionParams params) { return computeDOMAsync(params.getTextDocument(), (cancelChecker, xmlDocument) -> { if (definitionLinkSupport) { return Either.forRight( getXMLLanguageService().findDefinition(xmlDocument, params.getPosition(), cancelChecker)); } List<? extends Location> locations = getXMLLanguageService() .findDefinition(xmlDocument, params.getPosition(), cancelChecker) // .stream() // .map(locationLink -> XMLPositionUtility.toLocation(locationLink)) // .collect(Collectors.toList()); return Either.forLeft(locations); }); }
Example #13
Source File: ImplementationsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private boolean shouldIncludeDefinition(ITypeRoot typeRoot, IRegion region, IJavaElement elementToSearch, List<Location> implementations) { boolean isUnimplemented = false; try { isUnimplemented = isUnimplementedMember(elementToSearch); } catch (JavaModelException e) { // do nothing. } if (isUnimplemented && implementations != null && !implementations.isEmpty()) { return false; } CompilationUnit ast = CoreASTProvider.getInstance().getAST(typeRoot, CoreASTProvider.WAIT_YES, new NullProgressMonitor()); if (ast == null) { return false; } ASTNode node = NodeFinder.perform(ast, region.getOffset(), region.getLength()); if (node instanceof SimpleName && !(node.getParent() instanceof MethodDeclaration || node.getParent() instanceof SuperMethodInvocation || node.getParent() instanceof AbstractTypeDeclaration)) { return true; } return false; }
Example #14
Source File: GroovyServicesTypeDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testLocalVariableTypeDefinitionFromDeclaration() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class TypeDefinitions {\n"); contents.append(" public TypeDefinitions() {\n"); contents.append(" TypeDefinitions localVar\n"); contents.append(" }\n"); contents.append("}"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(2, 22); List<? extends Location> locations = services .typeDefinition(new TextDocumentPositionParams(textDocument, position)).get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(0, location.getRange().getStart().getLine()); Assertions.assertEquals(0, location.getRange().getStart().getCharacter()); Assertions.assertEquals(4, location.getRange().getEnd().getLine()); Assertions.assertEquals(1, location.getRange().getEnd().getCharacter()); }
Example #15
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public List<? extends Location> getDefinitions(XtextResource resource, int offset, IReferenceFinder.IResourceAccess resourceAccess, CancelIndicator cancelIndicator) { EObject element = eObjectAtOffsetHelper.resolveElementAt(resource, offset); if (element == null) { return Collections.emptyList(); } List<Location> locations = new ArrayList<>(); TargetURIs targetURIs = collectTargetURIs(element); for (URI targetURI : targetURIs) { operationCanceledManager.checkCanceled(cancelIndicator); doRead(resourceAccess, targetURI, (EObject obj) -> { Location location = documentExtensions.newLocation(obj); if (location != null) { locations.add(location); } }); } return locations; }
Example #16
Source File: XMLSymbolsProvider.java From lemminx with Eclipse Public License 2.0 | 6 votes |
private void findSymbolInformations(DOMNode node, String container, List<SymbolInformation> symbols, boolean ignoreNode, AtomicLong limit, CancelChecker cancelChecker) throws BadLocationException { if (!isNodeSymbol(node)) { return; } String name = ""; if (!ignoreNode) { name = nodeToName(node); DOMDocument xmlDocument = node.getOwnerDocument(); Range range = getSymbolRange(node); Location location = new Location(xmlDocument.getDocumentURI(), range); SymbolInformation symbol = new SymbolInformation(name, getSymbolKind(node), location, container); checkLimit(limit); symbols.add(symbol); } final String containerName = name; node.getChildren().forEach(child -> { try { findSymbolInformations(child, containerName, symbols, false, limit, cancelChecker); } catch (BadLocationException e) { LOGGER.log(Level.SEVERE, "XMLSymbolsProvider was given a BadLocation by the provided 'node' variable", e); } }); }
Example #17
Source File: TypeDefinitionProvider.java From vscode-as3mxml with Apache License 2.0 | 6 votes |
private List<? extends Location> actionScriptTypeDefinition(IASNode offsetNode, WorkspaceFolderData folderData) { if (offsetNode == null) { //we couldn't find a node at the specified location return Collections.emptyList(); } IDefinition definition = null; if (offsetNode instanceof IIdentifierNode) { IIdentifierNode identifierNode = (IIdentifierNode) offsetNode; definition = DefinitionUtils.resolveTypeWithExtras(identifierNode, folderData.project); } if (definition == null) { //VSCode may call typeDefinition() when there isn't necessarily a //type definition referenced at the current position. return Collections.emptyList(); } List<Location> result = new ArrayList<>(); workspaceFolderManager.resolveDefinition(definition, folderData, result); return result; }
Example #18
Source File: MavenPropertiesManagerLocationTest.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
@Test public void testUsingVertxTest() throws Exception { Module javaProject = createMavenModule("using-vertx", new File("projects/maven/using-vertx")); // Test with JAR // quarkus.datasource.url Location location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "io.quarkus.reactive.pg.client.runtime.DataSourceConfig", "url", null, PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition from JAR", location); // Test with deployment JAR // quarkus.arc.auto-inject-fields location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "io.quarkus.arc.deployment.ArcConfig", "autoInjectFields", null, PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition deployment from JAR", location); // Test with Java sources // myapp.schema.create location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "org.acme.vertx.FruitResource", "schemaCreate", null, PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition from Java Sources", location); }
Example #19
Source File: GroovyServicesDefinitionTests.java From groovy-language-server with Apache License 2.0 | 6 votes |
@Test void testClassDefinitionFromClassExpression() throws Exception { Path filePath = srcRoot.resolve("Definitions.groovy"); String uri = filePath.toUri().toString(); StringBuilder contents = new StringBuilder(); contents.append("class Definitions {\n"); contents.append(" public static void staticMethod() {}\n"); contents.append(" public Definitions() {\n"); contents.append(" Definitions.staticMethod()\n"); contents.append(" }\n"); contents.append("}"); TextDocumentItem textDocumentItem = new TextDocumentItem(uri, LANGUAGE_GROOVY, 1, contents.toString()); services.didOpen(new DidOpenTextDocumentParams(textDocumentItem)); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri); Position position = new Position(3, 6); List<? extends Location> locations = services.definition(new TextDocumentPositionParams(textDocument, position)) .get().getLeft(); Assertions.assertEquals(1, locations.size()); Location location = locations.get(0); Assertions.assertEquals(uri, location.getUri()); Assertions.assertEquals(0, location.getRange().getStart().getLine()); Assertions.assertEquals(0, location.getRange().getStart().getCharacter()); Assertions.assertEquals(5, location.getRange().getEnd().getLine()); Assertions.assertEquals(1, location.getRange().getEnd().getCharacter()); }
Example #20
Source File: TypeDefinitionProvider.java From vscode-as3mxml with Apache License 2.0 | 6 votes |
private List<? extends Location> mxmlTypeDefinition(IMXMLTagData offsetTag, int currentOffset, WorkspaceFolderData folderData) { IDefinition definition = MXMLDataUtils.getTypeDefinitionForMXMLNameAtOffset(offsetTag, currentOffset, folderData.project); if (definition == null) { //VSCode may call definition() when there isn't necessarily a //definition referenced at the current position. return Collections.emptyList(); } if (MXMLDataUtils.isInsideTagPrefix(offsetTag, currentOffset)) { //ignore the tag's prefix return Collections.emptyList(); } List<Location> result = new ArrayList<>(); workspaceFolderManager.resolveDefinition(definition, folderData, result); return result; }
Example #21
Source File: DefinitionTextUtils.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
public Location toLocation() { Location location = new Location(); String escapedText = UrlEscapers.urlFragmentEscaper().escape(text); URI uri = URI.create("swc://" + path + "?" + escapedText); location.setUri(uri.toString()); location.setRange(toRange()); return location; }
Example #22
Source File: NavigateToTypeDefinitionHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testNoClassContentSupport() throws Exception { when(preferenceManager.isClientSupportsClassFileContent()).thenReturn(true); String uri = ClassFileUtil.getURI(project, "org.apache.commons.lang3.StringUtils"); when(preferenceManager.isClientSupportsClassFileContent()).thenReturn(false); List<? extends Location> definitions = handler.typeDefinition(new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(20, 26)), monitor); assertNull(definitions); }
Example #23
Source File: GradlePropertiesManagerLocationConfigQuickstartTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testConfigPropertiesMethodTest() throws Exception { Module javaProject = getModule("config-quickstart.main"); // Test with method with parameters // greeting.constructor.message Location location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "org.acme.config.GreetingMethodResource", null, "setMessage(QString;)V", PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition from GreetingMethodResource#setMessage() method", location); }
Example #24
Source File: NavigateToTypeDefinitionHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public List<? extends Location> typeDefinition(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); Location location = null; if (unit != null && !monitor.isCanceled()) { location = computeTypeDefinitionNavigation(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } return location == null ? null : Arrays.asList(location); }
Example #25
Source File: DefinitionProcessorTest.java From camel-language-server with Apache License 2.0 | 5 votes |
@Test void testRetrieveNoDefinitionWhenEndpointContainsNoId() throws Exception { CamelLanguageServer camelLanguageServer = initializeLanguageServer(ENDPOINT_UNMATCH_ID); CompletableFuture<Either<List<? extends Location>,List<? extends LocationLink>>> definitions = getDefinitionsFor(camelLanguageServer, new Position(5, 22)); assertThat(definitions.get().getLeft()).isNullOrEmpty(); assertThat(definitions.get().getRight()).isNullOrEmpty(); }
Example #26
Source File: MavenPropertiesManagerLocationTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testConfigPropertiesConstructorTest() throws Exception { Module javaProject = createMavenModule("config-quickstart", new File("projects/maven/config-quickstart")); // Test with constructor with parameters // greeting.constructor.message Location location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "org.acme.config.GreetingConstructorResource", null, "GreetingConstructorResource(QString;QString;QOptional<QString;>;)V", PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition from GreetingConstructorResource constructor", location); }
Example #27
Source File: MavenPropertiesManagerLocationTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testConfigPropertiesTest() throws Exception { Module javaProject = createMavenModule("config-properties", new File("projects/maven/config-properties")); // Test with method // greetingInterface.name Location location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "org.acme.config.IGreetingConfiguration", null, "getName()QOptional<QString;>;", PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition from IGreetingConfiguration#getName() method", location); }
Example #28
Source File: ReferencesProvider.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
private void referencesForDefinition(IDefinition definition, ILspProject project, List<Location> result) { boolean isLocal = false; if (definition instanceof IVariableDefinition) { IVariableDefinition variableDef = (IVariableDefinition) definition; isLocal = VariableClassification.LOCAL.equals(variableDef.getVariableClassification()); } else if (definition instanceof IFunctionDefinition) { IFunctionDefinition functionDef = (IFunctionDefinition) definition; isLocal = FunctionClassification.LOCAL.equals(functionDef.getFunctionClassification()); } for (ICompilationUnit unit : project.getCompilationUnits()) { if (unit == null) { continue; } UnitType unitType = unit.getCompilationUnitType(); if (!UnitType.AS_UNIT.equals(unitType) && !UnitType.MXML_UNIT.equals(unitType)) { //compiled compilation units won't have problems continue; } if (isLocal && !unit.getAbsoluteFilename().equals(definition.getContainingFilePath())) { // no need to check this file continue; } referencesForDefinitionInCompilationUnit(definition, unit, project, result); } }
Example #29
Source File: GradlePropertiesManagerLocationConfigQuickstartTest.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Test public void testConfigPropertiesConstructorTest() throws Exception { Module javaProject = getModule("config-quickstart.main"); // Test with constructor with parameters // greeting.constructor.message Location location = PropertiesManager.getInstance().findPropertyLocation(javaProject, "org.acme.config.GreetingConstructorResource", null, "GreetingConstructorResource(QString;QString;QOptional<QString;>;)V", PsiUtilsImpl.getInstance()); Assert.assertNotNull("Definition from GreetingConstructorResource constructor", location); }
Example #30
Source File: AbstractCamelLanguageServerTest.java From camel-language-server with Apache License 2.0 | 5 votes |
protected CompletableFuture<Either<List<? extends Location>,List<? extends LocationLink>>> getDefinitionsFor(CamelLanguageServer camelLanguageServer, Position position) { TextDocumentService textDocumentService = camelLanguageServer.getTextDocumentService(); DefinitionParams params = new DefinitionParams(); params.setPosition(position); params.setTextDocument(new TextDocumentIdentifier(DUMMY_URI+extensionUsed)); return textDocumentService.definition(params); }