use of org.eclipse.jdt.ls.core.internal.handlers.NavigateToDefinitionHandler in project eclipse.jdt.ls by eclipse.
the class SyntaxLanguageServer method definition.
@Override
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> definition(DefinitionParams position) {
logInfo(">> document/definition");
NavigateToDefinitionHandler handler = new NavigateToDefinitionHandler(this.preferenceManager);
return computeAsync((monitor) -> {
waitForLifecycleJobs(monitor);
List<? extends Location> locations = handler.definition(position, monitor);
for (Location location : locations) {
location.setUri(JDTUtils.replaceUriFragment(location.getUri(), SYNTAX_SERVER_ID));
}
return Either.forLeft(locations);
});
}
use of org.eclipse.jdt.ls.core.internal.handlers.NavigateToDefinitionHandler in project eclipse.jdt.ls by eclipse.
the class InvisibleProjectBuildSupportTest method testUpdateReferencedLibraries.
@Test
public void testUpdateReferencedLibraries() throws Exception {
IProject project = copyAndImportFolder("singlefile/simple", "src/App.java");
NavigateToDefinitionHandler handler = new NavigateToDefinitionHandler(preferenceManager);
String uri = ClassFileUtil.getURI(project, "App");
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri);
List<? extends Location> definitions = handler.definition(new TextDocumentPositionParams(identifier, new Position(0, 13)), monitor);
// The original mylib.jar is an empty jar, so the GTD is not available
assertEquals(0, definitions.size());
// replace it which contains the class 'mylib.A'
IPath projectRealPath = ProjectUtils.getProjectRealFolder(project);
IPath newLibPath = projectRealPath.append("mylib.jar");
IPath referencedLibraryPath = projectRealPath.append("lib/mylib.jar");
FileUtils.copyFile(newLibPath.toFile(), referencedLibraryPath.toFile());
List<String> include = Arrays.asList("lib/**/*.jar");
ReferencedLibraries libraries = new ReferencedLibraries(new HashSet<>(include));
UpdateClasspathJob.getInstance().updateClasspath(JavaCore.create(project), libraries);
waitForBackgroundJobs();
definitions = handler.definition(new TextDocumentPositionParams(identifier, new Position(0, 13)), monitor);
assertEquals(1, definitions.size());
}
Aggregations