Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sourcegraph.semanticdb_javac;

public class CompilationUnitException extends Throwable {
public CompilationUnitException(String compilationUnit, Throwable cause) {
super(compilationUnit, cause);
}

@Override
public Throwable fillInStackTrace() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ public void finished(TaskEvent e) {
if (e.getKind() != TaskEvent.Kind.ANALYZE) return;
try {
onFinishedAnalyze(e);
} catch (Exception ex) {
} catch (Throwable ex) {
// Catch exceptions because we don't want to stop the compilation even if this plugin has a
// bug. We report the full stack trace because it's helpful for bug reports. Exceptions
// should only happen in *exceptional* situations and they should be reported upstream.
reporter.exception(ex);
Throwable throwable = ex;
if (e.getSourceFile() != null) {
throwable =
new CompilationUnitException(
String.valueOf(e.getSourceFile().toUri().toString()), throwable);
}
reporter.exception(throwable);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ public Void visitClass(ClassTree node, Void unused) {
List<JCTree.JCTypeParameter> typeParameters = cls.getTypeParameters();
int i = 0;
for (Symbol.TypeVariableSymbol typeSym : cls.sym.getTypeParameters()) {
if (i >= typeParameters.size()) {
// Happens in testcontainers/testcontainers-java, see
// https://github.com/sourcegraph/lsif-java/issues/319
// Failed to reproduce with a minimal source file so we don't have a test case that hits
// this branch.
break;
}
emitSymbolOccurrence(
typeSym,
typeParameters.get(i),
Expand Down