add npe check for current token
Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -122,6 +122,9 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
|||||||
final ParseExceptionWrapper parseExceptionWrapper = new ParseExceptionWrapper(parseException);
|
final ParseExceptionWrapper parseExceptionWrapper = new ParseExceptionWrapper(parseException);
|
||||||
final int[][] expectedTokenSequence = parseExceptionWrapper.getExpectedTokenSequence();
|
final int[][] expectedTokenSequence = parseExceptionWrapper.getExpectedTokenSequence();
|
||||||
final TokenWrapper currentToken = parseExceptionWrapper.getCurrentToken();
|
final TokenWrapper currentToken = parseExceptionWrapper.getCurrentToken();
|
||||||
|
if (currentToken == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
final TokenWrapper nextToken = currentToken.getNext();
|
final TokenWrapper nextToken = currentToken.getNext();
|
||||||
final int currentTokenKind = currentToken.getKind();
|
final int currentTokenKind = currentToken.getKind();
|
||||||
final String currentTokenImageName = currentToken.getImage();
|
final String currentTokenImageName = currentToken.getImage();
|
||||||
@@ -138,17 +141,22 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final int[] is : expectedTokenSequence) {
|
for (final int[] is : expectedTokenSequence) {
|
||||||
for (final int i : is) {
|
addSuggestionOnTokenImage(listTokens, nextTokenBeginColumn, currentTokenEndColumn, is);
|
||||||
final Collection<String> tokenImage = TokenDescription.getTokenImage(i);
|
|
||||||
if (tokenImage != null && !tokenImage.isEmpty()) {
|
|
||||||
tokenImage.forEach(image -> listTokens.add(new SuggestToken(currentTokenEndColumn + 1,
|
|
||||||
nextTokenBeginColumn + image.length(), null, image)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return listTokens;
|
return listTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addSuggestionOnTokenImage(final List<SuggestToken> listTokens, final int nextTokenBeginColumn,
|
||||||
|
final int currentTokenEndColumn, final int[] is) {
|
||||||
|
for (final int i : is) {
|
||||||
|
final Collection<String> tokenImage = TokenDescription.getTokenImage(i);
|
||||||
|
if (tokenImage != null && !tokenImage.isEmpty()) {
|
||||||
|
tokenImage.forEach(image -> listTokens.add(new SuggestToken(currentTokenEndColumn + 1,
|
||||||
|
nextTokenBeginColumn + image.length(), null, image)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Optional<List<SuggestToken>> handleFieldTokenSuggestion(final String currentTokenImageName,
|
private static Optional<List<SuggestToken>> handleFieldTokenSuggestion(final String currentTokenImageName,
|
||||||
final int nextTokenBeginColumn, final int currentTokenEndColumn) {
|
final int nextTokenBeginColumn, final int currentTokenEndColumn) {
|
||||||
final boolean containsDot = currentTokenImageName.indexOf('.') != -1;
|
final boolean containsDot = currentTokenImageName.indexOf('.') != -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user