Skip to content

Commit 2c54120

Browse files
committed
Never detect words in foo.bar constructs as keywords
Refs #812
1 parent badf398 commit 2c54120

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/lexer/disambiguateTokens.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const propertyNameKeywordToIdent = (token: Token, i: number, tokens: Token[]): T
3131
if (prevToken && prevToken.type === TokenType.PROPERTY_ACCESS_OPERATOR) {
3232
return { ...token, type: TokenType.IDENTIFIER, text: token.raw };
3333
}
34+
const nextToken = nextNonCommentToken(tokens, i);
35+
if (nextToken && nextToken.type === TokenType.PROPERTY_ACCESS_OPERATOR) {
36+
return { ...token, type: TokenType.IDENTIFIER, text: token.raw };
37+
}
3438
}
3539
return token;
3640
};

test/options/keywordCase.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ export default function supportsKeywordCase(format: FormatFn) {
6262
`);
6363
});
6464

65+
it('treats dot-seperated keywords as plain identifiers', () => {
66+
const result = format('select table.and from set.select', {
67+
keywordCase: 'upper',
68+
});
69+
expect(result).toBe(dedent`
70+
SELECT
71+
table.and
72+
FROM
73+
set.select
74+
`);
75+
});
76+
6577
// regression test for #356
6678
it('formats multi-word reserved clauses into single line', () => {
6779
const result = format(

0 commit comments

Comments
 (0)