Skip to content

Commit

Permalink
Merge pull request #254 from olafurpg/exception
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Jun 15, 2021
2 parents 9b0474c + 6c48349 commit fd09a0c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import java.nio.file.NoSuchFileException

import moped.cli.Application
import moped.progressbars.InteractiveProgressBar
import moped.reporters.Diagnostic

/**
* Console reporter for index-semanticdb command.
Expand All @@ -25,7 +24,7 @@ class ConsoleLsifSemanticdbReporter(app: Application)
case _: NoSuchFileException =>
app.reporter.error(s"no such file: ${e.getMessage}")
case _ =>
app.reporter.log(Diagnostic.exception(e))
e.printStackTrace(app.err)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sourcegraph.lsif_semanticdb;

public class LsifProcessingException extends Throwable {

public LsifProcessingException(LsifTextDocument doc, Throwable cause) {
super(doc.semanticdbPath.toString(), cause);
}

@Override
public Throwable fillInStackTrace() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,20 @@ private Set<String> exportSymbols(List<Path> files) {

private Stream<Integer> processPath(
Path path, Set<String> isExportedSymbol, PackageTable packages) {
return parseTextDocument(path).map(d -> processDocument(d, isExportedSymbol, packages));
return parseTextDocument(path).flatMap(d -> processDocument(d, isExportedSymbol, packages));
}

private Integer processDocument(
private Stream<Integer> processDocument(
LsifTextDocument doc, Set<String> isExportedSymbol, PackageTable packages) {
try {
return Stream.of(processDocumentUnsafe(doc, isExportedSymbol, packages));
} catch (Exception e) {
options.reporter.error(new LsifProcessingException(doc, e));
return Stream.empty();
}
}

private Integer processDocumentUnsafe(
LsifTextDocument doc, Set<String> isExportedSymbol, PackageTable packages) {
Symtab symtab = new Symtab(doc.semanticdb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.sourcegraph.semanticdb_javac.SemanticdbSymbols.Descriptor;
import com.sourcegraph.semanticdb_javac.SemanticdbSymbols.Descriptor.Kind;
import java.util.Optional;
import javax.swing.text.html.Option;

public class SymbolDescriptor {

Expand All @@ -16,6 +15,9 @@ public SymbolDescriptor(SemanticdbSymbols.Descriptor descriptor, String owner) {
this.owner = owner;
}

public static SymbolDescriptor NONE =
new SymbolDescriptor(Descriptor.NONE, SemanticdbSymbols.NONE);

public static SymbolDescriptor parseFromSymbol(String symbol) {
return new Parser(symbol).entryPoint();
}
Expand Down Expand Up @@ -54,8 +56,12 @@ public Parser(String symbol) {
}

public SymbolDescriptor entryPoint() {
if (SemanticdbSymbols.isLocal(symbol))
if (SemanticdbSymbols.isLocal(symbol)) {
return new SymbolDescriptor(Descriptor.local(symbol), SemanticdbSymbols.NONE);
}
if (SemanticdbSymbols.NONE.equals(symbol)) {
return SymbolDescriptor.NONE;
}
readChar();
SemanticdbSymbols.Descriptor descriptor = parseDescriptor();

Expand Down

0 comments on commit fd09a0c

Please sign in to comment.