org.eclipse.lsp4j.WorkspaceSymbolParams Java Examples

The following examples show how to use org.eclipse.lsp4j.WorkspaceSymbolParams. 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: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected void testSymbol(final Procedure1<? super WorkspaceSymbolConfiguration> configurator) {
  try {
    @Extension
    final WorkspaceSymbolConfiguration configuration = new WorkspaceSymbolConfiguration();
    configuration.setFilePath(("MyModel." + this.fileExtension));
    configurator.apply(configuration);
    this.initializeContext(configuration);
    String _query = configuration.getQuery();
    WorkspaceSymbolParams _workspaceSymbolParams = new WorkspaceSymbolParams(_query);
    final List<? extends SymbolInformation> symbols = this.languageServer.symbol(_workspaceSymbolParams).get();
    Procedure1<? super List<? extends SymbolInformation>> _assertSymbols = configuration.getAssertSymbols();
    boolean _tripleNotEquals = (_assertSymbols != null);
    if (_tripleNotEquals) {
      configuration.getAssertSymbols().apply(symbols);
    } else {
      final String actualSymbols = this.toExpectation(symbols);
      this.assertEquals(configuration.getExpectedSymbols(), actualSymbols);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #2
Source File: WorkspaceSymbolProvider.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
public List<LSPNavigationItem> workspaceSymbols(String name, Project project) {
  final Set<LanguageServerWrapper> serverWrappers = IntellijLanguageClient
      .getProjectToLanguageWrappers()
      .getOrDefault(FileUtils.projectToUri(project), Collections.emptySet());

  final WorkspaceSymbolParams symbolParams = new WorkspaceSymbolParams(name);
  return serverWrappers.stream().filter(s -> s.getStatus() == ServerStatus.INITIALIZED)
      .flatMap(server -> collectSymbol(server, server.getRequestManager(), symbolParams))
      .map(s -> createNavigationItem(s, project)).filter(Objects::nonNull).collect(Collectors.toList());
}
 
Example #3
Source File: JDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	logInfo(">> workspace/symbol");
	return computeAsync((monitor) -> {
		return WorkspaceSymbolHandler.search(params.getQuery(), monitor);
	});
}
 
Example #4
Source File: ActionScriptServices.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
/**
 * Searches by name for a symbol in the workspace.
 */
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams 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
        {
            WorkspaceSymbolProvider provider = new WorkspaceSymbolProvider(workspaceFolderManager);
            return provider.workspaceSymbol(params, cancelToken);
        }
        finally
        {
            compilerWorkspace.doneBuilding();
        }
    });
}
 
Example #5
Source File: GroovyServices.java    From groovy-language-server with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	WorkspaceSymbolProvider provider = new WorkspaceSymbolProvider(astVisitor);
	return provider.provideWorkspaceSymbols(params.getQuery());
}
 
Example #6
Source File: XMLWorkspaceService.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	return null;
}
 
Example #7
Source File: CamelWorkspaceService.java    From camel-language-server with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	LOGGER.info("SERVER: symbolQuery: {}", params.getQuery());
	return CompletableFuture.completedFuture(Collections.emptyList());
}
 
Example #8
Source File: XLanguageServerImpl.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	return lspExecutorService.submitAndCancelPrevious(WorkspaceSymbolParams.class, "symbol",
			cancelIndicator -> symbol(params, cancelIndicator));
}
 
Example #9
Source File: XLanguageServerImpl.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Compute the symbol information. Executed in a read request.
 */
protected List<? extends SymbolInformation> symbol(WorkspaceSymbolParams params, CancelIndicator cancelIndicator) {
	return workspaceSymbolService.getSymbols(params.getQuery(), resourceAccess,
			openFilesManager.createLiveScopeIndex(), cancelIndicator);
}
 
Example #10
Source File: WorkspaceServiceImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams arg0) {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #11
Source File: TeiidDdlWorkspaceService.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {

    return CompletableFuture.completedFuture(Collections.emptyList());
}
 
Example #12
Source File: WorkspaceSymbolProvider.java    From vscode-as3mxml with Apache License 2.0 4 votes vote down vote up
public List<? extends SymbolInformation> workspaceSymbol(WorkspaceSymbolParams params, CancelChecker cancelToken)
{
	cancelToken.checkCanceled();
	Set<String> qualifiedNames = new HashSet<>();
	List<SymbolInformation> result = new ArrayList<>();
	String query = params.getQuery();
	StringBuilder currentQuery = new StringBuilder();
	List<String> queries = new ArrayList<>();
	for(int i = 0, length = query.length(); i < length; i++)
	{
		String charAtI = query.substring(i, i + 1);
		if(i > 0 && charAtI.toUpperCase().equals(charAtI))
		{
			queries.add(currentQuery.toString().toLowerCase());
			currentQuery = new StringBuilder();
		}
		currentQuery.append(charAtI);
	}
	if(currentQuery.length() > 0)
	{
		queries.add(currentQuery.toString().toLowerCase());
	}
	for (WorkspaceFolder folder : workspaceFolderManager.getWorkspaceFolders())
	{
		WorkspaceFolderData folderData = workspaceFolderManager.getWorkspaceFolderData(folder);
		ILspProject project = folderData.project;
		if (project == null)
		{
			continue;
		}
		for (ICompilationUnit unit : project.getCompilationUnits())
		{
			if (unit == null)
			{
				continue;
			}
			UnitType unitType = unit.getCompilationUnitType();
			if (UnitType.SWC_UNIT.equals(unitType))
			{
				List<IDefinition> definitions = unit.getDefinitionPromises();
				for (IDefinition definition : definitions)
				{
					if (definition instanceof DefinitionPromise)
					{
						//we won't be able to detect what type of definition
						//this is without getting the actual definition from the
						//promise.
						DefinitionPromise promise = (DefinitionPromise) definition;
						definition = promise.getActualDefinition();
					}
					if (definition.isImplicit())
					{
						continue;
					}
					if (!matchesQueries(queries, definition.getQualifiedName()))
					{
						continue;
					}
					String qualifiedName = definition.getQualifiedName();
					if (qualifiedNames.contains(qualifiedName))
					{
						//we've already added this symbol
						//this can happen when there are multiple root
						//folders in the workspace
						continue;
					}
					SymbolInformation symbol = workspaceFolderManager.definitionToSymbolInformation(definition, project);
					if (symbol != null)
					{
						qualifiedNames.add(qualifiedName);
						result.add(symbol);
					}
				}
			}
			else if (UnitType.AS_UNIT.equals(unitType) || UnitType.MXML_UNIT.equals(unitType))
			{
				IASScope[] scopes;
				try
				{
					scopes = unit.getFileScopeRequest().get().getScopes();
				}
				catch (Exception e)
				{
					return Collections.emptyList();
				}
				for (IASScope scope : scopes)
				{
					querySymbolsInScope(queries, scope, qualifiedNames, project, result);
				}
			}
		}
	}
	cancelToken.checkCanceled();
	return result;
}
 
Example #13
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	return requestManager.runRead((cancelIndicator) -> symbol(params, cancelIndicator));
}
 
Example #14
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Compute the symbol information. Executed in a read request.
 * @since 2.20
 */
protected List<? extends SymbolInformation> symbol(WorkspaceSymbolParams params, CancelIndicator cancelIndicator) {
	return workspaceSymbolService.getSymbols(params.getQuery(), resourceAccess, workspaceManager.getIndex(),
			cancelIndicator);
}
 
Example #15
Source File: WorkspaceService.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The workspace symbol request is sent from the client to the server to
 * list project-wide symbols matching the query string.
 *
 * Registration Options: void
 */
@JsonRequest
default CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
	throw new UnsupportedOperationException();
}