diff --git a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/FileClasspath.java b/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/FileClasspath.java deleted file mode 100644 index 98f437236..000000000 --- a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/FileClasspath.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2018 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.maven.java.classpathfile; - -import java.io.File; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.springframework.ide.vscode.commons.java.ClasspathData; -import org.springframework.ide.vscode.commons.java.IClasspath; -import org.springframework.ide.vscode.commons.java.IType; -import org.springframework.ide.vscode.commons.languageserver.jdt.ls.Classpath.CPE; -import org.springframework.ide.vscode.commons.maven.MavenCore; - -import com.google.common.collect.ImmutableList; - -import reactor.core.publisher.Flux; -import reactor.util.function.Tuple2; - -/** - * Classpath for a project containing classpath text file - * - * @author Alex Boyko - * - */ -public class FileClasspath implements IClasspath { - - //TODO: This is obsolete and no longer used. Should delete and anything taht uses it probably too. - - private Path classpathFilePath; - - public FileClasspath(Path classpathFilePath) { - this.classpathFilePath = classpathFilePath; - } - - @Override - public ImmutableList getClasspathEntries() throws Exception { - return ImmutableList.of(); -// return ImmutableList.copyOf(Stream.concat(MavenCore.readClassPathFile(classpathFilePath), -// Stream.of(classpathFilePath.getParent().resolve("target/classes"), -// classpathFilePath.getParent().resolve("target/test-classes"))).collect(Collectors.toList())); - } - - @Override - public ImmutableList getClasspathResources() { - return ImmutableList.of(); - } - - @Override - public String getName() { - return classpathFilePath.toFile().getParentFile().getName(); - } - - @Override - public boolean exists() { - return Files.exists(classpathFilePath); - } - - @Override - public IType findType(String fqName) { - //TODO: implement - return null; - } - - @Override - public Flux> fuzzySearchTypes(String searchTerm, Predicate typeFilter) { - return Flux.empty(); - } - - @Override - public Flux> fuzzySearchPackages(String searchTerm) { - return Flux.empty(); - } - - @Override - public Flux allSubtypesOf(IType type) { - return Flux.empty(); - } - - @Override - public Path getOutputFolder() { - return null; - } - - @Override - public ImmutableList getSourceFolders() { - return ImmutableList.of(); - } - - @Override - public Optional findClasspathResourceContainer(String fqName) { - return Optional.empty(); - } - - @Override - public ClasspathData createClasspathData() throws Exception { - return ClasspathData.from(getName(), getClasspathEntries(), getClasspathResources(), getOutputFolder()); - } - - @Override - public void reindex() { - } - - @Override - public Optional sourceContainer(File classpathResource) { - return Optional.empty(); - } -} diff --git a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFile.java b/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFile.java deleted file mode 100644 index a48565f6f..000000000 --- a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFile.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.maven.java.classpathfile; - -import java.io.File; -import java.nio.file.Paths; -import java.util.concurrent.CompletableFuture; - -import org.springframework.ide.vscode.commons.java.IClasspath; -import org.springframework.ide.vscode.commons.java.IJavaProject; - -/** - * Java project that contains classpath text file - * - * @author Alex Boyko - * - */ -public class JavaProjectWithClasspathFile implements IJavaProject { - - private File cpFile; - private FileClasspath classpath; - - public JavaProjectWithClasspathFile(File cpFile) { - this.cpFile = cpFile; - this.classpath = new FileClasspath(Paths.get(cpFile.toURI())); - } - - @Override - public IClasspath getClasspath() { - return classpath; - } - - @Override - public String toString() { - return "JavaProjectWithClasspathFile("+cpFile+")"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cpFile == null) ? 0 : cpFile.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - JavaProjectWithClasspathFile other = (JavaProjectWithClasspathFile) obj; - if (cpFile == null) { - if (other.cpFile != null) - return false; - } else if (!cpFile.equals(other.cpFile)) - return false; - return true; - } - - CompletableFuture update() { - return CompletableFuture.supplyAsync(() -> doUpdate()); - } - - private synchronized boolean doUpdate() { - FileClasspath newClasspath = new FileClasspath(Paths.get(cpFile.toURI())); - if (newClasspath.equals(classpath)) { - return false; - } else { - this.classpath = newClasspath; - return true; - } - } - -} \ No newline at end of file diff --git a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFileCache.java b/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFileCache.java deleted file mode 100644 index 3614c27b4..000000000 --- a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFileCache.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.maven.java.classpathfile; - -import java.io.File; - -import org.springframework.ide.vscode.commons.languageserver.Sts4LanguageServer; -import org.springframework.ide.vscode.commons.languageserver.java.AbstractFileToProjectCache; - -public class JavaProjectWithClasspathFileCache extends AbstractFileToProjectCache { - - public JavaProjectWithClasspathFileCache(Sts4LanguageServer server) { - super(server, false, null); - } - - @Override - protected boolean update(JavaProjectWithClasspathFile project) { - project.update(); - return true; - } - - @Override - protected JavaProjectWithClasspathFile createProject(File cpFile) throws Exception { - return new JavaProjectWithClasspathFile(cpFile); - } - - - -} diff --git a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFileFinder.java b/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFileFinder.java deleted file mode 100644 index 19e4ce879..000000000 --- a/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/classpathfile/JavaProjectWithClasspathFileFinder.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 2018 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.maven.java.classpathfile; - -import java.io.File; -import java.util.Optional; - -import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.languageserver.java.FileBasedJavaProjectFinder; -import org.springframework.ide.vscode.commons.maven.MavenCore; -import org.springframework.ide.vscode.commons.util.FileUtils; - -/** - * Finder for projects with classpath.txt file that contains classpath entries - * For test purposes only. - * - * @author Alex Boyko - * - */ -public class JavaProjectWithClasspathFileFinder extends FileBasedJavaProjectFinder { - - private JavaProjectWithClasspathFileCache cache; - - public JavaProjectWithClasspathFileFinder(JavaProjectWithClasspathFileCache cache) { - super(); - this.cache = cache; - } - - @Override - public Optional find(File file) { - File cpFile = FileUtils.findFile(file, MavenCore.CLASSPATH_TXT); - if (cpFile!=null) { - return Optional.ofNullable(cache.project(cpFile)); - } - return Optional.empty(); - } - - @Override - protected Optional findProjectByName(String name) { - return cache.projectByName(name); - } -} diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java index d24a32ffe..e5e3ee20c 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java @@ -14,7 +14,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import org.junit.Ignore; import org.junit.Test; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.languageserver.ProgressService; @@ -67,38 +66,4 @@ public class PropertiesIndexTest { PropertyInfo propertyInfo = index.get("my.server.port"); assertNull(propertyInfo); } - - @Test @Ignore //ignore because classpath file is going to disapear and pieces already removed - public void springStandardPropertyPresent_ClasspathFile() throws Exception { - SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager( - ValueProviderRegistry.getDefault(), null); - IJavaProject classpathFileProject = projects.javaProjectWithClasspathFile(CUSTOM_PROPERTIES_PROJECT); - FuzzyMap index = indexManager.get(classpathFileProject, progressService); - PropertyInfo propertyInfo = index.get("server.port"); - assertNotNull(propertyInfo); - assertEquals(Integer.class.getName(), propertyInfo.getType()); - assertEquals("port", propertyInfo.getName()); - } - - @Test @Ignore //ignore because classpath file is going to disapear and pieces already removed - public void customPropertyPresent_ClasspathFile() throws Exception { - SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager( - ValueProviderRegistry.getDefault(), null); - IJavaProject classpathFileProject = projects.javaProjectWithClasspathFile(CUSTOM_PROPERTIES_PROJECT); - FuzzyMap index = indexManager.get(classpathFileProject, progressService); - PropertyInfo propertyInfo = index.get("demo.settings.user"); - assertNotNull(propertyInfo); - assertEquals(String.class.getName(), propertyInfo.getType()); - assertEquals("user", propertyInfo.getName()); - } - - @Test @Ignore //ignore because classpath file is going to disapear and pieces already removed - public void propertyNotPresent_ClasspathFile() throws Exception { - SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager( - ValueProviderRegistry.getDefault(), null); - IJavaProject classpathFileProject = projects.javaProjectWithClasspathFile(CUSTOM_PROPERTIES_PROJECT); - FuzzyMap index = indexManager.get(classpathFileProject, progressService); - PropertyInfo propertyInfo = index.get("my.server.port"); - assertNull(propertyInfo); - } } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/ProjectsHarness.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/ProjectsHarness.java index 3aebfd170..399cfc9c1 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/ProjectsHarness.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/ProjectsHarness.java @@ -23,7 +23,6 @@ import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.maven.MavenBuilder; import org.springframework.ide.vscode.commons.maven.MavenCore; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; -import org.springframework.ide.vscode.commons.maven.java.classpathfile.JavaProjectWithClasspathFile; import org.springframework.ide.vscode.commons.util.IOUtil; import com.google.common.cache.Cache; @@ -79,8 +78,8 @@ public class ProjectsHarness { } private enum ProjectType { - MAVEN, - CLASSPATH_TXT + MAVEN + // GRADLE? } private ProjectsHarness() { @@ -102,9 +101,6 @@ public class ProjectsHarness { case MAVEN: MavenBuilder.newBuilder(testProjectPath).clean().pack().javadoc().skipTests().execute(); return new MavenJavaProject(MavenCore.getDefault(), testProjectPath.resolve(MavenCore.POM_XML).toFile()); - case CLASSPATH_TXT: - MavenBuilder.newBuilder(testProjectPath).clean().pack().skipTests().execute(); - return new JavaProjectWithClasspathFile(testProjectPath.resolve(MavenCore.CLASSPATH_TXT).toFile()); default: throw new IllegalStateException("Bug!!! Missing case"); } @@ -133,9 +129,4 @@ public class ProjectsHarness { public MavenJavaProject mavenProject(String name) throws Exception { return (MavenJavaProject) project(ProjectType.MAVEN, name); } - - public IJavaProject javaProjectWithClasspathFile(String name) throws Exception { - return project(ProjectType.CLASSPATH_TXT, name); - } - }