[Cucumber for Java] correctly handle step location in Windows
authorAndrey Vokin <andrey.vokin@jetbrains.com>
Thu, 14 Nov 2019 10:21:17 +0000 (11:21 +0100)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 14 Nov 2019 10:35:35 +0000 (10:35 +0000)
Step location in Windows contains symbol ':' twice (for example 'C:/folder/file:4')

GitOrigin-RevId: dc7faad29eee2192b4377c0e6981242004d97e14

plugins/cucumber-jvm-formatter3/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm3Adapter.java

index 6c8e56cacfd0bb7712d862c81ab476f32a8ce903..f39ff3fc8ab8b3cff5e7b726ebd7a847e632219b 100644 (file)
@@ -143,8 +143,10 @@ public class CucumberJvm3Adapter {
         else if (location.startsWith("file:")) {
           location = location.substring("file:".length());
         }
-        String[] fileAndLine = location.split(":");
-        String result = CucumberJvmSMFormatterUtil.getStepKeyword(fileAndLine[0], Integer.parseInt(fileAndLine[1]));
+        int lastColonIndex = location.lastIndexOf(':');
+        String filePath = location.substring(0, lastColonIndex);
+        String lineNumberString = location.substring(lastColonIndex + 1);
+        String result = CucumberJvmSMFormatterUtil.getStepKeyword(filePath, Integer.parseInt(lineNumberString));
         if (result != null) {
           return result;
         }