use of com.nedap.archie.adlparser.antlr.AdlParser in project archetype-languageserver by nedap.
the class ADL2SymbolExtractor method extractSymbols.
public DocumentInformation extractSymbols(String uri, String text) throws IOException {
AdlLexer lexer = new AdlLexer(CharStreams.fromString(text));
AdlParser parser = new AdlParser(new CommonTokenStream(lexer));
ArchieErrorListener listener = new ArchieErrorListener();
parser.addErrorListener(listener);
SymbolInformationExtractingListener symbolExtractingListener = new SymbolInformationExtractingListener(uri, lexer);
// DocumentSymbolExtractingListener symbolExtractingListener = new DocumentSymbolExtractingListener();
try {
new ParseTreeWalker().walk(symbolExtractingListener, parser.adl());
} catch (Exception e) {
// this is fine. for now
e.printStackTrace();
}
archetypeId = symbolExtractingListener.getArchetypeId();
return new DocumentInformation(archetypeId, ADLVersion.VERSION_2, listener.getErrors(), symbolExtractingListener.getSymbols(), symbolExtractingListener.getFoldingRanges(), symbolExtractingListener.getDocumentLinks(), symbolExtractingListener.getCTerminologyCodes());
}
Aggregations