Shared: Support YAML comments.

This commit is contained in:
Mathias Vorreiter Pedersen
2026-06-04 12:44:07 +01:00
parent cd2398aeea
commit e87f7fb3f7

View File

@@ -134,6 +134,23 @@ signature module InputSig {
*/
string getMessage();
}
/**
* A base class for comments.
*
* Typically `@yaml_comment`.
*/
class CommentBase extends LocatableBase {
/**
* Gets the text of this comment, not including delimiters.
*/
string getText();
/**
* Gets a textual representation of this comment.
*/
string toString();
}
}
/** Provides a class hierarchy for working with YAML files. */
@@ -607,6 +624,26 @@ module Make<InputSig Input> {
string toString() { result = super.getMessage() }
}
/**
* A YAML comment.
*
* Example:
*
* ```
* # here is a comment
* ```
*/
class YamlComment instanceof Input::CommentBase {
/** Gets the `Location` of this comment. */
Input::Location getLocation() { result = super.getLocation() }
/** Gets the text of this comment, not including delimiters. */
string getText() { result = super.getText() }
/** Gets a textual representation of this comment. */
string toString() { result = super.toString() }
}
/**
* A YAML node that may contain sub-nodes that can be identified by a name.
* I.e. a mapping, sequence, or scalar.