langium icon indicating copy to clipboard operation
langium copied to clipboard

AST Node has no document

Open grafandreas opened this issue 1 year ago • 5 comments

When working on a new grammar / language, I see the issue that in Linking and other situations, Langium fails with

Error: AST node has no document. at getDocument (c:\Users\agraf.vscode\extensions\undefined_publisher.XXXXX-0.0.1\out\language\main.cjs:10601:11)

Since in @cdietrich 's report on the formatter he mentions "the" AST node has no document bug, I assume it is already known. Is there further information on that bug?

Regards,

Andreas

grafandreas avatar Oct 15 '24 10:10 grafandreas

Hey @grafandreas,

can you post a reproduction example? I've seen some complaints about it, but failed to reproduce the issue as of now.

msujew avatar Oct 15 '24 10:10 msujew

image i have encounter similar issue by override getDocumentHighlight method in DefaultDocumentHighlightProvider

zrwsmd avatar Oct 16 '24 02:10 zrwsmd

@zrwsmd Can you reproduce this consistently? Can you share a reproducible example?

msujew avatar Oct 23 '24 11:10 msujew

Probably this is not the reason but I ran into this error when accidentally using ?= to assign a value to a property of type boolean combined with a rule.

In this example (which might not be very reasonable) :

entry Model:
    persons+=Person*;

Person:
    'person' name=ID isXYZ?=PersonPredicate;

PersonPredicate:
    'knows' other=[Person:ID];

Using this input:

person Foo knows Bar
person Bar knows Foo

The error AST node has no document. occurs (related to the cross references after knows). This might be just because of an incorrect definition but maybe this can serve as a litte hint.

MarianPalkus avatar Oct 29 '24 13:10 MarianPalkus

A Boolean assignment with a non-primitive right-hand-side should actually be forbidden. We need a grammar validation check for that.

spoenemann avatar Nov 06 '24 08:11 spoenemann