Skip to content

Commit 234a051

Browse files
committed
Shared: Support YAML comments.
1 parent cb8cf8a commit 234a051

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

shared/yaml/codeql/yaml/Yaml.qll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,23 @@ signature module InputSig {
134134
*/
135135
string getMessage();
136136
}
137+
138+
/**
139+
* A base class for comments.
140+
*
141+
* Typically `@yaml_comment`.
142+
*/
143+
class CommentBase extends LocatableBase {
144+
/**
145+
* Gets the text of this comment, not including delimiters.
146+
*/
147+
string getText();
148+
149+
/**
150+
* Gets a textual representation of this comment.
151+
*/
152+
string toString();
153+
}
137154
}
138155

139156
/** Provides a class hierarchy for working with YAML files. */
@@ -607,6 +624,26 @@ module Make<InputSig Input> {
607624
string toString() { result = super.getMessage() }
608625
}
609626

627+
/**
628+
* A YAML comment.
629+
*
630+
* Example:
631+
*
632+
* ```
633+
* # here is a comment
634+
* ```
635+
*/
636+
class YamlComment instanceof Input::CommentBase {
637+
/** Gets the `Location` of this comment. */
638+
Input::Location getLocation() { result = super.getLocation() }
639+
640+
/** Gets the text of this comment, not including delimiters. */
641+
string getText() { result = super.getText() }
642+
643+
/** Gets a textual representation of this comment. */
644+
string toString() { result = super.toString() }
645+
}
646+
610647
/**
611648
* A YAML node that may contain sub-nodes that can be identified by a name.
612649
* I.e. a mapping, sequence, or scalar.

0 commit comments

Comments
 (0)