Procházet zdrojové kódy

Fix detecting Kotlin keywords with label

Robin Maisch před 4 roky
rodič
revize
3ca4aca650

+ 1 - 1
jplag.frontend.kotlin/src/main/java/de/jplag/kotlin/KotlinListener.java

@@ -354,7 +354,7 @@ public class KotlinListener extends KotlinParserBaseListener {
         Token token = node.getSymbol();
         String tokenText = token.getText();
         if (tokenText.contains("@")) {
-            tokenText = tokenText.substring(0, tokenText.indexOf("@") - 1);
+            tokenText = tokenText.substring(0, tokenText.indexOf("@"));
         }
         Optional<Integer> type = switch (tokenText) {
             case "throw" -> Optional.of(THROW);

+ 2 - 2
jplag.frontend.kotlin/src/test/resources/de/jplag/kotlin/Complete.kt

@@ -62,11 +62,11 @@ fun main(args : Array<String>) {
     println(complete.getAccessCount())
 
     var int : Int = 0;
-    while (true) {
+    loop@ while (true) {
         val box = Container(int);
         if (box.isTheAnswer()) {
             println("Finally!")
-            break
+            break@loop
         }
         int = int + 2;
     }