Cleanup (constants; formatting)

This commit is contained in:
Roman Shevchenko
2016-08-18 19:38:58 +03:00
parent 52c7ad2a4f
commit cfd385ea0c
3 changed files with 21 additions and 27 deletions
@@ -16,8 +16,7 @@
package com.intellij.psi;
/**
* Represents a Java keyword. Constants defined in this interface represent all
* keywords of the Java language.
* Represents a Java keyword. Constants defined in this interface represent all keywords and literals of the Java language.
*/
public interface PsiKeyword extends PsiJavaToken {
String ABSTRACT = "abstract";
@@ -57,6 +56,8 @@ public interface PsiKeyword extends PsiJavaToken {
String PUBLIC = "public";
String RETURN = "return";
String SHORT = "short";
String STATIC = "static";
String STRICTFP = "strictfp";
String SUPER = "super";
String SWITCH = "switch";
String SYNCHRONIZED = "synchronized";
@@ -66,10 +67,8 @@ public interface PsiKeyword extends PsiJavaToken {
String TRANSIENT = "transient";
String TRY = "try";
String VOID = "void";
String STATIC = "static";
String STRICTFP = "strictfp";
String WHILE = "while";
String VOLATILE = "volatile";
String WHILE = "while";
String TRUE = "true";
String FALSE = "false";
@@ -28,17 +28,19 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.Set;
import static com.intellij.psi.PsiKeyword.*;
public class JavaLexer extends LexerBase {
private static final Set<String> KEYWORDS = ContainerUtil.newTroveSet(
"abstract", "default", "if", "private", "this", "boolean", "do", "implements", "protected", "throw", "break", "double", "import",
"public", "throws", "byte", "else", "instanceof", "return", "transient", "case", "extends", "int", "short", "try", "catch", "final",
"interface", "static", "void", "char", "finally", "long", "strictfp", "volatile", "class", "float", "native", "super", "while",
"const", "for", "new", "switch", "continue", "goto", "package", "synchronized", "true", "false", "null");
ABSTRACT, BOOLEAN, BREAK, BYTE, CASE, CATCH, CHAR, CLASS, CONST, CONTINUE, DEFAULT, DO, DOUBLE, ELSE, EXTENDS, FINAL, FINALLY,
FLOAT, FOR, GOTO, IF, IMPLEMENTS, IMPORT, INSTANCEOF, INT, INTERFACE, LONG, NATIVE, NEW, PACKAGE, PRIVATE, PROTECTED, PUBLIC,
RETURN, SHORT, STATIC, STRICTFP, SUPER, SWITCH, SYNCHRONIZED, THIS, THROW, THROWS, TRANSIENT, TRY, VOID, VOLATILE, WHILE,
TRUE, FALSE, NULL);
public static boolean isKeyword(String id, @NotNull LanguageLevel level) {
return KEYWORDS.contains(id) ||
level.isAtLeast(LanguageLevel.JDK_1_4) && "assert".equals(id) ||
level.isAtLeast(LanguageLevel.JDK_1_5) && "enum".equals(id);
level.isAtLeast(LanguageLevel.JDK_1_4) && ASSERT.equals(id) ||
level.isAtLeast(LanguageLevel.JDK_1_5) && ENUM.equals(id);
}
private final _JavaLexer myFlexLexer;
@@ -18,23 +18,15 @@ package com.intellij.codeInsight.completion
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.lookup.LookupElementPresentation
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.annotations.NotNull
/**
* User: anna
* @author anna
*/
public class Normal8CompletionTest extends LightFixtureCompletionTestCase {
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
return JAVA_8;
}
final LightProjectDescriptor projectDescriptor = JAVA_8
final String basePath = JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/lambda/completion/normal/"
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/lambda/completion/normal/";
}
public void testSelfStaticsOnly() throws Exception {
public void testSelfStaticsOnly() {
configureByFile("SelfStaticsOnly.java");
assertStringItems("ba", "bar");
}
@@ -117,7 +109,7 @@ class Test {
assert items.find { LookupElementPresentation.renderElement(it).itemText.contains('this::bar') } != null
}
public void "test suggest receiver method reference"() throws Exception {
public void "test suggest receiver method reference"() {
myFixture.configureByText "a.java", """
class MethodRef {
@@ -256,12 +248,13 @@ class Test88 {
configureByTestName()
myFixture.assertPreferredCompletionItems(0, 'toString', 'wait')
}
public void testLambdaWithSuperWildcardInAmbiguousCall() {
configureByTestName()
myFixture.assertPreferredCompletionItems(0, 'substring', 'substring', 'subSequence')
}
public void testUnexpectedLambdaInAmbiguousCall() { doAntiTest() }
public void testUnexpectedLambdaInAmbiguousCall() { doAntiTest() }
public void testNoCollectorsInComment() { doAntiTest() }
public void testNoContinueInsideLambdaInLoop() { doAntiTest(); }
}
}