Skip to content

IaC Comment Class - #388

Open
Chanel (chanel-y) wants to merge 3 commits into
mainfrom
chanely/iac-comment-class-v2
Open

IaC Comment Class#388
Chanel (chanel-y) wants to merge 3 commits into
mainfrom
chanely/iac-comment-class-v2

Conversation

@chanel-y

@chanel-y Chanel (chanel-y) commented Aug 5, 2026

Copy link
Copy Markdown

No description provided.

Chanel (chanel-y) and others added 3 commits August 5, 2026 14:52
The generated AST printer now references the Tree-sitter Comment node, and the expected locations were normalized to LF line endings to match the generated output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chanel-y Chanel (chanel-y) changed the title Extracting comments from YAML, renaming HCL-only Comment to HCL Comme… IaC Comment Class Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of simplifcations, but otherwise this LGTM!

Comment on lines +25 to +29
exists(YamlDocument document |
document.getFile() = file and
document instanceof YamlMapping and
document
.(YamlMapping)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short(er) and sweet(er)!

Suggested change
exists(YamlDocument document |
document.getFile() = file and
document instanceof YamlMapping and
document
.(YamlMapping)
exists(YamlMapping document |
document.getFile() = file and
document

*/
class Comment extends Location {
Comment() {
exists(string text, string delimiterStyle | getIacCommentText(this, text, delimiterStyle))

@MathiasVP Mathias Vorreiter Pedersen (MathiasVP) Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wish LLMs would start using _ in QL 😅

Suggested change
exists(string text, string delimiterStyle | getIacCommentText(this, text, delimiterStyle))
getIacCommentText(this, _, _)


/** Gets the comment text without its delimiter. */
string getText() {
exists(string delimiterStyle | getIacCommentText(this, result, delimiterStyle))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exists(string delimiterStyle | getIacCommentText(this, result, delimiterStyle))
getIacCommentText(this, result, _)

}

/** Holds if this comment uses `#` as its delimiter. */
predicate hasHashDelimiter() { exists(string text | getIacCommentText(this, text, "hash")) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
predicate hasHashDelimiter() { exists(string text | getIacCommentText(this, text, "hash")) }
predicate hasHashDelimiter() { getIacCommentText(this, _, "hash") }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants