[julia] Update for PMD 7

This commit is contained in:
Andreas Dangel
2023-04-04 19:48:32 +02:00
parent 1ef32e4a3f
commit acc6aa2681
6 changed files with 142 additions and 145 deletions

View File

@ -9,7 +9,7 @@ Julia was designed from the beginning for high performance.
Julia programs compile to efficient native code for multiple platforms via LLVM.
## Support in PMD
Starting from version 6.55.0, Julia support was added to CPD.
Starting from version 7.0.0, Julia support was added to CPD.
### Limitations
- Support for Julia only extends to CPD to detect code duplication in Julia source files.

View File

@ -158,6 +158,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-julia</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-kotlin</artifactId>

View File

@ -41,8 +41,8 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -5,26 +5,17 @@
package net.sourceforge.pmd.lang.julia.cpd;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import net.sourceforge.pmd.cpd.AntlrTokenizer;
import net.sourceforge.pmd.cpd.SourceCode;
import net.sourceforge.pmd.cpd.token.AntlrTokenFilter;
import net.sourceforge.pmd.lang.antlr.AntlrTokenManager;
import net.sourceforge.pmd.cpd.internal.AntlrTokenizer;
import net.sourceforge.pmd.lang.julia.ast.JuliaLexer;
/**
* The Julia Tokenizer.
*/
public class JuliaTokenizer extends AntlrTokenizer {
@Override
protected AntlrTokenManager getLexerForSource(SourceCode sourceCode) {
CharStream charStream = AntlrTokenizer.getCharStreamFromSourceCode(sourceCode);
return new AntlrTokenManager(new JuliaLexer(charStream), sourceCode.getFileName());
}
@Override
protected AntlrTokenFilter getTokenFilter(final AntlrTokenManager tokenManager) {
return new AntlrTokenFilter(tokenManager);
protected Lexer getLexerForSource(CharStream charStream) {
return new JuliaLexer(charStream);
}
}

View File

@ -6,13 +6,13 @@ package net.sourceforge.pmd.cpd;
import java.util.Properties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
import net.sourceforge.pmd.lang.julia.cpd.JuliaTokenizer;
public class JuliaTokenizerTest extends CpdTextComparisonTest {
public JuliaTokenizerTest() {
class JuliaTokenizerTest extends CpdTextComparisonTest {
JuliaTokenizerTest() {
super(".jl");
}
@ -28,7 +28,7 @@ public class JuliaTokenizerTest extends CpdTextComparisonTest {
}
@Test
public void testMathExample() {
void testMathExample() {
doTest("mathExample");
}
}

View File

@ -1,143 +1,143 @@
[Image] or [Truncated image[ Bcol Ecol
L2
[function] 1 8
[sphere_vol] 10 19
[(] 20 20
[r] 21 21
[)] 22 22
[function] 1 9
[sphere_vol] 10 20
[(] 20 21
[r] 21 22
[)] 22 23
L5
[return] 3 8
[4] 10 10
[/] 11 11
[3] 12 12
[*] 13 13
[pi] 14 15
[*] 16 16
[r] 17 17
[^] 18 18
[3] 19 19
[return] 3 9
[4] 10 11
[/] 11 12
[3] 12 13
[*] 13 14
[pi] 14 16
[*] 16 17
[r] 17 18
[^] 18 19
[3] 19 20
L6
[end] 1 3
[end] 1 4
L9
[quadratic] 1 9
[(] 10 10
[a] 11 11
[,] 12 12
[sqr_term] 14 21
[,] 22 22
[b] 24 24
[)] 25 25
[=] 27 27
[(] 29 29
[-] 30 30
[b] 31 31
[+] 33 33
[sqr_term] 35 42
[)] 43 43
[/] 45 45
[2] 47 47
[a] 48 48
[quadratic] 1 10
[(] 10 11
[a] 11 12
[,] 12 13
[sqr_term] 14 22
[,] 22 23
[b] 24 25
[)] 25 26
[=] 27 28
[(] 29 30
[-] 30 31
[b] 31 32
[+] 33 34
[sqr_term] 35 43
[)] 43 44
[/] 45 46
[2] 47 48
[a] 48 49
L12
[function] 1 8
[quadratic2] 10 19
[(] 20 20
[a] 21 21
[::] 22 23
[Float64] 24 30
[,] 31 31
[b] 33 33
[::] 34 35
[Float64] 36 42
[,] 43 43
[c] 45 45
[::] 46 47
[Float64] 48 54
[)] 55 55
[function] 1 9
[quadratic2] 10 20
[(] 20 21
[a] 21 22
[::] 22 24
[Float64] 24 31
[,] 31 32
[b] 33 34
[::] 34 36
[Float64] 36 43
[,] 43 44
[c] 45 46
[::] 46 48
[Float64] 48 55
[)] 55 56
L15
[sqr_term] 3 10
[=] 12 12
[sqrt] 14 17
[(] 18 18
[b] 19 19
[^] 20 20
[2] 21 21
[-] 22 22
[4] 23 23
[a] 24 24
[*] 25 25
[c] 26 26
[)] 27 27
[sqr_term] 3 11
[=] 12 13
[sqrt] 14 18
[(] 18 19
[b] 19 20
[^] 20 21
[2] 21 22
[-] 22 23
[4] 23 24
[a] 24 25
[*] 25 26
[c] 26 27
[)] 27 28
L16
[r1] 3 4
[=] 6 6
[quadratic] 8 16
[(] 17 17
[a] 18 18
[,] 19 19
[sqr_term] 21 28
[,] 29 29
[b] 31 31
[)] 32 32
[r1] 3 5
[=] 6 7
[quadratic] 8 17
[(] 17 18
[a] 18 19
[,] 19 20
[sqr_term] 21 29
[,] 29 30
[b] 31 32
[)] 32 33
L17
[r2] 3 4
[=] 6 6
[quadratic] 8 16
[(] 17 17
[a] 18 18
[,] 19 19
[-] 21 21
[sqr_term] 22 29
[,] 30 30
[b] 32 32
[)] 33 33
[r2] 3 5
[=] 6 7
[quadratic] 8 17
[(] 17 18
[a] 18 19
[,] 19 20
[-] 21 22
[sqr_term] 22 30
[,] 30 31
[b] 32 33
[)] 33 34
L20
[r1] 3 4
[,] 5 5
[r2] 7 8
[r1] 3 5
[,] 5 6
[r2] 7 9
L21
[end] 1 3
[end] 1 4
L23
[vol] 1 3
[=] 5 5
[sphere_vol] 7 16
[(] 17 17
[3] 18 18
[)] 19 19
[vol] 1 4
[=] 5 6
[sphere_vol] 7 17
[(] 17 18
[3] 18 19
[)] 19 20
L25
[using] 1 5
[Printf] 7 12
[using] 1 6
[Printf] 7 13
L26
[@] 1 1
[printf] 2 7
["volume = %0.3f\\n"] 9 26
[vol] 28 30
[@] 1 2
[printf] 2 8
["volume = %0.3f\\n"] 9 27
[vol] 28 31
L29
[quad1] 1 5
[,] 6 6
[quad2] 8 12
[=] 14 14
[quadratic2] 16 25
[(] 26 26
[2.0] 27 29
[,] 30 30
[-] 32 32
[2.0] 33 35
[,] 36 36
[-] 38 38
[12.0] 39 42
[)] 43 43
[quad1] 1 6
[,] 6 7
[quad2] 8 13
[=] 14 15
[quadratic2] 16 26
[(] 26 27
[2.0] 27 30
[,] 30 31
[-] 32 33
[2.0] 33 36
[,] 36 37
[-] 38 39
[12.0] 39 43
[)] 43 44
L30
[println] 1 7
[(] 8 8
["result 1: "] 9 20
[,] 21 21
[quad1] 23 27
[)] 28 28
[println] 1 8
[(] 8 9
["result 1: "] 9 21
[,] 21 22
[quad1] 23 28
[)] 28 29
L32
[println] 1 7
[(] 8 8
["result 2: "] 9 20
[,] 21 21
[quad2] 23 27
[)] 28 28
[println] 1 8
[(] 8 9
["result 2: "] 9 21
[,] 21 22
[quad2] 23 28
[)] 28 29
EOF