eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
750 stars 68 forks source link

AST Node has no document #1717

Open grafandreas opened 1 month ago

grafandreas commented 1 month ago

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

msujew commented 1 month ago

Hey @grafandreas,

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

zrwsmd commented 1 month ago

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

msujew commented 1 month ago

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

MarianPalkus commented 4 weeks ago

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.

spoenemann commented 2 weeks ago

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