Skip to content

Commit

Permalink
fixes #439; Avoid indexing an empty array in HaskellNamesValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
carymrobbins committed Aug 18, 2020
1 parent c0771e0 commit bd3be73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/com/haskforce/language/HaskellNamesValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.regex.Pattern;

/**
* Ensures names are legal Haskell. Used by refactoring.
Expand Down Expand Up @@ -35,15 +36,17 @@ public boolean isKeyword(@NotNull String name, Project project) {
*/
@Override
public boolean isIdentifier(@NotNull String name, Project project) {
String[] parts = name.split("\\.");

String[] parts = DOT_REGEX.split(name);
if (parts.length == 0) return false;
for (int i = 0; i < parts.length - 1; i++) {
String word = parts[i];
if (!isModid(word, project)) return false;
}
return isOneid(parts[parts.length - 1], project, true);
}

static Pattern DOT_REGEX = Pattern.compile("\\.");

/**
* Extended grammar for varid/conid from Haskell 2010 specification. Also allows
* underscore as start on varids.
Expand Down

0 comments on commit bd3be73

Please sign in to comment.