Skip to content

Commit 7ebc405

Browse files
committed
JS: Support YAML comments.
1 parent 234a051 commit 7ebc405

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

javascript/ql/lib/semmle/javascript/Comments.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module;
55
import javascript
66

77
/**
8-
* A JavaScript source-code comment.
8+
* A JavaScript or YAML source-code comment.
99
*
1010
* Examples:
1111
*
@@ -14,6 +14,7 @@ import javascript
1414
* /* a block
1515
* comment *&#47
1616
* <!-- an HTML line comment
17+
* # a YAML line comment
1718
* </pre>
1819
*/
1920
class Comment extends @comment, Locatable {
@@ -44,13 +45,14 @@ class Comment extends @comment, Locatable {
4445
}
4546

4647
/**
47-
* A line comment, that is, either an HTML comment or a `//` comment.
48+
* A line comment, that is, an HTML comment, a `//` comment, or a YAML comment.
4849
*
4950
* Examples:
5051
*
5152
* <pre>
5253
* // a line comment
5354
* &lt;!-- an HTML line comment
55+
* # a YAML line comment
5456
* </pre>
5557
*/
5658
class LineComment extends @line_comment, Comment { }

javascript/ql/lib/semmle/javascript/YAML.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ private module YamlSig implements LibYaml::InputSig {
4444
class ParseErrorBase extends LocatableBase, @yaml_error {
4545
string getMessage() { yaml_errors(this, result) }
4646
}
47+
48+
class CommentBase extends LocatableBase, @yaml_comment {
49+
string getText() { yaml_comments(this, result, _) }
50+
51+
override string toString() { yaml_comments(this, _, result) }
52+
}
4753
}
4854

4955
import LibYaml::Make<YamlSig>

javascript/ql/lib/semmlecode.javascript.dbscheme

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,13 +1090,17 @@ yaml_scalars (unique int scalar: @yaml_scalar_node ref,
10901090
int style: int ref,
10911091
string value: string ref);
10921092

1093+
yaml_comments (unique int id: @yaml_comment,
1094+
string text: string ref,
1095+
string tostring: string ref);
1096+
10931097
yaml_errors (unique int id: @yaml_error,
10941098
string message: string ref);
10951099

10961100
yaml_locations(unique int locatable: @yaml_locatable ref,
10971101
int location: @location_default ref);
10981102

1099-
@yaml_locatable = @yaml_node | @yaml_error;
1103+
@yaml_locatable = @yaml_node | @yaml_error | @yaml_comment;
11001104

11011105
/*- XML Files -*/
11021106

0 commit comments

Comments
 (0)