org.eclipse.lsp4j.TypeDefinitionParams Java Examples

The following examples show how to use org.eclipse.lsp4j.TypeDefinitionParams. 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: XMLTextDocumentService.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> typeDefinition(
		TypeDefinitionParams params) {
	return computeDOMAsync(params.getTextDocument(), (cancelChecker, xmlDocument) -> {
		if (typeDefinitionLinkSupport) {
			return Either.forRight(
					getXMLLanguageService().findTypeDefinition(xmlDocument, params.getPosition(), cancelChecker));
		}
		List<? extends Location> locations = getXMLLanguageService()
				.findTypeDefinition(xmlDocument, params.getPosition(), cancelChecker) //
				.stream() //
				.map(locationLink -> XMLPositionUtility.toLocation(locationLink)) //
				.collect(Collectors.toList());
		return Either.forLeft(locations);
	});
}
 
Example #2
Source File: JDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> typeDefinition(TypeDefinitionParams position) {
	logInfo(">> document/typeDefinition");
	NavigateToTypeDefinitionHandler handler = new NavigateToTypeDefinitionHandler();
	return computeAsync((monitor) -> {
		waitForLifecycleJobs(monitor);
		return Either.forLeft((handler.typeDefinition(position, monitor)));
	});
}
 
Example #3
Source File: SyntaxLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> typeDefinition(TypeDefinitionParams position) {
	logInfo(">> document/typeDefinition");
	NavigateToTypeDefinitionHandler handler = new NavigateToTypeDefinitionHandler();
	return computeAsync((monitor) -> {
		waitForLifecycleJobs(monitor);
		List<? extends Location> locations = handler.typeDefinition(position, monitor);
		for (Location location : locations) {
			location.setUri(JDTUtils.replaceUriFragment(location.getUri(), SYNTAX_SERVER_ID));
		}
		return Either.forLeft(locations);
	});
}
 
Example #4
Source File: SyntaxServerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testTypeDefinition() throws Exception {
	URI fileURI = openFile("maven/salut4", "src/main/java/java/Foo.java");
	TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileURI.toString());
	TypeDefinitionParams params = new TypeDefinitionParams(identifier, new Position(11, 24));
	Either<List<? extends Location>, List<? extends LocationLink>> result = server.typeDefinition(params).join();
	assertTrue(result.isLeft());
	assertNotNull(result.getLeft());
	assertEquals(1, result.getLeft().size());
	String targetUri = result.getLeft().get(0).getUri();
	assertNotNull(targetUri);
	assertEquals(ResourceUtils.toClientUri(getFileUri("maven/salut4", "src/main/java/java/Bar.java")), targetUri);
}
 
Example #5
Source File: ActionScriptServices.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
/**
 * Finds where the type of the definition referenced at the current position
 * in a text document is defined.
 */
@Override
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> typeDefinition(TypeDefinitionParams params)
{
    return CompletableFutures.computeAsync(compilerWorkspace.getExecutorService(), cancelToken ->
    {
        cancelToken.checkCanceled();

        //make sure that the latest changes have been passed to
        //workspace.fileChanged() before proceeding
        if(realTimeProblemsChecker != null)
        {
            realTimeProblemsChecker.updateNow();
        }

        compilerWorkspace.startBuilding();
        try
        {
            TypeDefinitionProvider provider = new TypeDefinitionProvider(workspaceFolderManager, fileTracker);
            return provider.typeDefinition(params, cancelToken);
        }
        finally
        {
            compilerWorkspace.doneBuilding();
        }
    });
}
 
Example #6
Source File: TextDocumentService.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The goto type definition request is sent from the client to the server to resolve
 * the type definition location of a symbol at a given text document position.
 * 
 * Registration Options: TextDocumentRegistrationOptions
 * 
 * Since version 3.6.0
 */
@JsonRequest
@ResponseJsonAdapter(LocationLinkListAdapter.class)
default CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> typeDefinition(TypeDefinitionParams params) {
	throw new UnsupportedOperationException();
}