Search in sources :

Example 11 with DocumentInformation

use of com.nedap.openehr.lsp.document.DocumentInformation in project archetype-languageserver by nedap.

the class ADL14SymbolExtractor method extractSymbols.

public DocumentInformation extractSymbols(String uri, String text) throws IOException {
    Adl14Lexer lexer = new Adl14Lexer(CharStreams.fromString(text));
    Adl14Parser parser = new Adl14Parser(new CommonTokenStream(lexer));
    ArchieErrorListener listener = new ArchieErrorListener();
    parser.addErrorListener(listener);
    ADL14SymbolInformationExtractingListener symbolExtractingListener = new ADL14SymbolInformationExtractingListener(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_1_4, listener.getErrors(), symbolExtractingListener.getSymbols(), symbolExtractingListener.getFoldingRanges(), symbolExtractingListener.getDocumentLinks());
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) ArchieErrorListener(com.nedap.archie.antlr.errors.ArchieErrorListener) Adl14Parser(com.nedap.archie.adlparser.antlr.Adl14Parser) DocumentInformation(com.nedap.openehr.lsp.document.DocumentInformation) Adl14Lexer(com.nedap.archie.adlparser.antlr.Adl14Lexer) ParseTreeWalker(org.antlr.v4.runtime.tree.ParseTreeWalker) IOException(java.io.IOException)

Aggregations

DocumentInformation (com.nedap.openehr.lsp.document.DocumentInformation)11 JsonPrimitive (com.google.gson.JsonPrimitive)4 Archetype (com.nedap.archie.aom.Archetype)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Lists (com.google.common.collect.Lists)2 ArchieErrorListener (com.nedap.archie.antlr.errors.ArchieErrorListener)2 OperationalTemplate (com.nedap.archie.aom.OperationalTemplate)2 ValidationResult (com.nedap.archie.archetypevalidator.ValidationResult)2 Flattener (com.nedap.archie.flattener.Flattener)2 BroadcastingArchetypeRepository (com.nedap.openehr.lsp.repository.BroadcastingArchetypeRepository)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 ParseTreeWalker (org.antlr.v4.runtime.tree.ParseTreeWalker)2 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ADLParseException (com.nedap.archie.adlparser.ADLParseException)1