code cleanup
This commit is contained in:
@@ -254,60 +254,36 @@ public class BootJavaLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
providers.put(org.springframework.ide.vscode.boot.java.value.Constants.SPRING_VALUE, new ValueHoverProvider());
|
||||
|
||||
providers.put(Annotations.SPRING_REQUEST_MAPPING,
|
||||
new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_GET_MAPPING,
|
||||
new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_POST_MAPPING,
|
||||
new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_PUT_MAPPING,
|
||||
new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_DELETE_MAPPING,
|
||||
new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_PATCH_MAPPING,
|
||||
new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_REQUEST_MAPPING, new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_GET_MAPPING, new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_POST_MAPPING, new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_PUT_MAPPING, new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_DELETE_MAPPING, new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.SPRING_PATCH_MAPPING, new RequestMappingHoverProvider());
|
||||
providers.put(Annotations.PROFILE, new ActiveProfilesProvider());
|
||||
|
||||
providers.put(Annotations.AUTOWIRED, new AutowiredHoverProvider());
|
||||
providers.put(Annotations.COMPONENT, new ComponentInjectionsHoverProvider());
|
||||
providers.put(Annotations.BEAN, new BeanInjectedIntoHoverProvider());
|
||||
|
||||
providers.put(Annotations.CONDITIONAL,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_BEAN,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_MISSING_BEAN,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_PROPERTY,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_RESOURCE,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_CLASS,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_MISSING_CLASS,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_CLOUD_PLATFORM,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_WEB_APPLICATION,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_NOT_WEB_APPLICATION,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_INFO_CONTRIBUTOR,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_RESOURCE_CHAIN,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_ENDPOINT,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_HEALTH_INDICATOR,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_EXPRESSION,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_JAVA,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_JNDI,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_SINGLE_CANDIDATE,
|
||||
new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_BEAN, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_MISSING_BEAN, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_PROPERTY, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_RESOURCE, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_CLASS, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_MISSING_CLASS, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_CLOUD_PLATFORM, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_WEB_APPLICATION, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_NOT_WEB_APPLICATION, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_INFO_CONTRIBUTOR, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_RESOURCE_CHAIN, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_ENDPOINT, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_ENABLED_HEALTH_INDICATOR, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_EXPRESSION, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_JAVA, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_JNDI, new ConditionalsLiveHoverProvider());
|
||||
providers.put(Annotations.CONDITIONAL_ON_SINGLE_CANDIDATE, new ConditionalsLiveHoverProvider());
|
||||
|
||||
return new BootJavaHoverProvider(this, javaProjectFinder, providers, runningAppProvider);
|
||||
}
|
||||
@@ -315,16 +291,11 @@ public class BootJavaLanguageServer extends SimpleLanguageServer {
|
||||
protected SpringIndexer createAnnotationIndexer(SimpleLanguageServer server, JavaProjectFinder projectFinder) {
|
||||
AnnotationHierarchyAwareLookup<SymbolProvider> providers = new AnnotationHierarchyAwareLookup<>();
|
||||
providers.put(Annotations.SPRING_REQUEST_MAPPING, new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_GET_MAPPING,
|
||||
new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_POST_MAPPING,
|
||||
new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_PUT_MAPPING,
|
||||
new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_DELETE_MAPPING,
|
||||
new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_PATCH_MAPPING,
|
||||
new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_GET_MAPPING, new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_POST_MAPPING, new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_PUT_MAPPING, new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_DELETE_MAPPING, new RequestMappingSymbolProvider());
|
||||
providers.put(Annotations.SPRING_PATCH_MAPPING, new RequestMappingSymbolProvider());
|
||||
|
||||
providers.put(Annotations.BEAN, new BeansSymbolProvider());
|
||||
providers.put(Annotations.COMPONENT, new ComponentSymbolProvider());
|
||||
|
||||
@@ -11,22 +11,15 @@
|
||||
package org.springframework.ide.vscode.boot.java.annotations;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.jdt.core.dom.Annotation;
|
||||
import org.eclipse.jdt.core.dom.IAnnotationBinding;
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.gradle.internal.io.SkipFirstTextStream;
|
||||
import org.springframework.ide.vscode.commons.util.CollectorUtil;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
|
||||
@@ -18,18 +18,12 @@ import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.RequestMappingSymbolProvider;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import reactor.util.function.Tuple2;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
/**
|
||||
* A Map-like utilyt that allows putting and getting values associated with
|
||||
* A Map-like utilty that allows putting and getting values associated with
|
||||
* annotation types.
|
||||
* <p>
|
||||
* The lookup is 'hierarchy aware' which means that is able to associate values
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BootJavaCompletionEngine implements ICompletionEngine {
|
||||
|
||||
@Override
|
||||
public Collection<ICompletionProposal> getCompletions(IDocument document, int offset) throws Exception {
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS8);
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS9);
|
||||
Map<String, String> options = JavaCore.getOptions();
|
||||
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
|
||||
parser.setCompilerOptions(options);
|
||||
|
||||
@@ -10,18 +10,14 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.jdt.core.dom.ASTNode;
|
||||
import org.eclipse.jdt.core.dom.ASTVisitor;
|
||||
import org.eclipse.jdt.core.dom.Annotation;
|
||||
import org.eclipse.jdt.core.dom.CompilationUnit;
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.eclipse.jdt.core.dom.MarkerAnnotation;
|
||||
import org.eclipse.jdt.core.dom.NodeFinder;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class BootJavaReferencesHandler implements ReferencesHandler {
|
||||
}
|
||||
|
||||
private CompletableFuture<List<? extends Location>> provideReferences(TextDocument document, int offset) throws Exception {
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS8);
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS9);
|
||||
Map<String, String> options = JavaCore.getOptions();
|
||||
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
|
||||
parser.setCompilerOptions(options);
|
||||
|
||||
@@ -126,7 +126,7 @@ public final class CompilationUnitCache {
|
||||
}
|
||||
|
||||
public static CompilationUnit parse(TextDocument document, IJavaProject project) throws Exception {
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS8);
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS9);
|
||||
Map<String, String> options = JavaCore.getOptions();
|
||||
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
|
||||
parser.setCompilerOptions(options);
|
||||
|
||||
@@ -273,7 +273,7 @@ public class SpringIndexer {
|
||||
|
||||
private void scanProject(IJavaProject project, String[] files) {
|
||||
try {
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS8);
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS9);
|
||||
String[] classpathEntries = getClasspathEntries(project);
|
||||
|
||||
scanFiles(parser, files, classpathEntries);
|
||||
@@ -284,7 +284,7 @@ public class SpringIndexer {
|
||||
}
|
||||
|
||||
private void scanFile(String docURI, String content, String[] classpathEntries) throws Exception {
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS8);
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS9);
|
||||
Map<String, String> options = JavaCore.getOptions();
|
||||
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
|
||||
parser.setCompilerOptions(options);
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
package org.springframework.ide.vscode.boot.java.beans.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
@@ -112,9 +109,6 @@ public class SpringIndexerBeansTest {
|
||||
indexer.assertDocumentSymbols(uriPrefix + "/src/main/java/org/test/SimpleComponent.java",
|
||||
symbol("@Component", "@+ 'simpleComponent' (@Component) SimpleComponent")
|
||||
);
|
||||
// List<? extends SymbolInformation> symbols = indexer.getSymbols(uriPrefix + "/src/main/java/org/test/SimpleComponent.java");
|
||||
// assertEquals(1, symbols.size());
|
||||
// assertTrue(containsSymbol(symbols, "@+ 'simpleComponent' (@Component) SimpleComponent", uriPrefix + "/src/main/java/org/test/SimpleComponent.java", 4, 0, 4, 10));
|
||||
}
|
||||
|
||||
@Test public void testScanSimpleControllerClass() throws Exception {
|
||||
@@ -145,23 +139,6 @@ public class SpringIndexerBeansTest {
|
||||
////////////////////////////////
|
||||
// harness code
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private TestSymbolInfo symbol(String coveredText, String label) {
|
||||
return new TestSymbolInfo(coveredText, label);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ package org.springframework.ide.vscode.boot.java.references.test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package org.springframework.ide.vscode.boot.java.scope.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
Reference in New Issue
Block a user