Skip to content

Commit

Permalink
Never detect words in foo.bar constructs as keywords
Browse files Browse the repository at this point in the history
Refs #812
  • Loading branch information
nene committed Dec 21, 2024
1 parent badf398 commit 2c54120
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lexer/disambiguateTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const propertyNameKeywordToIdent = (token: Token, i: number, tokens: Token[]): T
if (prevToken && prevToken.type === TokenType.PROPERTY_ACCESS_OPERATOR) {
return { ...token, type: TokenType.IDENTIFIER, text: token.raw };
}
const nextToken = nextNonCommentToken(tokens, i);
if (nextToken && nextToken.type === TokenType.PROPERTY_ACCESS_OPERATOR) {
return { ...token, type: TokenType.IDENTIFIER, text: token.raw };
}
}
return token;
};
Expand Down
12 changes: 12 additions & 0 deletions test/options/keywordCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ export default function supportsKeywordCase(format: FormatFn) {
`);
});

it('treats dot-seperated keywords as plain identifiers', () => {
const result = format('select table.and from set.select', {
keywordCase: 'upper',
});
expect(result).toBe(dedent`
SELECT
table.and
FROM
set.select
`);
});

// regression test for #356
it('formats multi-word reserved clauses into single line', () => {
const result = format(
Expand Down

0 comments on commit 2c54120

Please sign in to comment.