From ad7ac9be5fb76c45e838b7f83cb838585b7ebb7f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 30 Sep 2022 12:40:24 +0200 Subject: [PATCH] [lua] Fix compile errors --- .../net/sourceforge/pmd/cpd/LuaTokenizer.java | 5 +- .../pmd/lang/lua/cpd/testdata/comment.txt | 32 +- .../pmd/lang/lua/cpd/testdata/luauTypes.txt | 540 +++++++++--------- 3 files changed, 290 insertions(+), 287 deletions(-) diff --git a/pmd-lua/src/main/java/net/sourceforge/pmd/cpd/LuaTokenizer.java b/pmd-lua/src/main/java/net/sourceforge/pmd/cpd/LuaTokenizer.java index 5523dddf77..509a7803c6 100644 --- a/pmd-lua/src/main/java/net/sourceforge/pmd/cpd/LuaTokenizer.java +++ b/pmd-lua/src/main/java/net/sourceforge/pmd/cpd/LuaTokenizer.java @@ -10,8 +10,10 @@ import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.Lexer; import net.sourceforge.pmd.cpd.internal.AntlrTokenizer; -import net.sourceforge.pmd.lang.lua.ast.LuaLexer; import net.sourceforge.pmd.cpd.token.AntlrTokenFilter; +import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrToken; +import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrTokenManager; +import net.sourceforge.pmd.lang.lua.ast.LuaLexer; /** * The Lua Tokenizer @@ -37,6 +39,7 @@ public class LuaTokenizer extends AntlrTokenizer { @Override protected Lexer getLexerForSource(CharStream charStream) { return new LuaLexer(charStream); + } @Override protected AntlrTokenFilter getTokenFilter(final AntlrTokenManager tokenManager) { diff --git a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/comment.txt b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/comment.txt index f6f1fd25fd..d2bb8e818c 100644 --- a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/comment.txt +++ b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/comment.txt @@ -1,23 +1,23 @@ [Image] or [Truncated image[ Bcol Ecol L3 - [print] 1 5 - [(] 6 6 - [1] 7 7 - [)] 18 18 + [print] 1 6 + [(] 6 7 + [1] 7 8 + [)] 18 19 L6 - [print] 1 5 - [(] 6 6 - [1] 7 7 - [)] 8 8 + [print] 1 6 + [(] 6 7 + [1] 7 8 + [)] 8 9 L9 - [print] 1 5 - [(] 6 6 - [1] 7 7 + [print] 1 6 + [(] 6 7 + [1] 7 8 L10 - [)] 17 17 + [)] 17 18 L13 - [print] 1 5 - [(] 6 6 - [1] 7 7 - [)] 8 8 + [print] 1 6 + [(] 6 7 + [1] 7 8 + [)] 8 9 EOF diff --git a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt index f1a3934c53..464fb611d5 100644 --- a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt +++ b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt @@ -1,302 +1,302 @@ [Image] or [Truncated image[ Bcol Ecol L2 - [type] 1 4 - [Array] 6 10 - [<] 11 11 - [T] 12 12 - [=] 14 14 - [any] 16 18 - [>] 19 19 - [=] 21 21 - [{] 23 23 - [T] 25 25 - [}] 27 27 + [type] 1 5 + [Array] 6 11 + [<] 11 12 + [T] 12 13 + [=] 14 15 + [any] 16 19 + [>] 19 20 + [=] 21 22 + [{] 23 24 + [T] 25 26 + [}] 27 28 L3 - [local] 1 5 - [x] 7 7 - [=] 9 9 - [31337] 11 15 + [local] 1 6 + [x] 7 8 + [=] 9 10 + [31337] 11 16 L4 - [local] 1 5 - [_negativeLiteral] 7 22 - [=] 24 24 - [-] 26 26 - [3] 27 27 + [local] 1 6 + [_negativeLiteral] 7 23 + [=] 24 25 + [-] 26 27 + [3] 27 28 L5 - [local] 1 5 - [_negativeVariable] 7 23 - [=] 25 25 - [-] 27 27 - [x] 28 28 + [local] 1 6 + [_negativeVariable] 7 24 + [=] 25 26 + [-] 27 28 + [x] 28 29 L6 - [local] 1 5 - [_notLiteral] 7 17 - [=] 19 19 - [not] 21 23 - [true] 25 28 + [local] 1 6 + [_notLiteral] 7 18 + [=] 19 20 + [not] 21 24 + [true] 25 29 L7 - [local] 1 5 - [_notVariable] 7 18 - [=] 20 20 - [not] 22 24 - [x] 26 26 + [local] 1 6 + [_notVariable] 7 19 + [=] 20 21 + [not] 22 25 + [x] 26 27 L8 - [local] 1 5 - [_length] 7 13 - [=] 15 15 - [#] 17 17 - [{] 18 18 - [x] 19 19 - [}] 20 20 + [local] 1 6 + [_length] 7 14 + [=] 15 16 + [#] 17 18 + [{] 18 19 + [x] 19 20 + [}] 20 21 L9 - [export] 1 6 - [type] 8 11 - [Function] 13 20 - [<] 21 21 - [T] 22 22 - [...] 23 25 - [=] 27 27 - [...] 29 31 - [any] 32 34 - [>] 35 35 - [=] 37 37 - [(] 39 39 - [...] 40 42 - [any] 43 45 - [)] 46 46 - [->] 48 49 - [T] 51 51 - [...] 52 54 + [export] 1 7 + [type] 8 12 + [Function] 13 21 + [<] 21 22 + [T] 22 23 + [...] 23 26 + [=] 27 28 + [...] 29 32 + [any] 32 35 + [>] 35 36 + [=] 37 38 + [(] 39 40 + [...] 40 43 + [any] 43 46 + [)] 46 47 + [->] 48 50 + [T] 51 52 + [...] 52 55 L10 - [local] 1 5 - [_PlatformService] 7 22 - [=] 24 24 - [nil] 26 28 + [local] 1 6 + [_PlatformService] 7 23 + [=] 24 25 + [nil] 26 29 L11 - [local] 1 5 - [game] 7 10 - [=] 12 12 - [.] 41 41 - [default] 42 48 - [::] 50 51 - [any] 53 55 + [local] 1 6 + [game] 7 11 + [=] 12 13 + [.] 41 42 + [default] 42 49 + [::] 50 52 + [any] 53 56 L12 - [pcall] 1 5 - [(] 6 6 - [function] 7 14 - [(] 15 15 - [)] 16 16 - [_PlatformService] 18 33 - [=] 35 35 - [game] 37 40 - [:] 41 41 - [GetService] 42 51 - [(] 52 52 - ['PlatformService'] 53 69 - [)] 70 70 - [end] 72 74 - [)] 75 75 + [pcall] 1 6 + [(] 6 7 + [function] 7 15 + [(] 15 16 + [)] 16 17 + [_PlatformService] 18 34 + [=] 35 36 + [game] 37 41 + [:] 41 42 + [GetService] 42 52 + [(] 52 53 + ['PlatformService'] 53 70 + [)] 70 71 + [end] 72 75 + [)] 75 76 L14 - [return] 1 6 - [function] 8 15 - [<] 17 17 - [T] 18 18 - [>] 19 19 - [(] 20 20 - [req] 21 23 - [,] 24 24 - [...] 26 28 - [:] 29 29 - [boolean] 31 37 - [)] 38 38 - [:] 39 39 - [(] 41 41 - [{] 42 42 - [\[] 43 43 - [string] 44 49 - [|] 50 50 - [number] 51 56 - [\]] 57 57 - [:] 58 58 - [T] 60 60 - [}] 61 61 - [,] 62 62 - [string] 64 69 - [,] 70 70 - [Function] 72 79 - [<] 80 80 - [...] 81 83 - [any] 84 86 - [>] 87 87 - [)] 88 88 + [return] 1 7 + [function] 8 16 + [<] 17 18 + [T] 18 19 + [>] 19 20 + [(] 20 21 + [req] 21 24 + [,] 24 25 + [...] 26 29 + [:] 29 30 + [boolean] 31 38 + [)] 38 39 + [:] 39 40 + [(] 41 42 + [{] 42 43 + [\[] 43 44 + [string] 44 50 + [|] 50 51 + [number] 51 57 + [\]] 57 58 + [:] 58 59 + [T] 60 61 + [}] 61 62 + [,] 62 63 + [string] 64 70 + [,] 70 71 + [Function] 72 80 + [<] 80 81 + [...] 81 84 + [any] 84 87 + [>] 87 88 + [)] 88 89 L15 - [local] 3 7 - [body] 9 12 - [=] 14 14 - [string] 16 21 - [.] 22 22 - [format] 23 28 - [(] 29 29 - ["%s %s\\n"] 30 38 - [,] 39 39 - [req] 41 43 - [.] 44 44 - [method] 45 50 - [,] 51 51 - [req] 53 55 - [.] 56 56 - [path] 57 60 - [)] 61 61 + [local] 3 8 + [body] 9 13 + [=] 14 15 + [string] 16 22 + [.] 22 23 + [format] 23 29 + [(] 29 30 + ["%s %s\\n"] 30 39 + [,] 39 40 + [req] 41 44 + [.] 44 45 + [method] 45 51 + [,] 51 52 + [req] 53 56 + [.] 56 57 + [path] 57 61 + [)] 61 62 L16 - [local] 3 7 - [res] 9 11 - [=] 13 13 - [{] 15 15 + [local] 3 8 + [res] 9 12 + [=] 13 14 + [{] 15 16 L17 - [code] 5 8 - [=] 10 10 - [200] 12 14 - [,] 15 15 + [code] 5 9 + [=] 10 11 + [200] 12 15 + [,] 15 16 L18 - [{] 5 5 - ["Content-Type"] 7 20 - [,] 21 21 - ["text/plain"] 23 34 - [}] 36 36 - [,] 37 37 + [{] 5 6 + ["Content-Type"] 7 21 + [,] 21 22 + ["text/plain"] 23 35 + [}] 36 37 + [,] 37 38 L19 - [{] 5 5 + [{] 5 6 L20 - ["Content-Length"] 7 22 - [,] 23 23 + ["Content-Length"] 7 23 + [,] 23 24 L21 - [#] 7 7 - [body] 8 11 - [,] 12 12 + [#] 7 8 + [body] 8 12 + [,] 12 13 L22 - [\[] 7 7 - ["Auth.Confirm"] 8 21 - [\]] 22 22 - [=] 24 24 - [\[\[至:%s。\]\]] 26 34 - [,] 35 35 + [\[] 7 8 + ["Auth.Confirm"] 8 22 + [\]] 22 23 + [=] 24 25 + [\[\[至:%s。\]\]] 26 35 + [,] 35 36 L24 - [}] 5 5 - [::] 7 8 - [Array] 10 14 - [<] 15 15 - [any] 16 18 - [>] 19 19 - [,] 20 20 + [}] 5 6 + [::] 7 9 + [Array] 10 15 + [<] 15 16 + [any] 16 19 + [>] 19 20 + [,] 20 21 L25 - [}] 3 3 - [::] 5 6 - [{] 8 8 - [\[] 10 10 - [any] 11 13 - [\]] 14 14 - [:] 15 15 - [number] 17 22 - [|] 24 24 - [Array] 26 30 - [<] 31 31 - [string] 32 37 - [|] 39 39 - [boolean] 41 47 - [>] 48 48 - [}] 50 50 + [}] 3 4 + [::] 5 7 + [{] 8 9 + [\[] 10 11 + [any] 11 14 + [\]] 14 15 + [:] 15 16 + [number] 17 23 + [|] 24 25 + [Array] 26 31 + [<] 31 32 + [string] 32 38 + [|] 39 40 + [boolean] 41 48 + [>] 48 49 + [}] 50 51 L26 - [if] 3 4 - [(] 6 6 - [req] 7 9 - [::] 11 12 - [any] 14 16 - [)] 17 17 - [.] 18 18 - [keepAlive] 19 27 - [then] 29 32 + [if] 3 5 + [(] 6 7 + [req] 7 10 + [::] 11 13 + [any] 14 17 + [)] 17 18 + [.] 18 19 + [keepAlive] 19 28 + [then] 29 33 L27 - [local] 5 9 - [socketType] 11 20 - [:] 21 21 - ["Connection"] 23 34 - [|] 36 36 - ["Pingback"] 38 47 - [|] 49 49 - [""] 51 52 - [=] 54 54 - [""] 56 57 - [::] 59 60 - [""] 62 63 + [local] 5 10 + [socketType] 11 21 + [:] 21 22 + ["Connection"] 23 35 + [|] 36 37 + ["Pingback"] 38 48 + [|] 49 50 + [""] 51 53 + [=] 54 55 + [""] 56 58 + [::] 59 61 + [""] 62 64 L28 - [socketType] 5 14 - [=] 16 16 - ["Connection"] 18 29 - [::] 31 32 - ["Connection"] 34 45 + [socketType] 5 15 + [=] 16 17 + ["Connection"] 18 30 + [::] 31 33 + ["Connection"] 34 46 L29 - [res] 5 7 - [\[] 8 8 - [#] 9 9 - [res] 10 12 - [+] 14 14 - [1] 16 16 - [\]] 17 17 - [=] 19 19 - [{] 21 21 - [socketType] 23 32 - [::] 34 35 - [string] 37 42 - [,] 43 43 - [`\\`${req.keepAlive}\\``] 45 66 - [}] 68 68 + [res] 5 8 + [\[] 8 9 + [#] 9 10 + [res] 10 13 + [+] 14 15 + [1] 16 17 + [\]] 17 18 + [=] 19 20 + [{] 21 22 + [socketType] 23 33 + [::] 34 36 + [string] 37 43 + [,] 43 44 + [`\\`${req.keepAlive}\\``] 45 67 + [}] 68 69 L30 - [res] 5 7 - [\[] 8 8 - [#] 9 9 - [res] 10 12 - [-] 14 14 - [2] 16 16 - [\]] 17 17 - [=] 19 19 - [{] 21 21 - [...] 23 25 - [}] 27 27 + [res] 5 8 + [\[] 8 9 + [#] 9 10 + [res] 10 13 + [-] 14 15 + [2] 16 17 + [\]] 17 18 + [=] 19 20 + [{] 21 22 + [...] 23 26 + [}] 27 28 L31 - [end] 3 5 + [end] 3 6 L33 - [return] 3 8 - [(] 10 10 - [res] 11 13 - [::] 15 16 - [any] 18 20 - [)] 21 21 - [::] 23 24 - [{] 26 26 - [T] 28 28 - [}] 30 30 - [,] 31 31 - [(] 33 33 - [if] 34 35 - [req] 37 39 - [then] 41 44 - [body] 46 49 - [else] 51 54 - [""] 56 57 - [)] 58 58 - [::] 60 61 - [string] 63 68 - [,] 69 69 - [function] 71 78 - [(] 79 79 - [...] 80 82 - [)] 83 83 - [:] 84 84 - [...] 86 88 - [any] 89 91 - [return] 93 98 - [...] 100 102 - [end] 104 106 + [return] 3 9 + [(] 10 11 + [res] 11 14 + [::] 15 17 + [any] 18 21 + [)] 21 22 + [::] 23 25 + [{] 26 27 + [T] 28 29 + [}] 30 31 + [,] 31 32 + [(] 33 34 + [if] 34 36 + [req] 37 40 + [then] 41 45 + [body] 46 50 + [else] 51 55 + [""] 56 58 + [)] 58 59 + [::] 60 62 + [string] 63 69 + [,] 69 70 + [function] 71 79 + [(] 79 80 + [...] 80 83 + [)] 83 84 + [:] 84 85 + [...] 86 89 + [any] 89 92 + [return] 93 99 + [...] 100 103 + [end] 104 107 L34 - [end] 1 3 + [end] 1 4 EOF