Skip to content

loadAstNode #1747

Answered by cdietrich
cdietrich asked this question in Q&A
Nov 11, 2024 · 1 comments · 7 replies
Discussion options

You must be logged in to vote

ok

export class SampleLinker extends DefaultLinker {
    protected override loadAstNode(nodeDescription: AstNodeDescription): AstNode | undefined {
        if (nodeDescription.node) {
            return nodeDescription.node;
        }
        let doc = this.langiumDocuments().getDocument(nodeDescription.documentUri);
        if (!doc) {
            const content = fs.readFileSync(nodeDescription.documentUri.fsPath, 'utf-8')
            doc = this.langiumDocuments().createDocument(nodeDescription.documentUri, content);
            if (!doc) {
                return undefined;
            }
           
        }
        return this.astNodeLocator.getAstNode(doc.parseResult.value, nodeDescri…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@cdietrich
Comment options

cdietrich Nov 11, 2024
Collaborator Author

@cdietrich
Comment options

cdietrich Nov 11, 2024
Collaborator Author

@msujew
Comment options

@cdietrich
Comment options

cdietrich Nov 11, 2024
Collaborator Author

Answer selected by cdietrich
@msujew
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants