Skip to content

Commit bd3be73

Browse files
committed
fixes #439; Avoid indexing an empty array in HaskellNamesValidator
1 parent c0771e0 commit bd3be73

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/com/haskforce/language/HaskellNamesValidator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.jetbrains.annotations.NotNull;
77

88
import java.util.Arrays;
9+
import java.util.regex.Pattern;
910

1011
/**
1112
* Ensures names are legal Haskell. Used by refactoring.
@@ -35,15 +36,17 @@ public boolean isKeyword(@NotNull String name, Project project) {
3536
*/
3637
@Override
3738
public boolean isIdentifier(@NotNull String name, Project project) {
38-
String[] parts = name.split("\\.");
39-
39+
String[] parts = DOT_REGEX.split(name);
40+
if (parts.length == 0) return false;
4041
for (int i = 0; i < parts.length - 1; i++) {
4142
String word = parts[i];
4243
if (!isModid(word, project)) return false;
4344
}
4445
return isOneid(parts[parts.length - 1], project, true);
4546
}
4647

48+
static Pattern DOT_REGEX = Pattern.compile("\\.");
49+
4750
/**
4851
* Extended grammar for varid/conid from Haskell 2010 specification. Also allows
4952
* underscore as start on varids.

0 commit comments

Comments
 (0)