Skip to content

Commit 8049dec

Browse files
committed
QL: Add support for YAML comments.
1 parent 494364f commit 8049dec

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,12 @@ module YAML {
27372737
class ParseErrorBase extends LocatableBase, @yaml_error {
27382738
string getMessage() { yaml_errors(this, result) }
27392739
}
2740+
2741+
class CommentBase extends LocatableBase, @yaml_comment {
2742+
string getText() { yaml_comments(this, result, _) }
2743+
2744+
override string toString() { yaml_comments(this, _, result) }
2745+
}
27402746
}
27412747

27422748
import LibYaml::Make<YamlSig>

ql/ql/src/codeql_ql/ast/Yaml.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ private module YamlSig implements LibYaml::InputSig {
4646
class ParseErrorBase extends LocatableBase, @yaml_error {
4747
string getMessage() { yaml_errors(this, result) }
4848
}
49+
50+
class CommentBase extends LocatableBase, @yaml_comment {
51+
string getText() { yaml_comments(this, result, _) }
52+
53+
override string toString() { yaml_comments(this, _, result) }
54+
}
4955
}
5056

5157
import LibYaml::Make<YamlSig>

ql/ql/src/ql.dbscheme

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,17 @@ yaml_scalars (unique int scalar: @yaml_scalar_node ref,
101101
int style: int ref,
102102
string value: string ref);
103103

104+
yaml_comments (unique int id: @yaml_comment,
105+
string text: string ref,
106+
string tostring: string ref);
107+
104108
yaml_errors (unique int id: @yaml_error,
105109
string message: string ref);
106110

107111
yaml_locations(unique int locatable: @yaml_locatable ref,
108112
int location: @location_default ref);
109113

110-
@yaml_locatable = @yaml_node | @yaml_error;
114+
@yaml_locatable = @yaml_node | @yaml_error | @yaml_comment;
111115

112116
/*- Database metadata -*/
113117

0 commit comments

Comments
 (0)