From cfd385ea0cc49cc81d845b393b9f64a26f910275 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 18 Aug 2016 17:23:52 +0300 Subject: [PATCH] Cleanup (constants; formatting) --- .../src/com/intellij/psi/PsiKeyword.java | 9 +++---- .../intellij/lang/java/lexer/JavaLexer.java | 14 ++++++----- .../completion/Normal8CompletionTest.groovy | 25 +++++++------------ 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/PsiKeyword.java b/java/java-psi-api/src/com/intellij/psi/PsiKeyword.java index e71434599ccb..5ce10a1ee9b9 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiKeyword.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiKeyword.java @@ -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"; diff --git a/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java b/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java index a82675a706ee..79eb188bf4e6 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java @@ -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 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; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal8CompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal8CompletionTest.groovy index 4d52ee6b479d..e6428ea3733f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal8CompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal8CompletionTest.groovy @@ -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(); } -} +} \ No newline at end of file