Search in sources :

Example 1 with MavenProjectFinder

use of org.springframework.ide.vscode.commons.maven.java.MavenProjectFinder in project sts4 by spring-projects.

the class BootLanguageServerParams method createFallbackProjectCache.

private static JavaProjectsService createFallbackProjectCache(SimpleLanguageServer server) {
    CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder();
    MavenProjectCache mavenProjectCache = new MavenProjectCache(server, MavenCore.getDefault(), true, Paths.get(IJavaProject.PROJECT_CACHE_FOLDER));
    javaProjectFinder.addJavaProjectFinder(new MavenProjectFinder(mavenProjectCache));
    GradleProjectCache gradleProjectCache = new GradleProjectCache(server, GradleCore.getDefault(), true, Paths.get(IJavaProject.PROJECT_CACHE_FOLDER));
    javaProjectFinder.addJavaProjectFinder(new GradleProjectFinder(gradleProjectCache));
    CompositeProjectOvserver projectObserver = new CompositeProjectOvserver(Arrays.asList(mavenProjectCache, gradleProjectCache));
    return new JavaProjectsService() {

        @Override
        public void removeListener(Listener listener) {
            projectObserver.removeListener(listener);
        }

        @Override
        public void addListener(Listener listener) {
            projectObserver.addListener(listener);
        }

        @Override
        public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
            return javaProjectFinder.find(doc);
        }
    };
}
Also used : GradleProjectCache(org.springframework.ide.vscode.commons.gradle.GradleProjectCache) MavenProjectCache(org.springframework.ide.vscode.commons.maven.java.MavenProjectCache) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) CompositeJavaProjectFinder(org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder) Listener(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) CompositeProjectOvserver(org.springframework.ide.vscode.commons.languageserver.java.CompositeProjectOvserver) MavenProjectFinder(org.springframework.ide.vscode.commons.maven.java.MavenProjectFinder) JavaProjectsService(org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsService) GradleProjectFinder(org.springframework.ide.vscode.commons.gradle.GradleProjectFinder)

Aggregations

TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 JavaProjectsService (org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsService)1 GradleProjectCache (org.springframework.ide.vscode.commons.gradle.GradleProjectCache)1 GradleProjectFinder (org.springframework.ide.vscode.commons.gradle.GradleProjectFinder)1 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)1 CompositeJavaProjectFinder (org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder)1 CompositeProjectOvserver (org.springframework.ide.vscode.commons.languageserver.java.CompositeProjectOvserver)1 Listener (org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener)1 MavenProjectCache (org.springframework.ide.vscode.commons.maven.java.MavenProjectCache)1 MavenProjectFinder (org.springframework.ide.vscode.commons.maven.java.MavenProjectFinder)1