Search in sources :

Example 1 with WorkspaceFolder

use of org.eclipse.lsp4j.WorkspaceFolder in project eclipse.jdt.ls by eclipse.

the class WorkspaceFolderChangeHandler method update.

public void update(DidChangeWorkspaceFoldersParams params) {
    final Collection<IPath> addedRootPaths = new ArrayList<>();
    final Collection<IPath> removedRootPaths = new ArrayList<>();
    for (WorkspaceFolder folder : params.getEvent().getAdded()) {
        IPath rootPath = ResourceUtils.filePathFromURI(folder.getUri());
        if (rootPath != null) {
            addedRootPaths.add(rootPath);
        }
    }
    for (WorkspaceFolder folder : params.getEvent().getRemoved()) {
        IPath rootPath = ResourceUtils.filePathFromURI(folder.getUri());
        if (rootPath != null) {
            removedRootPaths.add(rootPath);
        }
    }
    projectManager.updateWorkspaceFolders(addedRootPaths, removedRootPaths);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder)

Example 2 with WorkspaceFolder

use of org.eclipse.lsp4j.WorkspaceFolder in project sts4 by spring-projects.

the class SpringIndexer method scanFiles.

private void scanFiles(WorkspaceFolder directory) {
    try {
        Map<Optional<IJavaProject>, List<String>> projects = Files.walk(Paths.get(new URI(directory.getUri()))).filter(path -> path.getFileName().toString().endsWith(".java")).filter(Files::isRegularFile).map(path -> path.toAbsolutePath().toString()).collect(Collectors.groupingBy((javaFile) -> projectFinder.find(new TextDocumentIdentifier(new File(javaFile).toURI().toString()))));
        projects.forEach((maybeProject, files) -> maybeProject.ifPresent(project -> scanProject(project, files.toArray(new String[0]))));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Arrays(java.util.Arrays) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) SymbolProvider(org.springframework.ide.vscode.boot.java.handlers.SymbolProvider) LoggerFactory(org.slf4j.LoggerFactory) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) FileASTRequestor(org.eclipse.jdt.core.dom.FileASTRequestor) ASTVisitor(org.eclipse.jdt.core.dom.ASTVisitor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Location(org.eclipse.lsp4j.Location) AnnotationHierarchyAwareLookup(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup) URI(java.net.URI) Path(java.nio.file.Path) ExceptionUtil(org.springframework.ide.vscode.commons.util.ExceptionUtil) Predicate(java.util.function.Predicate) SymbolAddOnInformation(org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) EnhancedSymbolInformation(org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation) List(java.util.List) Stream(java.util.stream.Stream) ASTParser(org.eclipse.jdt.core.dom.ASTParser) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) AST(org.eclipse.jdt.core.dom.AST) Optional(java.util.Optional) SimpleWorkspaceService(org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService) SingleMemberAnnotation(org.eclipse.jdt.core.dom.SingleMemberAnnotation) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) SimpleLanguageServer(org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer) MarkerAnnotation(org.eclipse.jdt.core.dom.MarkerAnnotation) JavaProjectFinder(org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder) SymbolKind(org.eclipse.lsp4j.SymbolKind) BootLanguageServerParams(org.springframework.ide.vscode.boot.BootLanguageServerParams) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) ProjectObserver(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) StringUtil(org.springframework.ide.vscode.commons.util.StringUtil) ImmutableList(com.google.common.collect.ImmutableList) Annotation(org.eclipse.jdt.core.dom.Annotation) AnnotationHierarchies(org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies) UriUtil(org.springframework.ide.vscode.commons.util.UriUtil) NormalAnnotation(org.eclipse.jdt.core.dom.NormalAnnotation) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) Logger(org.slf4j.Logger) Files(java.nio.file.Files) JavaCore(org.eclipse.jdt.core.JavaCore) Futures(org.springframework.ide.vscode.commons.util.Futures) FileUtils(org.apache.commons.io.FileUtils) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) File(java.io.File) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) Listener(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener) Paths(java.nio.file.Paths) Collections(java.util.Collections) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Optional(java.util.Optional) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) Files(java.nio.file.Files) URI(java.net.URI) File(java.io.File)

Example 3 with WorkspaceFolder

