Просмотр исходного кода

Implement suggestions from PR reviews

Robin Maisch 4 лет назад
Родитель
Сommit
2a1831d554

+ 0 - 1
jplag.frontend.R/pom.xml

@@ -31,7 +31,6 @@
             <plugin>
                 <groupId>org.antlr</groupId>
                 <artifactId>antlr4-maven-plugin</artifactId>
-                <version>4.10.1</version>
                 <executions>
                     <execution>
                         <goals>

+ 1 - 1
jplag.frontend.R/src/main/java/de/jplag/R/RCombinedBaseListener.java

@@ -9,7 +9,7 @@ import de.jplag.R.grammar.*;
 /**
  * Empty base implementation for {@link RListener} and {@link RFilterListener}.
  */
-public class RCombinedBaseListener implements RListener, RFilterListener {
+public abstract class RCombinedBaseListener implements RListener, RFilterListener {
     @Override
     public void enterStream(RFilter.StreamContext context) {
 

+ 0 - 1
jplag.frontend.R/src/main/java/de/jplag/R/RToken.java

@@ -3,7 +3,6 @@ package de.jplag.R;
 /**
  * This class represents the occurrence of an R Token in the source code. Based on an R frontend for JPlag v2.15 by Olmo
  * Kramer, see their <a href="https://github.com/CodeGra-de/jplag/tree/master/jplag.frontend.R">JPlag fork</a>.
- * @author Robin Maisch
  */
 public class RToken extends de.jplag.Token implements RTokenConstants {
 

+ 5 - 3
jplag.frontend.R/src/test/java/de/jplag/R/RFrontendTest.java

@@ -32,6 +32,8 @@ public class RFrontendTest {
      * Test source file that is supposed to produce a complete set of tokens, i.e. all types of tokens.
      */
     private static final String COMPLETE_TEST_FILE = "Complete.R";
+    public static final int NOT_SET = -1;
+
     private final Logger logger = LoggerFactory.getLogger("R frontend test");
     private final String[] testFiles = new String[] {"Game.R", COMPLETE_TEST_FILE};
     private final File testFileLocation = Path.of("src", "test", "resources", "de", "jplag", "R").toFile();
@@ -75,7 +77,7 @@ public class RFrontendTest {
 
             if (codeLines.length > tokenLines.length) {
                 var diffLine = IntStream.range(0, codeLines.length)
-                        .dropWhile(lineIdx -> lineIdx < tokenLines.length && codeLines[lineIdx] == tokenLines[lineIdx]).findFirst();
+                        .dropWhile(lineIndex -> lineIndex < tokenLines.length && codeLines[lineIndex] == tokenLines[lineIndex]).findFirst();
                 diffLine.ifPresent(
                         lineIdx -> fail("Line %d of file '%s' is not represented in the token list.".formatted(codeLines[lineIdx], fileName)));
             }
@@ -98,9 +100,9 @@ public class RFrontendTest {
 
         if (allTokens.length > foundTokens.length) {
             var diffLine = IntStream.range(0, allTokens.length)
-                    .dropWhile(lineIdx -> lineIdx < foundTokens.length && allTokens[lineIdx] == foundTokens[lineIdx]).findFirst();
+                    .dropWhile(lineIndex -> lineIndex < foundTokens.length && allTokens[lineIndex] == foundTokens[lineIndex]).findFirst();
             diffLine.ifPresent(lineIdx -> fail("Token type %s was not found in the complete code example '%s'."
-                    .formatted(new RToken(allTokens[lineIdx], fileName, -1, -1, -1).type2string(), fileName)));
+                    .formatted(new RToken(allTokens[lineIdx], fileName, NOT_SET, NOT_SET, NOT_SET).type2string(), fileName)));
         }
         assertArrayEquals(allTokens, foundTokens);
     }