(node: AstNode)
| 702 | * @throws an error if the node is not contained in a document. |
| 703 | */ |
| 704 | export function getDocument<T extends AstNode = AstNode>(node: AstNode): LangiumDocument<T> { |
| 705 | const rootNode = findRootNode(node); |
| 706 | const result = rootNode.$document; |
| 707 | if (!result) { |
| 708 | throw new Error('AST node has no document.'); |
| 709 | } |
| 710 | return result as LangiumDocument<T>; |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * Gets the list of plugin documents from the given model. |
no test coverage detected