now feeding parser with source path from classpath data
This commit is contained in:
@@ -30,9 +30,6 @@ import org.eclipse.jdt.core.dom.Type;
|
||||
import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.AbstractSymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
@@ -40,7 +37,6 @@ import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.SCAN_PASS;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
/**
|
||||
@@ -48,8 +44,6 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
*/
|
||||
public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WebfluxRouterSymbolProvider.class);
|
||||
|
||||
@Override
|
||||
public void addSymbols(MethodDeclaration methodDeclaration, SpringIndexerJavaContext context, TextDocument doc) {
|
||||
Type returnType = methodDeclaration.getReturnType2();
|
||||
@@ -57,10 +51,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
|
||||
ITypeBinding resolvedBinding = returnType.resolveBinding();
|
||||
|
||||
if (resolvedBinding == null) {
|
||||
log.info("type binding of method declatation return type IS NULL: " + methodDeclaration.toString());
|
||||
}
|
||||
|
||||
if (resolvedBinding != null && WebfluxUtils.ROUTER_FUNCTION_TYPE.equals(resolvedBinding.getBinaryName())) {
|
||||
|
||||
Block methodBody = methodDeclaration.getBody();
|
||||
@@ -82,10 +72,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
public boolean visit(MethodInvocation node) {
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method invocation IS NULL: " + node.toString());
|
||||
}
|
||||
|
||||
if (methodBinding != null && WebfluxUtils.isRouteMethodInvocation(methodBinding)) {
|
||||
extractMappingSymbol(node, doc, context);
|
||||
}
|
||||
@@ -158,10 +144,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
extractNestedValue(routerInvocation, path, (methodInvocation) -> {
|
||||
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method invocation IS NULL: " + methodInvocation.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
if (methodBinding != null && WebfluxUtils.REQUEST_PREDICATE_PATH_METHOD.equals(methodBinding.getName())) {
|
||||
StringLiteral stringLiteral = WebfluxUtils.extractStringLiteralArgument(methodInvocation);
|
||||
@@ -194,10 +176,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
extractNestedValue(routerInvocation, methods, (methodInvocation) -> {
|
||||
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method invocation IS NULL: " + methodInvocation.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
if (methodBinding != null && WebfluxUtils.REQUEST_PREDICATE_METHOD_METHOD.equals(methodBinding.getName())) {
|
||||
QualifiedName qualifiedName = WebfluxUtils.extractQualifiedNameArgument(methodInvocation);
|
||||
@@ -231,10 +209,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
extractNestedValue(routerInvocation, acceptTypes, (methodInvocation) -> {
|
||||
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method invocation IS NULL: " + methodInvocation.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
if (methodBinding != null && WebfluxUtils.REQUEST_PREDICATE_ACCEPT_TYPE_METHOD.equals(methodBinding.getName())) {
|
||||
SimpleName nameArgument = WebfluxUtils.extractSimpleNameArgument(methodInvocation);
|
||||
@@ -268,10 +242,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
extractNestedValue(routerInvocation, contentTypes, (methodInvocation) -> {
|
||||
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method invocation IS NULL: " + methodInvocation.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
if (methodBinding != null && WebfluxUtils.REQUEST_PREDICATE_CONTENT_TYPE_METHOD.equals(methodBinding.getName())) {
|
||||
SimpleName nameArgument = WebfluxUtils.extractSimpleNameArgument(methodInvocation);
|
||||
@@ -300,10 +270,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
MethodInvocation methodInvocation = (MethodInvocation) node;
|
||||
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method invocation IS NULL: " + methodInvocation.toString());
|
||||
}
|
||||
|
||||
if (methodBinding != null && methodBinding.getDeclaringClass() != null
|
||||
&& WebfluxUtils.ROUTER_FUNCTIONS_TYPE.equals(methodBinding.getDeclaringClass().getBinaryName())) {
|
||||
|
||||
@@ -337,10 +303,6 @@ public class WebfluxRouterSymbolProvider extends AbstractSymbolProvider {
|
||||
ExpressionMethodReference methodReference = (ExpressionMethodReference) argument;
|
||||
IMethodBinding methodBinding = methodReference.resolveMethodBinding();
|
||||
|
||||
if (methodBinding == null) {
|
||||
log.info("method binding of method reference IS NULL: " + methodReference.toString());
|
||||
}
|
||||
|
||||
if (methodBinding != null && methodBinding.getDeclaringClass() != null && methodBinding.getMethodDeclaration() != null) {
|
||||
String handlerClass = methodBinding.getDeclaringClass().getBinaryName();
|
||||
if (handlerClass != null) handlerClass = handlerClass.trim();
|
||||
|
||||
@@ -317,12 +317,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
|
||||
private ASTParser createParser(IJavaProject project, boolean ignoreMethodBodies) throws Exception {
|
||||
String[] classpathEntries = getClasspathEntries(project);
|
||||
|
||||
log.info("CLASSPATH ENTRIES for project: " + project.getElementName() + " ... ignore method bodies: " + ignoreMethodBodies);
|
||||
for (String entry : classpathEntries) {
|
||||
log.info("CLASSPATH ENTRY: " + entry);
|
||||
}
|
||||
log.info("CLASSPATH ENTRIES for project: " + project.getElementName() + " ...DONE !!!");
|
||||
String[] sourceEntries = getSourceEntries(project);
|
||||
|
||||
ASTParser parser = ASTParser.newParser(AST.JLS11);
|
||||
Map<String, String> options = JavaCore.getOptions();
|
||||
@@ -334,7 +329,6 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
parser.setResolveBindings(true);
|
||||
parser.setIgnoreMethodBodies(ignoreMethodBodies);
|
||||
|
||||
String[] sourceEntries = new String[] {};
|
||||
parser.setEnvironment(classpathEntries, sourceEntries, null, false);
|
||||
return parser;
|
||||
}
|
||||
@@ -348,6 +342,15 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
private String[] getSourceEntries(IJavaProject project) throws Exception {
|
||||
IClasspath classpath = project.getClasspath();
|
||||
Stream<File> sourceEntries = IClasspathUtil.getSourceFolders(classpath);
|
||||
return sourceEntries
|
||||
.filter(file -> file.exists())
|
||||
.map(file -> file.getAbsolutePath())
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
private String[] getFiles(IJavaProject project) throws Exception {
|
||||
return Files.walk(Paths.get(project.getLocationUri()))
|
||||
.filter(path -> path.getFileName().toString().endsWith(".java"))
|
||||
|
||||
@@ -13,11 +13,8 @@ package org.springframework.ide.vscode.boot.bootiful;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
|
||||
Reference in New Issue
Block a user