Skip to content

Commit

Permalink
Fix offset warnings with quoted strings
Browse files Browse the repository at this point in the history
Fixes #169
  • Loading branch information
FPtje committed Oct 22, 2023
1 parent 65535c1 commit 94fe10a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/GLuaFixer/AG/LexLint.ag
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ sem Token
| DQString
loc.consistent = (not . lint_syntaxInconsistencies $ @lhs.config) || (not . cUsed $ @lhs.strSyntax)
loc.strSyntax = SyntaxUsed @loc.consistent False
lhs.nextTokenPos = customAdvanceStr @lhs.nextTokenPos @str
-- Apply custom advancement of the string, but also have the advancement take the quotes into account
lhs.nextTokenPos = customAdvanceStr @lhs.nextTokenPos $ "\"" <> @str <> "\""
+tokenWarnings = if @loc.consistent then id else
(:) $ SyntaxInconsistency "double quoted strings" "single quoted strings"

| SQString
loc.consistent = (not . lint_syntaxInconsistencies $ @lhs.config) || (not . luaUsed $ @lhs.strSyntax) || isSingleChar @str -- Allow single character ' ' strings
loc.strSyntax = SyntaxUsed False (@loc.consistent && not (isSingleChar @str))
lhs.nextTokenPos = customAdvanceStr @lhs.nextTokenPos @str
-- Apply custom advancement of the string, but also have the advancement take the quotes into account
lhs.nextTokenPos = customAdvanceStr @lhs.nextTokenPos $ "'" <> @str <> "'"
+tokenWarnings = if @loc.consistent then id else
(:) $ SyntaxInconsistency "single quoted strings" "double quoted strings"

Expand Down

0 comments on commit 94fe10a

Please sign in to comment.