Remove obsolete method 'isProjectRoot' from project finder interface
This commit is contained in:
@@ -87,8 +87,8 @@ public class AutowiredHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutowiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
@@ -113,8 +113,8 @@ public class AutowiredHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutowiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
@@ -132,8 +132,8 @@ public class AutowiredHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutowiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
@@ -153,8 +153,8 @@ public class AutowiredHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutowiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
|
||||
@@ -87,8 +87,8 @@ public class ComponentHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutomaticallyWiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
@@ -113,8 +113,8 @@ public class ComponentHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutowiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
@@ -134,8 +134,8 @@ public class ComponentHoverProviderTest {
|
||||
harness.intialize(directory);
|
||||
|
||||
String docURI = "file://" + directory.getAbsolutePath() + "/src/main/java/org/test/MyAutomaticallyWiredComponent.java";
|
||||
IJavaProject project = projectFinder.find(directory);
|
||||
TextDocument document = createTempTextDocument(docURI);
|
||||
IJavaProject project = projectFinder.find(document);
|
||||
|
||||
CompilationUnit cu = parse(document, project);
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.AbstractJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
@@ -39,17 +39,9 @@ import org.springframework.ide.vscode.project.harness.PropertyIndexHarness;
|
||||
*/
|
||||
public class ScopeCompletionTest {
|
||||
|
||||
protected final CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder(Arrays.asList(new JavaProjectFinder() {
|
||||
protected final CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder(Arrays.asList((JavaProjectFinder)new AbstractJavaProjectFinder() {
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IJavaProject find(File file) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IJavaProject find(IDocument doc) {
|
||||
public IJavaProject find(File doc) {
|
||||
return getTestProject();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
@@ -29,7 +28,6 @@ import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.AbstractJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
@@ -53,29 +51,17 @@ public class ValueCompletionTest {
|
||||
testProject = ProjectsHarness.INSTANCE.mavenProject("test-annotations");
|
||||
indexHarness = new PropertyIndexHarness();
|
||||
|
||||
harness = new LanguageServerHarness<BootJavaLanguageServer>(new Callable<BootJavaLanguageServer>() {
|
||||
@Override
|
||||
public BootJavaLanguageServer call() throws Exception {
|
||||
BootJavaLanguageServer server = new BootJavaLanguageServer(
|
||||
new CompositeJavaProjectFinder(new ArrayList<>(Collections.singleton(new AbstractJavaProjectFinder() {
|
||||
harness = new LanguageServerHarness<BootJavaLanguageServer>(() -> {
|
||||
BootJavaLanguageServer server = new BootJavaLanguageServer(
|
||||
new CompositeJavaProjectFinder(new ArrayList<>(Collections.singleton(new AbstractJavaProjectFinder() {
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavaProject find(File file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavaProject find(IDocument doc) {
|
||||
public IJavaProject find(File doc) {
|
||||
return getTestProject();
|
||||
}
|
||||
}))),
|
||||
indexHarness.getIndexProvider());
|
||||
return server;
|
||||
}
|
||||
}))),
|
||||
indexHarness.getIndexProvider()
|
||||
);
|
||||
return server;
|
||||
}) {
|
||||
@Override
|
||||
protected String getFileExtension() {
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.AbstractJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
@@ -48,15 +49,7 @@ public abstract class AbstractPropsEditorTest {
|
||||
protected PropertyIndexHarness md;
|
||||
protected final CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder(Arrays.asList(new AbstractJavaProjectFinder() {
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IJavaProject find(File file) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IJavaProject find(IDocument doc) {
|
||||
public IJavaProject find(File doc) {
|
||||
return getTestProject();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -36,10 +36,4 @@ public class GradleProjectFinder extends AbstractJavaProjectFinder {
|
||||
File gradlebuild = FileUtils.findFile(file, GradleCore.GRADLE_BUILD_FILE);
|
||||
return cache.project(gradlebuild);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return FileUtils.findFile(file, GradleCore.GRADLE_BUILD_FILE, false) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
public abstract class AbstractJavaProjectFinder implements JavaProjectFinder {
|
||||
|
||||
@Override
|
||||
public IJavaProject find(IDocument doc) {
|
||||
public final IJavaProject find(IDocument doc) {
|
||||
try {
|
||||
String uriStr = doc.getUri();
|
||||
if (StringUtil.hasText(uriStr)) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class CompositeJavaProjectFinder implements JavaProjectFinder {
|
||||
public class CompositeJavaProjectFinder extends AbstractJavaProjectFinder {
|
||||
|
||||
private final List<JavaProjectFinder> projectFinders;
|
||||
|
||||
@@ -46,19 +46,8 @@ public class CompositeJavaProjectFinder implements JavaProjectFinder {
|
||||
return projectFinders.remove(javaProjectFinder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavaProject find(IDocument doc) {
|
||||
return projectFinders.stream().map(finder -> finder.find(doc)).filter(Objects::nonNull).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavaProject find(File file) {
|
||||
return projectFinders.stream().map(finder -> finder.find(file)).filter(Objects::nonNull).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return projectFinders.stream().filter(finder -> finder.isProjectRoot(file)) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
|
||||
/**
|
||||
* Java project finder. Able to find a java project for a file or document
|
||||
*
|
||||
* Java project finder provides a means to obtain the project context associated with
|
||||
* a document location.
|
||||
* *
|
||||
* @author Alex Boyko
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public interface JavaProjectFinder {
|
||||
|
||||
IJavaProject find(IDocument doc);
|
||||
IJavaProject find(File file);
|
||||
boolean isProjectRoot(File file);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,10 +36,4 @@ public class MavenProjectFinder extends AbstractJavaProjectFinder {
|
||||
File pomFile = FileUtils.findFile(file, MavenCore.POM_XML);
|
||||
return cache.project(pomFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return FileUtils.findFile(file, MavenCore.POM_XML, false) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,10 +38,4 @@ public class JavaProjectWithClasspathFileFinder extends AbstractJavaProjectFinde
|
||||
File cpFile = FileUtils.findFile(file, MavenCore.CLASSPATH_TXT);
|
||||
return cache.project(cpFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectRoot(File file) {
|
||||
return FileUtils.findFile(file, MavenCore.CLASSPATH_TXT, false) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user