#460: Ignore enclosing backticks from identifier analysis.#477
#460: Ignore enclosing backticks from identifier analysis.#477adityatrivedi merged 7 commits intomasterfrom
Conversation
Rules: * [lower-camel-case] * [constant-naming] * [constant-k-prefix]
…he opening backtick
51fb395 to
d9ec09b
Compare
| String constantName = CharFormatUtil.unescapeIdentifier(ctx.getText()); | ||
| Location location = ListenerUtil.getContextStartLocation(ctx); | ||
| // Ensure that the violation column number reports the character after the opening backtick. | ||
| if (CharFormatUtil.isEnclosedInBackticks(ctx.getText())) { |
There was a problem hiding this comment.
We could create a function that returns the first character of an identifier and accounts for the escaped case (since we're doing this in a couple of places).
| assertTrue(CharFormatUtil.unescapeIdentifier("").isEmpty()); | ||
| assertTrue(CharFormatUtil.unescapeIdentifier("`s`").equals("s")); | ||
| assertTrue(CharFormatUtil.unescapeIdentifier("`self`").equals("self")); | ||
| assertFalse(CharFormatUtil.unescapeIdentifier("`self").equals("self")); |
There was a problem hiding this comment.
assertFalse is kind of weird here (it's like saying we expect that it should be anything but self). Can we change this to assertEqual (and the following assertFalse(s) as well)?
| // Backtick(s) are not part of the identifier | ||
| assertTrue(CharFormatUtil.unescapeIdentifier("``").isEmpty()); | ||
| assertTrue(CharFormatUtil.unescapeIdentifier("").isEmpty()); | ||
| assertTrue(CharFormatUtil.unescapeIdentifier("`s`").equals("s")); |
There was a problem hiding this comment.
you can use assertEquals(CharFormatUtil.unescapeIdentifier("`s`"), "s") instead (this applies to everything that follows)
|
|
||
| private void verifyLowerCamelCase(String constructType, ParserRuleContext ctx) { | ||
| String constructName = ctx.getText(); | ||
| verifyLowerCamelCase(constructType, ctx, false); |
There was a problem hiding this comment.
can you not escape function and enum names?
| * @param ctx the context | ||
| * @return the start location of the provided context's string | ||
| */ | ||
| public static Location getIdentifierStartLocation(ParserRuleContext ctx) { |
There was a problem hiding this comment.
maybe make the parameter type 'IdentifierContext' for clearer semantics
Based on the work done in #461 by @kober32 last year.
Fixes #460.