Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/java-snippet-checker/check-java-snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ for (const dir of baseDirs) {
const variations = [
{ content: snippet.content, error: null },
{ content: snippetAsMethod(snippet.content), error: null },
{ content: snippetAsExpression(snippet.content), error: null },
{ content: snippetAsCode(snippet.content), error: null },
];

Expand Down Expand Up @@ -206,6 +207,17 @@ ${ indentLines(content.trim(), 4) }
`;
}

/**
* @param {string} content
*/
function snippetAsExpression(content) {
Copy link
Copy Markdown
Contributor

@smahati smahati May 5, 2026

Choose a reason for hiding this comment

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

@agoerler I added a expression option based on the other variations, the idea is to allow expressions to get checked and it still catches issues in cases like an assignment with a missing semicolon so I hope this is ok but if you think this'll cause issues we can revert it and use a ignore comment instead.

return `// Snippet Checker
Object o =
${ indentLines(content.trim(), 4) }
;
`;
}

/**
* @param {string[]} files
*/
Expand Down
Loading
Loading