use of org.eclipse.lsp4j.WorkspaceFolder in project sts4 by spring-projects.

the class SpringIndexerHarness method wsFolder.

public Collection<WorkspaceFolder> wsFolder(File directory) {
    if (directory != null) {
        WorkspaceFolder folder = new WorkspaceFolder();
        folder.setName(directory.getName());
        folder.setUri(directory.toURI().toString());
        return ImmutableList.of(folder);
    }
    return ImmutableList.of();
}
Also used : WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder)

Example 4 with WorkspaceFolder

use of org.eclipse.lsp4j.WorkspaceFolder in project xtext-core by eclipse.

the class IndexOnlyProjectTest method getServerModule.

@Override
public com.google.inject.Module getServerModule() {
    return Modules2.mixin(new ServerModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(IMultiRootWorkspaceConfigFactory.class).toInstance(new MultiRootWorkspaceConfigFactory() {

                @Override
                public void addProjectsForWorkspaceFolder(WorkspaceConfig workspaceConfig, WorkspaceFolder workspaceFolder, Set<String> existingNames) {
                    String uri = null;
                    if (workspaceFolder != null) {
                        uri = workspaceFolder.getUri();
                    }
                    if (uri != null) {
                        FileProjectConfig project = new FileProjectConfig(getUriExtensions().toUri(workspaceFolder.getUri()), getUniqueProjectName(workspaceFolder.getName(), existingNames)) {

                            @Override
                            public boolean isIndexOnly() {
                                return true;
                            }
                        };
                        project.addSourceFolder(".");
                        workspaceConfig.addProject(project);
                    }
                }
            });
        }
    });
}
Also used : Binder(com.google.inject.Binder) IMultiRootWorkspaceConfigFactory(org.eclipse.xtext.ide.server.IMultiRootWorkspaceConfigFactory) MultiRootWorkspaceConfigFactory(org.eclipse.xtext.ide.server.MultiRootWorkspaceConfigFactory) Set(java.util.Set) WorkspaceConfig(org.eclipse.xtext.workspace.WorkspaceConfig) ServerModule(org.eclipse.xtext.ide.server.ServerModule) Module(com.google.inject.Module) FileProjectConfig(org.eclipse.xtext.workspace.FileProjectConfig) ServerModule(org.eclipse.xtext.ide.server.ServerModule) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder)

Example 5 with WorkspaceFolder

use of org.eclipse.lsp4j.WorkspaceFolder in project xtext-core by eclipse.

the class WorkspaceManager method initialize.

/**
 * Initialize a workspace at the given location.
 *
 * @param baseDir
 *            the location
 * @param issueAcceptor
 *            the issue acceptor
 * @param cancelIndicator
 *            allows to cancel the initialization
 */
public void initialize(URI baseDir, Procedure2<? super URI, ? super Iterable<Issue>> issueAcceptor, CancelIndicator cancelIndicator) {
    WorkspaceFolder workspaceFolder = new WorkspaceFolder(uriExtensions.toUriString(baseDir), "");
    initialize(Collections.singletonList(workspaceFolder), issueAcceptor, cancelIndicator);
}
Also used : WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder)

Aggregations

WorkspaceFolder (org.eclipse.lsp4j.WorkspaceFolder)14 ArrayList (java.util.ArrayList)5 InitializeParams (org.eclipse.lsp4j.InitializeParams)4 InitializeResult (org.eclipse.lsp4j.InitializeResult)3 WorkspaceFoldersChangeEvent (org.eclipse.lsp4j.WorkspaceFoldersChangeEvent)3 ImmutableList (com.google.common.collect.ImmutableList)2 File (java.io.File)2 URI (java.net.URI)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ClientCapabilities (org.eclipse.lsp4j.ClientCapabilities)2 DidChangeWorkspaceFoldersParams (org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams)2 DocumentSymbolCapabilities (org.eclipse.lsp4j.DocumentSymbolCapabilities)2 ServerCapabilities (org.eclipse.lsp4j.ServerCapabilities)2 TextDocumentClientCapabilities (org.eclipse.lsp4j.TextDocumentClientCapabilities)2 WorkspaceServerCapabilities (org.eclipse.lsp4j.WorkspaceServerCapabilities)2