mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExtractSetFromComparisonChainAction: i18n, java9 test, disable in Java 1.4 or lower (as varargs and generics aren't available there)
This commit is contained in:
+3
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -111,7 +112,7 @@ public class ExtractSetFromComparisonChainAction extends PsiElementBaseIntention
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
return disjuncts(element).count() > 1;
|
||||
return PsiUtil.isLanguageLevel5OrHigher(element) && disjuncts(element).count() > 1;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -124,7 +125,7 @@ public class ExtractSetFromComparisonChainAction extends PsiElementBaseIntention
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Extract Set from comparison chain";
|
||||
return CodeInsightBundle.message("intention.extract.set.from.comparison.chain.family");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.Set;
|
||||
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
private static final Set<String> PROPERTIES = Set.of("foo", "bar", "baz");
|
||||
|
||||
void testOr(int i, String property) {
|
||||
if(i > 0 || PROPERTIES.contains(property) || i == -10) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
void testOr(int i, String property) {
|
||||
if(i > 0 || "foo"<caret>.equals(property) || "bar".equals(property) || "baz".equals(property) || i == -10) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -16,11 +16,17 @@
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
public class ExtractSetFromComparisonChainActionTest extends LightIntentionActionTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected LanguageLevel getLanguageLevel() {
|
||||
return getTestName(false).contains("Java9") ? LanguageLevel.JDK_1_9 : LanguageLevel.JDK_1_8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/extractSetFromComparison";
|
||||
|
||||
@@ -545,3 +545,5 @@ inlay.hints.disable.action.text=Disable Hints
|
||||
inlay.hints.blacklist.pattern.explanation=<html> No in-line parameter name hints will be shown for methods matching any of these patterns.<br> Patterns are matched on fully qualified method name, parameter count and parameter names. <ul> <li><code>java.lang</code> matches all methods from <em>java.lang</em> package</li> <li><code>java.lang.*(*, *)</code> matches all methods from the <em>java.lang</em> package with two parameters</li> <li><code>(*info)</code> matches all single parameter methods where the parameter name ends with <em>info</em></li> <li><code>(key, value)</code> matches all methods with parameters <em>key</em> and <em>value</em></li> <li><code>*.put(key, value)</code> matches all <em>put</em> methods with <em>key</em> and <em>value</em> parameters </ul> </html>
|
||||
inlay.hints.disable.custom.option=Disable ''{0}''
|
||||
inlay.hints.enable.custom.option=Enable ''{0}''
|
||||
|
||||
intention.extract.set.from.comparison.chain.family=Extract Set from comparison chain
|
||||
|
||||
Reference in New Issue
Block a user