nextChar == -1 || nextChar == ' ' || nextChar == ',' || nextChar == ';' || nextChar == '\n';
// TODO: Check if user has just fixed pairing?
if (context != IN_STRING) {
if ('(' == key && canPairParenthesis) {
return new ExplicitAction(new DefaultAutocompleteResult("()", "", 1));
} else if ('[' == key && canPairParenthesis) {
return new ExplicitAction(new DefaultAutocompleteResult("[]", "", 1));
} else if ('{' == key && canPairParenthesis) {
return new ExplicitAction(new DefaultAutocompleteResult("{}", "", 1));
} else if ('"' == key || '\'' == key) {
String doubleQuote = key + "" + key;
if (!textBeforePosition(selectionRange[0]).endsWith(doubleQuote)) {
return new ExplicitAction(new DefaultAutocompleteResult(doubleQuote, "", 1));
}
} else if (!selection.hasSelection() && (key == nextChar)
&& (']' == key || ')' == key || '}' == key)) {
// Testing what is more useful: pasting or passing.
JsonArray<Token> tokens = parser.parseLineSync(selectionRange[0].getLine());
if (tokens != null) {
int column = selectionRange[0].getColumn();
String closers = calculateClosingParens(tokens, column);
String openers = calculateOpenParens(tokens, column);
int match = StringUtils.findCommonPrefixLength(closers, openers);
int newMatch = StringUtils.findCommonPrefixLength(key + closers, openers);
if (newMatch <= match) {
// With pasting results will be worse -> pass.
return new ExplicitAction(DefaultAutocompleteResult.PASS_CHAR);
}
}
}
} else {
if ((key == nextChar) && ('"' == key || '\'' == key)) {
ParseResult<State> parseResult = parser.getState(State.class, selectionRange[0], key + " ");
if (parseResult != null) {
JsonArray<Token> tokens = parseResult.getTokens();
Preconditions.checkState(!tokens.isEmpty());
if (tokens.peek().getType() != STRING) {
return new ExplicitAction(DefaultAutocompleteResult.PASS_CHAR);
}
}
}
}