mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
catch SIOOBE in PythonNamesValidator
This commit is contained in:
@@ -7,29 +7,36 @@ import com.jetbrains.python.lexer.PythonLexer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Alexey.Ivanov
|
||||
* Date: Aug 19, 2009
|
||||
* Time: 10:23:26 PM
|
||||
* @author Alexey.Ivanov
|
||||
*/
|
||||
public class PythonNamesValidator implements NamesValidator {
|
||||
private static final PythonLexer ourLexer = new PythonLexer();
|
||||
|
||||
public synchronized boolean isKeyword(@NotNull final String name, final Project project) {
|
||||
ourLexer.start(name);
|
||||
if (!PyTokenTypes.KEYWORDS.contains(ourLexer.getTokenType())) {
|
||||
try {
|
||||
ourLexer.start(name);
|
||||
if (!PyTokenTypes.KEYWORDS.contains(ourLexer.getTokenType())) {
|
||||
return false;
|
||||
}
|
||||
ourLexer.advance();
|
||||
return ourLexer.getTokenType() == null;
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e) {
|
||||
return false;
|
||||
}
|
||||
ourLexer.advance();
|
||||
return ourLexer.getTokenType() == null;
|
||||
}
|
||||
|
||||
public synchronized boolean isIdentifier(@NotNull final String name, final Project project) {
|
||||
ourLexer.start(name);
|
||||
if (ourLexer.getTokenType() != PyTokenTypes.IDENTIFIER) {
|
||||
try {
|
||||
ourLexer.start(name);
|
||||
if (ourLexer.getTokenType() != PyTokenTypes.IDENTIFIER) {
|
||||
return false;
|
||||
}
|
||||
ourLexer.advance();
|
||||
return ourLexer.getTokenType() == null;
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e) {
|
||||
return false;
|
||||
}
|
||||
ourLexer.advance();
|
||||
return ourLexer.getTokenType() == null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user