Skip to content

Commit

Permalink
Fix comment extraction for variable assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasgeiter committed Jul 15, 2023
1 parent 4563ac0 commit 32b7b1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/js/extractors/comments.ts
Expand Up @@ -72,6 +72,7 @@ export abstract class JsCommentUtils {
case ts.SyntaxKind.ThrowStatement:
case ts.SyntaxKind.ExpressionStatement:
case ts.SyntaxKind.ParenthesizedExpression:
case ts.SyntaxKind.BinaryExpression:
return this.getExtractionPositions(node.parent, sourceFile);

case ts.SyntaxKind.VariableDeclaration:
Expand Down
12 changes: 11 additions & 1 deletion tests/js/extractors/comments.test.ts
Expand Up @@ -214,7 +214,7 @@ describe('JS: comments', () => {
});
});

describe('variable assignment', () => {
describe('variable declaration', () => {

test('single variable', () => {
check(`
Expand Down Expand Up @@ -353,6 +353,16 @@ describe('JS: comments', () => {
});
});

test('variable assignment', () => {
check(`
// Relevant leading line comment
foo = getText('Foo'); // Relevant trailing line comment
`, {
otherLineLeading: ['Relevant leading line comment'],
sameLineTrailing: ['Relevant trailing line comment']
});
});

describe('object literal', () => {

describe('single line', () => {
Expand Down

0 comments on commit 32b7b1f

Please sign in to comment.