improved error logging when something goes wrong while parsing source code for symbols and live hovers
This commit is contained in:
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.core.dom.ASTNode;
|
||||
import org.eclipse.jdt.core.dom.Annotation;
|
||||
import org.eclipse.jdt.core.dom.IExtendedModifier;
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.eclipse.jdt.core.dom.MethodDeclaration;
|
||||
import org.eclipse.jdt.core.dom.Modifier;
|
||||
@@ -52,9 +51,9 @@ public class BeansSymbolProvider implements SymbolProvider {
|
||||
@Override
|
||||
public Collection<EnhancedSymbolInformation> getSymbols(Annotation node, ITypeBinding annotationType, Collection<ITypeBinding> metaAnnotations, TextDocument doc) {
|
||||
if (isMethodAbstract(node)) return null;
|
||||
|
||||
|
||||
ImmutableList.Builder<EnhancedSymbolInformation> symbols = ImmutableList.builder();
|
||||
|
||||
|
||||
boolean isFunction = isFunctionBean(node);
|
||||
String beanType = getBeanType(node);
|
||||
for (Tuple2<String, DocumentRegion> nameAndRegion : getBeanNames(node, doc)) {
|
||||
@@ -155,8 +154,8 @@ public class BeansSymbolProvider implements SymbolProvider {
|
||||
ASTNode parent = node.getParent();
|
||||
if (parent instanceof MethodDeclaration) {
|
||||
MethodDeclaration method = (MethodDeclaration) parent;
|
||||
|
||||
String returnType = null;
|
||||
|
||||
if (method.getReturnType2().isParameterizedType()) {
|
||||
ParameterizedType paramType = (ParameterizedType) method.getReturnType2();
|
||||
Type type = paramType.getType();
|
||||
@@ -172,7 +171,7 @@ public class BeansSymbolProvider implements SymbolProvider {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean isMethodAbstract(Annotation node) {
|
||||
if (node != null && node.getParent() != null && node.getParent() instanceof MethodDeclaration) {
|
||||
MethodDeclaration method = (MethodDeclaration) node.getParent();
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.HoverHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
@@ -104,7 +103,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
extractLiveHintsForType(node, document, runningBootApps, result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("error extracting live hint information for docURI '" + document.getUri() + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
return super.visit(node);
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
try {
|
||||
extractLiveHintsForAnnotation(node, document, runningBootApps, result);
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error extracting live hint information for docURI '" + document.getUri() + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -125,7 +124,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
try {
|
||||
extractLiveHintsForAnnotation(node, document, runningBootApps, result);
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error extracting live hint information for docURI '" + document.getUri() + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -136,7 +135,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
try {
|
||||
extractLiveHintsForAnnotation(node, document, runningBootApps, result);
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error extracting live hint information for docURI '" + document.getUri() + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -147,7 +146,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
try {
|
||||
extractLiveHintsForMethod(node, document, runningBootApps, result);
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error extracting live hint information for docURI '" + document.getUri() + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -157,7 +156,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error extracting live hint information for docURI '" + document.getUri(), e);
|
||||
}
|
||||
return result.toArray(new Range[result.size()]);
|
||||
});
|
||||
@@ -337,7 +336,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error identifying actuator dependency on project '" + project.getElementName() + "'", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -350,7 +349,7 @@ public class BootJavaHoverProvider implements HoverHandler {
|
||||
try {
|
||||
return RunningAppMatcher.getAllMatchingApps(runningAppProvider.getAllRunningSpringApps(), project).toArray(new SpringBootApp[0]);
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
logger.error("error getting all matching projects for project'" + project.getElementName() + "'", e);
|
||||
return new SpringBootApp[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ public class SpringIndexer {
|
||||
extractSymbolInformation(project, node, docURI, docRef, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("error extracting symbol information in project '" + project.getElementName() + "' - for docURI '" + docURI + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
return super.visit(node);
|
||||
}
|
||||
@@ -393,7 +393,7 @@ public class SpringIndexer {
|
||||
extractSymbolInformation(project, node, docURI, docRef, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("error extracting symbol information in project '" + project.getElementName() + "' - for docURI '" + docURI + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
return super.visit(node);
|
||||
}
|
||||
@@ -404,7 +404,7 @@ public class SpringIndexer {
|
||||
extractSymbolInformation(project, node, docURI, docRef, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("error extracting symbol information in project '" + project.getElementName() + "' - for docURI '" + docURI + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -416,7 +416,7 @@ public class SpringIndexer {
|
||||
extractSymbolInformation(project, node, docURI, docRef, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("error extracting symbol information in project '" + project.getElementName() + "' - for docURI '" + docURI + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -428,7 +428,7 @@ public class SpringIndexer {
|
||||
extractSymbolInformation(project, node, docURI, docRef, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("error extracting symbol information in project '" + project.getElementName() + "' - for docURI '" + docURI + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return super.visit(node);
|
||||
@@ -483,7 +483,7 @@ public class SpringIndexer {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SymbolInformation symbol = provideDefaultSymbol(node, docURI, docRef, content);
|
||||
SymbolInformation symbol = provideDefaultSymbol(project, node, docURI, docRef, content);
|
||||
if (symbol != null) {
|
||||
addSymbol(project, docURI, new EnhancedSymbolInformation(symbol, null));
|
||||
}
|
||||
@@ -510,7 +510,7 @@ public class SpringIndexer {
|
||||
return doc;
|
||||
}
|
||||
|
||||
private SymbolInformation provideDefaultSymbol(Annotation node, String docURI, AtomicReference<TextDocument> docRef, String content) {
|
||||
private SymbolInformation provideDefaultSymbol(IJavaProject project, Annotation node, String docURI, AtomicReference<TextDocument> docRef, String content) {
|
||||
try {
|
||||
ITypeBinding type = node.resolveTypeBinding();
|
||||
if (type != null) {
|
||||
@@ -524,7 +524,7 @@ public class SpringIndexer {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("error creating default symbol in project '" + project.getElementName() + "' - for docURI '" + docURI + "' - on node: " + node.toString(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user