diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml index 7c598c820145..68a6372705ba 100644 --- a/.idea/inspectionProfiles/idea_default.xml +++ b/.idea/inspectionProfiles/idea_default.xml @@ -911,11 +911,11 @@ - + - + @@ -923,7 +923,7 @@ - + diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/HardCodedPurity.java b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/HardCodedPurity.java index 56e5560f9f09..94989bc35d71 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/HardCodedPurity.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/HardCodedPurity.java @@ -3,7 +3,6 @@ package com.intellij.codeInspection.bytecodeAnalysis; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode; import java.util.Collections; @@ -14,11 +13,11 @@ import java.util.Set; class HardCodedPurity { static final boolean AGGRESSIVE_HARDCODED_PURITY = Registry.is("java.annotations.inference.aggressive.hardcoded.purity", true); - private static final Set thisChangingMethods = ContainerUtil.set( + private static final Set thisChangingMethods = Set.of( new Member("java/lang/Throwable", "fillInStackTrace", "()Ljava/lang/Throwable;") ); // Assumed that all these methods are not only pure, but return object which could be safely modified - private static final Set pureMethods = ContainerUtil.set( + private static final Set pureMethods = Set.of( // Maybe overloaded and be not pure, but this would be definitely bad code style // Used in Throwable(Throwable) ctor, so this helps to infer purity of many exception constructors new Member("java/lang/Throwable", "toString", "()Ljava/lang/String;"), @@ -104,7 +103,7 @@ class HardCodedPurity { } static class AggressiveHardCodedPurity extends HardCodedPurity { - static final Set ITERABLES = ContainerUtil.set("java/lang/Iterable", "java/util/Collection", + static final Set ITERABLES = Set.of("java/lang/Iterable", "java/util/Collection", "java/util/List", "java/util/Set", "java/util/ArrayList", "java/util/HashSet", "java/util/AbstractList", "java/util/AbstractSet", "java/util/TreeSet"); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/OriginalElementPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/OriginalElementPostfixTemplateTest.java index c591aae465f6..a4da78c0744c 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/OriginalElementPostfixTemplateTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/OriginalElementPostfixTemplateTest.java @@ -12,7 +12,6 @@ import com.intellij.psi.PsiExpression; import com.intellij.psi.PsiMethod; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.LazyKt; -import com.intellij.util.containers.ContainerUtil; import kotlin.Lazy; import org.jdom.Element; import org.jetbrains.annotations.Nls; @@ -37,7 +36,7 @@ public class OriginalElementPostfixTemplateTest extends PostfixTemplateTestCase // This emulates conditions in some languages e.g. in go where resolve involves getOriginalElement() calls. PostfixTemplate template = new JavaEditablePostfixTemplate( "myId", "foo", "System.out.println();$END$", "", - ContainerUtil.set(new OriginalElementCondition()), + Set.of(new OriginalElementCondition()), LanguageLevel.JDK_1_8, true, provider); PostfixTemplateStorage.getInstance().setTemplates(provider, asList(template)); } diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/SameKeyPostfixTemplatesTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/SameKeyPostfixTemplatesTest.java index b3aa3660d431..2c0c1117d3ff 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/SameKeyPostfixTemplatesTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/SameKeyPostfixTemplatesTest.java @@ -8,10 +8,11 @@ import com.intellij.codeInsight.template.postfix.templates.editable.JavaEditable import com.intellij.codeInsight.template.postfix.templates.editable.JavaPostfixTemplateExpressionCondition; import com.intellij.pom.java.LanguageLevel; import com.intellij.util.LazyKt; -import com.intellij.util.containers.ContainerUtil; import kotlin.Lazy; import org.jetbrains.annotations.NotNull; +import java.util.Set; + import static java.util.Arrays.asList; public class SameKeyPostfixTemplatesTest extends PostfixTemplateTestCase { @@ -24,11 +25,11 @@ public class SameKeyPostfixTemplatesTest extends PostfixTemplateTestCase { JavaPostfixTemplateProvider provider = PROVIDER.getValue(); PostfixTemplate template1 = new JavaEditablePostfixTemplate( "myId1", "sameKey", "Boolean.toString($EXPR$);$END$", "", - ContainerUtil.set(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateBooleanExpressionCondition()), + Set.of(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateBooleanExpressionCondition()), LanguageLevel.JDK_1_8, true, provider); PostfixTemplate template2 = new JavaEditablePostfixTemplate( "myId2", "sameKey", "Integer.toString($EXPR$);$END$", "", - ContainerUtil.set(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateNumberExpressionCondition()), + Set.of(new JavaPostfixTemplateExpressionCondition.JavaPostfixTemplateNumberExpressionCondition()), LanguageLevel.JDK_1_8, true, provider); PostfixTemplateStorage.getInstance().setTemplates(provider, asList(template1, template2)); } diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeClassSealedPropertyTest.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeClassSealedPropertyTest.java index 1d40697e5280..6d3b1d739beb 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeClassSealedPropertyTest.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeClassSealedPropertyTest.java @@ -25,10 +25,7 @@ import org.jetbrains.jetCheck.ImperativeCommand; import org.jetbrains.jetCheck.IntDistribution; import org.jetbrains.jetCheck.PropertyChecker; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; public class MakeClassSealedPropertyTest extends BaseUnivocityTest { @@ -75,7 +72,8 @@ public class MakeClassSealedPropertyTest extends BaseUnivocityTest { } PsiDocumentManager.getInstance(myProject).commitAllDocuments(); - Set relatedFiles = ContainerUtil.set(psiFile); + Set relatedFiles = new HashSet<>(); + relatedFiles.add(psiFile); DirectClassInheritorsSearch.search(psiClass).mapping(PsiElement::getContainingFile).forEach(e -> { relatedFiles.add(e); return true; diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingsPresentations.java b/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingsPresentations.java index 7df1bb939826..22b44dfd32b4 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingsPresentations.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingsPresentations.java @@ -5,7 +5,6 @@ import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.util.NlsContexts; import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizableOptions; import com.intellij.util.LocaleSensitiveApplicationCacheService; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -28,7 +27,7 @@ final class CodeStyleSettingsPresentations { Map> result = new LinkedHashMap<>(); var customizableOptions = CodeStyleSettingsCustomizableOptions.getInstance(); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.BLANK_LINES_KEEP), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.BLANK_LINES_KEEP), List.of( new CodeStyleSettingPresentation("KEEP_BLANK_LINES_IN_DECLARATIONS", ApplicationBundle.message("editbox.keep.blanklines.in.declarations")), new CodeStyleSettingPresentation("KEEP_BLANK_LINES_IN_CODE", ApplicationBundle.message("editbox.keep.blanklines.in.code")), @@ -38,7 +37,7 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("editbox.keep.blanklines.between.header.and.package")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.BLANK_LINES), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.BLANK_LINES), List.of( new CodeStyleSettingPresentation("BLANK_LINES_BEFORE_PACKAGE", ApplicationBundle.message("editbox.blanklines.before.package.statement")), new CodeStyleSettingPresentation("BLANK_LINES_AFTER_PACKAGE", @@ -67,7 +66,7 @@ final class CodeStyleSettingsPresentations { //-----------------------------------SPACING_SETTINGS----------------------------------------------------- result = new LinkedHashMap<>(); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_BEFORE_PARENTHESES), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_BEFORE_PARENTHESES), List.of( new CodeStyleSettingPresentation("SPACE_BEFORE_METHOD_PARENTHESES", ApplicationBundle.message("checkbox.spaces.method.declaration.parentheses")), new CodeStyleSettingPresentation("SPACE_BEFORE_METHOD_CALL_PARENTHESES", @@ -87,7 +86,7 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("checkbox.spaces.annotation.parameters")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_AROUND_OPERATORS), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_AROUND_OPERATORS), List.of( new CodeStyleSettingPresentation("SPACE_AROUND_ASSIGNMENT_OPERATORS", ApplicationBundle.message("checkbox.spaces.assignment.operators")), new CodeStyleSettingPresentation("SPACE_AROUND_LOGICAL_OPERATORS", @@ -110,7 +109,7 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("checkbox.spaces.around.method.ref.dbl.colon.arrow")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_BEFORE_LEFT_BRACE), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_BEFORE_LEFT_BRACE), List.of( new CodeStyleSettingPresentation("SPACE_BEFORE_CLASS_LBRACE", ApplicationBundle.message("checkbox.spaces.class.left.brace")), new CodeStyleSettingPresentation("SPACE_BEFORE_METHOD_LBRACE", ApplicationBundle.message("checkbox.spaces.method.left.brace")), new CodeStyleSettingPresentation("SPACE_BEFORE_IF_LBRACE", ApplicationBundle.message("checkbox.spaces.if.left.brace")), @@ -131,14 +130,14 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("checkbox.spaces.annotation.array.initializer.left.brace")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_BEFORE_KEYWORD), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_BEFORE_KEYWORD), List.of( new CodeStyleSettingPresentation("SPACE_BEFORE_ELSE_KEYWORD", ApplicationBundle.message("checkbox.spaces.else.keyword")), new CodeStyleSettingPresentation("SPACE_BEFORE_WHILE_KEYWORD", ApplicationBundle.message("checkbox.spaces.while.keyword")), new CodeStyleSettingPresentation("SPACE_BEFORE_CATCH_KEYWORD", ApplicationBundle.message("checkbox.spaces.catch.keyword")), new CodeStyleSettingPresentation("SPACE_BEFORE_FINALLY_KEYWORD", ApplicationBundle.message("checkbox.spaces.finally.keyword")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_WITHIN), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_WITHIN), List.of( new CodeStyleSettingPresentation("SPACE_WITHIN_BRACES", ApplicationBundle.message("checkbox.spaces.within.braces")), new CodeStyleSettingPresentation("SPACE_WITHIN_BRACKETS", ApplicationBundle.message("checkbox.spaces.within.brackets")), new CodeStyleSettingPresentation("SPACE_WITHIN_ARRAY_INITIALIZER_BRACES", @@ -171,7 +170,7 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("checkbox.spaces.annotation.parentheses")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_IN_TERNARY_OPERATOR), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_IN_TERNARY_OPERATOR), List.of( new CodeStyleSettingPresentation("SPACE_BEFORE_QUEST", ApplicationBundle.message("checkbox.spaces.before.question")), new CodeStyleSettingPresentation("SPACE_AFTER_QUEST", ApplicationBundle.message("checkbox.spaces.after.question")), new CodeStyleSettingPresentation("SPACE_BEFORE_COLON", ApplicationBundle.message("checkbox.spaces.before.colon")), @@ -179,20 +178,20 @@ final class CodeStyleSettingsPresentations { )); result - .put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_WITHIN_TYPE_ARGUMENTS), ContainerUtil.immutableList( + .put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_WITHIN_TYPE_ARGUMENTS), List.of( new CodeStyleSettingPresentation("SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS", ApplicationBundle.message("checkbox.spaces.after.comma")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_IN_TYPE_ARGUMENTS), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_IN_TYPE_ARGUMENTS), List.of( new CodeStyleSettingPresentation("SPACE_BEFORE_TYPE_PARAMETER_LIST", ApplicationBundle.message("checkbox.spaces.before.opening.angle.bracket")) )); result - .put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_IN_TYPE_PARAMETERS), ContainerUtil.immutableList()); + .put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_IN_TYPE_PARAMETERS), Collections.emptyList()); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_OTHER), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.SPACES_OTHER), List.of( new CodeStyleSettingPresentation("SPACE_BEFORE_COMMA", ApplicationBundle.message("checkbox.spaces.before.comma")), new CodeStyleSettingPresentation("SPACE_AFTER_COMMA", ApplicationBundle.message("checkbox.spaces.after.comma")), new CodeStyleSettingPresentation("SPACE_BEFORE_SEMICOLON", ApplicationBundle.message("checkbox.spaces.before.semicolon")), @@ -204,7 +203,7 @@ final class CodeStyleSettingsPresentations { //-----------------------------------WRAPPING_AND_BRACES_SETTINGS----------------------------------------------------- result = new LinkedHashMap<>(); - result.put(new CodeStyleSettingPresentation.SettingsGroup(null), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(null), List.of( new CodeStyleBoundedIntegerSettingPresentation("RIGHT_MARGIN", ApplicationBundle.message("editbox.right.margin.columns"), 0, 999, -1, ApplicationBundle.message("settings.code.style.default.general")), @@ -213,7 +212,7 @@ final class CodeStyleSettingsPresentations { new CodeStyleSoftMarginsPresentation() )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_KEEP), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_KEEP), List.of( new CodeStyleSettingPresentation("KEEP_LINE_BREAKS", ApplicationBundle.message("wrapping.keep.line.breaks")), new CodeStyleSettingPresentation("KEEP_FIRST_COLUMN_COMMENT", ApplicationBundle.message("wrapping.keep.comment.at.first.column")), @@ -231,15 +230,15 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("wrapping.keep.simple.classes.in.one.line")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(null), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(null), List.of( new CodeStyleSettingPresentation("WRAP_LONG_LINES", ApplicationBundle.message("wrapping.long.lines")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_COMMENTS), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_COMMENTS), List.of( new CodeStyleSettingPresentation("WRAP_COMMENTS", ApplicationBundle.message("wrapping.comments.wrap.at.right.margin")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_BRACES), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_BRACES), List.of( new CodeStyleSelectSettingPresentation("CLASS_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.class.declaration"), BRACE_PLACEMENT_VALUES, customizableOptions.BRACE_PLACEMENT_OPTIONS), @@ -253,7 +252,7 @@ final class CodeStyleSettingsPresentations { )); putGroupTop(result, "EXTENDS_LIST_WRAP", customizableOptions.WRAPPING_EXTENDS_LIST, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_EXTENDS_LIST), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_EXTENDS_LIST), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_EXTENDS_LIST", ApplicationBundle.message("wrapping.align.when.multiline")) )); @@ -261,7 +260,7 @@ final class CodeStyleSettingsPresentations { customizableOptions.WRAP_OPTIONS_FOR_SINGLETON); putGroupTop(result, "THROWS_LIST_WRAP", customizableOptions.WRAPPING_THROWS_LIST, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_THROWS_LIST), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_THROWS_LIST), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_THROWS_LIST", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("ALIGN_THROWS_KEYWORD", ApplicationBundle.message("wrapping.align.throws.keyword")) )); @@ -271,7 +270,7 @@ final class CodeStyleSettingsPresentations { putGroupTop(result, "METHOD_PARAMETERS_WRAP", customizableOptions.WRAPPING_METHOD_PARAMETERS, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_METHOD_PARAMETERS), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_METHOD_PARAMETERS), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARAMETERS", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.new.line.after.lpar")), @@ -282,7 +281,7 @@ final class CodeStyleSettingsPresentations { putGroupTop(result, "CALL_PARAMETERS_WRAP", customizableOptions.WRAPPING_METHOD_ARGUMENTS_WRAPPING, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_METHOD_ARGUMENTS_WRAPPING), - ContainerUtil.immutableList( + List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARAMETERS_IN_CALLS", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("PREFER_PARAMETERS_WRAP", @@ -293,12 +292,12 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("wrapping.rpar.on.new.line")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_METHOD_PARENTHESES), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_METHOD_PARENTHESES), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_METHOD_BRACKETS", ApplicationBundle.message("wrapping.align.when.multiline")) )); putGroupTop(result, "METHOD_CALL_CHAIN_WRAP", customizableOptions.WRAPPING_CALL_CHAIN, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_CALL_CHAIN), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_CALL_CHAIN), List.of( new CodeStyleSettingPresentation("WRAP_FIRST_METHOD_IN_CALL_CHAIN", ApplicationBundle.message("wrapping.chained.method.call.first.on.new.line")), new CodeStyleSettingPresentation("ALIGN_MULTILINE_CHAINED_METHODS", ApplicationBundle.message("wrapping.align.when.multiline")), @@ -306,7 +305,7 @@ final class CodeStyleSettingsPresentations { new CodeStyleSettingPresentation("KEEP_BUILDER_METHODS_INDENTS", ApplicationBundle.message("wrapping.builder.methods.keep.indents")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_IF_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_IF_STATEMENT), List.of( new CodeStyleSelectSettingPresentation("IF_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES, customizableOptions.BRACE_OPTIONS), new CodeStyleSettingPresentation("ELSE_ON_NEW_LINE", ApplicationBundle.message("wrapping.else.on.new.line")), @@ -315,7 +314,7 @@ final class CodeStyleSettingsPresentations { )); putGroupTop(result, "FOR_STATEMENT_WRAP", customizableOptions.WRAPPING_FOR_STATEMENT, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_FOR_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_FOR_STATEMENT), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_FOR", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("FOR_STATEMENT_LPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.new.line.after.lpar")), @@ -324,18 +323,18 @@ final class CodeStyleSettingsPresentations { customizableOptions.BRACE_OPTIONS) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_WHILE_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_WHILE_STATEMENT), List.of( new CodeStyleSelectSettingPresentation("WHILE_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES, customizableOptions.BRACE_OPTIONS) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_DOWHILE_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_DOWHILE_STATEMENT), List.of( new CodeStyleSelectSettingPresentation("DOWHILE_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES, customizableOptions.BRACE_OPTIONS), new CodeStyleSettingPresentation("WHILE_ON_NEW_LINE", ApplicationBundle.message("wrapping.while.on.new.line")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_SWITCH_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_SWITCH_STATEMENT), List.of( new CodeStyleSettingPresentation("INDENT_CASE_FROM_SWITCH", ApplicationBundle.message("wrapping.indent.case.from.switch")), new CodeStyleSettingPresentation("INDENT_BREAK_FROM_CASE", ApplicationBundle.message("wrapping.indent.break.from.case")), new CodeStyleSettingPresentation("CASE_STATEMENT_ON_NEW_LINE", ApplicationBundle.message("wrapping.case.statements.on.one.line")) @@ -343,21 +342,21 @@ final class CodeStyleSettingsPresentations { putGroupTop(result, "RESOURCE_LIST_WRAP", customizableOptions.WRAPPING_TRY_RESOURCE_LIST, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_TRY_RESOURCE_LIST), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_TRY_RESOURCE_LIST), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_RESOURCES", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("RESOURCE_LIST_LPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.new.line.after.lpar")), new CodeStyleSettingPresentation("RESOURCE_LIST_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_TRY_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_TRY_STATEMENT), List.of( new CodeStyleSettingPresentation("CATCH_ON_NEW_LINE", ApplicationBundle.message("wrapping.catch.on.new.line")), new CodeStyleSettingPresentation("FINALLY_ON_NEW_LINE", ApplicationBundle.message("wrapping.finally.on.new.line")) )); putGroupTop(result, "BINARY_OPERATION_WRAP", customizableOptions.WRAPPING_BINARY_OPERATION, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_BINARY_OPERATION), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_BINARY_OPERATION), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_BINARY_OPERATION", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("BINARY_OPERATION_SIGN_ON_NEXT_LINE", @@ -370,14 +369,14 @@ final class CodeStyleSettingsPresentations { )); putGroupTop(result, "ASSIGNMENT_WRAP", customizableOptions.WRAPPING_ASSIGNMENT, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_ASSIGNMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_ASSIGNMENT), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_ASSIGNMENT", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.assignment.sign.on.next.line")) )); result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_FIELDS_VARIABLES_GROUPS), - ContainerUtil.immutableList( + List.of( new CodeStyleSettingPresentation("ALIGN_GROUP_FIELD_DECLARATIONS", ApplicationBundle.message("wrapping.align.fields.in.columns")), new CodeStyleSettingPresentation("ALIGN_CONSECUTIVE_VARIABLE_DECLARATIONS", @@ -390,7 +389,7 @@ final class CodeStyleSettingsPresentations { putGroupTop(result, "TERNARY_OPERATION_WRAP", customizableOptions.WRAPPING_TERNARY_OPERATION, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_TERNARY_OPERATION), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_TERNARY_OPERATION), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_TERNARY_OPERATION", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("TERNARY_OPERATION_SIGNS_ON_NEXT_LINE", @@ -399,7 +398,7 @@ final class CodeStyleSettingsPresentations { putGroupTop(result, "ARRAY_INITIALIZER_WRAP", customizableOptions.WRAPPING_ARRAY_INITIALIZER, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_ARRAY_INITIALIZER), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_ARRAY_INITIALIZER), List.of( new CodeStyleSettingPresentation("ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION", ApplicationBundle.message("wrapping.align.when.multiline")), new CodeStyleSettingPresentation("ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE", @@ -408,13 +407,13 @@ final class CodeStyleSettingsPresentations { ApplicationBundle.message("wrapping.rbrace.on.new.line")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_MODIFIER_LIST), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_MODIFIER_LIST), List.of( new CodeStyleSettingPresentation("MODIFIER_LIST_WRAP", ApplicationBundle.message("wrapping.after.modifier.list")) )); putGroupTop(result, "ASSERT_STATEMENT_WRAP", customizableOptions.WRAPPING_ASSERT_STATEMENT, WRAP_VALUES, customizableOptions.WRAP_OPTIONS); - result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_ASSERT_STATEMENT), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(customizableOptions.WRAPPING_ASSERT_STATEMENT), List.of( new CodeStyleSettingPresentation("ASSERT_STATEMENT_COLON_ON_NEXT_LINE", ApplicationBundle.message("wrapping.colon.signs.on.next.line")) )); @@ -436,22 +435,22 @@ final class CodeStyleSettingsPresentations { //-----------------------------------INDENT_SETTINGS----------------------------------------------------- result = new LinkedHashMap<>(); - result.put(new CodeStyleSettingPresentation.SettingsGroup(null), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(null), List.of( new CodeStyleSettingPresentation("INDENT_SIZE", ApplicationBundle.message("editbox.indent.indent")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(null), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(null), List.of( new CodeStyleSettingPresentation("CONTINUATION_INDENT_SIZE", ApplicationBundle.message("editbox.indent.continuation.indent")) )); - result.put(new CodeStyleSettingPresentation.SettingsGroup(null), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(null), List.of( new CodeStyleSettingPresentation("TAB_SIZE", ApplicationBundle.message("editbox.indent.tab.size")) )); myIndentStandardSettings = Collections.unmodifiableMap(result); } - private static void putGroupTop(@NotNull Map> result, + private static void putGroupTop(@NotNull Map> result, @NotNull String fieldName, @NlsContexts.Label @NotNull String uiName, int[] values, String[] valueUiNames) { - result.put(new CodeStyleSettingPresentation.SettingsGroup(null), ContainerUtil.immutableList( + result.put(new CodeStyleSettingPresentation.SettingsGroup(null), List.of( new CodeStyleSelectSettingPresentation(fieldName, uiName, values, valueUiNames) )); } diff --git a/platform/platform-tests/testSrc/com/intellij/ui/tree/TreeUtilVisitTest.java b/platform/platform-tests/testSrc/com/intellij/ui/tree/TreeUtilVisitTest.java index c9db59041602..1eda256cc5a2 100644 --- a/platform/platform-tests/testSrc/com/intellij/ui/tree/TreeUtilVisitTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ui/tree/TreeUtilVisitTest.java @@ -13,6 +13,7 @@ import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -25,7 +26,6 @@ import java.util.stream.Stream; import static com.intellij.ui.tree.TreePathUtil.convertArrayToTreePath; import static com.intellij.ui.tree.TreeTestUtil.node; -import static com.intellij.util.containers.ContainerUtil.set; public final class TreeUtilVisitTest { @Before @@ -794,13 +794,13 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedPaths() { - testCollectExpandedPaths(set("Root", "1", "2", "22", "3", "33", "333"), test + testCollectExpandedPaths(Set.of("Root", "1", "2", "22", "3", "33", "333"), test -> TreeUtil.collectExpandedPaths(test.getTree())); } @Test public void testCollectExpandedPathsUnderCollapsed11() { - testCollectExpandedPaths(set(), test -> { + testCollectExpandedPaths(Collections.emptySet(),test -> { TreePath root = test.getTree().getPathForRow(2); // 11 return TreeUtil.collectExpandedPaths(test.getTree(), root); }); @@ -808,7 +808,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedPathsWithInvisibleRootUnderInvisibleRoot() { - testCollectExpandedPaths(set("1", "2", "22", "3", "33", "333"), test -> { + testCollectExpandedPaths(Set.of("1", "2", "22", "3", "33", "333"), test -> { TreePath root = test.getTree().getPathForRow(0); // Root test.getTree().setRootVisible(false); return TreeUtil.collectExpandedPaths(test.getTree(), root); @@ -817,7 +817,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedPathsWithInvisibleRoot() { - testCollectExpandedPaths(set("1", "2", "22", "3", "33", "333"), test -> { + testCollectExpandedPaths(Set.of("1", "2", "22", "3", "33", "333"), test -> { test.getTree().setRootVisible(false); return TreeUtil.collectExpandedPaths(test.getTree()); }); @@ -825,7 +825,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedPathsWithInvisibleRootUnder33() { - testCollectExpandedPaths(set("33", "333"), test -> { + testCollectExpandedPaths(Set.of("33", "333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(14); // 33 return TreeUtil.collectExpandedPaths(test.getTree(), root); @@ -834,7 +834,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedPathsWithInvisibleRootUnder333() { - testCollectExpandedPaths(set("333"), test -> { + testCollectExpandedPaths(Set.of("333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(17); // 333 return TreeUtil.collectExpandedPaths(test.getTree(), root); @@ -852,13 +852,13 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedUserObjects() { - testCollectExpandedUserObjects(set("Root", "1", "2", "22", "3", "33", "333"), test + testCollectExpandedUserObjects(Set.of("Root", "1", "2", "22", "3", "33", "333"), test -> TreeUtil.collectExpandedUserObjects(test.getTree())); } @Test public void testCollectExpandedUserObjectsWithCollapsedPath() { - testCollectExpandedUserObjects(set("Root", "1", "2", "22", "3"), test -> { + testCollectExpandedUserObjects(Set.of("Root", "1", "2", "22", "3"), test -> { test.getTree().collapseRow(15); // 33 return TreeUtil.collectExpandedUserObjects(test.getTree()); }); @@ -875,7 +875,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectExpandedUserObjectsWithCollapsedPath333Under33() { - testCollectExpandedUserObjects(set("33"), test -> { + testCollectExpandedUserObjects(Set.of("33"), test -> { test.getTree().collapseRow(18); // 333 TreePath root = test.getTree().getPathForRow(15); // 33 return TreeUtil.collectExpandedUserObjects(test.getTree(), root); @@ -893,13 +893,13 @@ public final class TreeUtilVisitTest { @Test public void testCollectSelectedPaths() { - testCollectSelectedPaths(set("11", "222", "33", "3331", "3332", "3333", "Root"), test + testCollectSelectedPaths(Set.of("11", "222", "33", "3331", "3332", "3333", "Root"), test -> TreeUtil.collectSelectedPaths(test.getTree())); } @Test public void testCollectSelectedPathsWithInvisibleRoot() { - testCollectSelectedPaths(set("11", "222", "33", "3331", "3332", "3333"), test -> { + testCollectSelectedPaths(Set.of("11", "222", "33", "3331", "3332", "3333"), test -> { test.getTree().setRootVisible(false); return TreeUtil.collectSelectedPaths(test.getTree()); }); @@ -907,7 +907,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectSelectedPathsWithInvisibleRootUnder33() { - testCollectSelectedPaths(set("33", "3331", "3332", "3333"), test -> { + testCollectSelectedPaths(Set.of("33", "3331", "3332", "3333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(14); // 33 return TreeUtil.collectSelectedPaths(test.getTree(), root); @@ -916,7 +916,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectSelectedPathsWithInvisibleRootUnder333() { - testCollectSelectedPaths(set("3331", "3332", "3333"), test -> { + testCollectSelectedPaths(Set.of("3331", "3332", "3333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(17); // 333 return TreeUtil.collectSelectedPaths(test.getTree(), root); @@ -934,13 +934,13 @@ public final class TreeUtilVisitTest { @Test public void testCollectSelectedUserObjects() { - testCollectSelectedUserObjects(set("11", "222", "33", "3331", "3332", "3333", "Root"), test + testCollectSelectedUserObjects(Set.of("11", "222", "33", "3331", "3332", "3333", "Root"), test -> TreeUtil.collectSelectedUserObjects(test.getTree())); } @Test public void testCollectSelectedUserObjectsWithCollapsedPath() { - testCollectSelectedUserObjects(set("11", "222", "33", "Root"), test -> { + testCollectSelectedUserObjects(Set.of("11", "222", "33", "Root"), test -> { test.getTree().collapseRow(15); // 33 return TreeUtil.collectSelectedUserObjects(test.getTree()); }); @@ -948,7 +948,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectSelectedUserObjectsWithCollapsedPathUnder33() { - testCollectSelectedUserObjects(set("33"), test -> { + testCollectSelectedUserObjects(Set.of("33"), test -> { test.getTree().collapseRow(15); // 33 TreePath root = test.getTree().getPathForRow(15); // 33 return TreeUtil.collectSelectedUserObjects(test.getTree(), root); @@ -958,7 +958,7 @@ public final class TreeUtilVisitTest { @Test public void testCollectSelectedUserObjectsWithCollapsedPathUnder333() { // collapsed parent node becomes selected if it contains selected children - testCollectSelectedUserObjects(set("333"), test -> { + testCollectSelectedUserObjects(Set.of("333"), test -> { test.getTree().collapseRow(18); // 333 TreePath root = test.getTree().getPathForRow(18); // 333 return TreeUtil.collectSelectedUserObjects(test.getTree(), root); diff --git a/platform/platform-tests/testSrc/com/intellij/util/io/PersistentMapTest.java b/platform/platform-tests/testSrc/com/intellij/util/io/PersistentMapTest.java index bc82c9ae32da..94397c5e6201 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/io/PersistentMapTest.java +++ b/platform/platform-tests/testSrc/com/intellij/util/io/PersistentMapTest.java @@ -82,24 +82,24 @@ public class PersistentMapTest extends PersistentMapTestBase { assertEquals("AAA_VALUE", myMap.get("AAA")); assertNull(myMap.get("BBB")); - assertEquals(ContainerUtil.set("AAA"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); + assertEquals(Set.of("AAA"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); assertEquals(1, getMapSize()); myMap.put("BBB", "BBB_VALUE"); assertEquals("BBB_VALUE", myMap.get("BBB")); - assertEquals(ContainerUtil.set("AAA", "BBB"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); + assertEquals(Set.of("AAA", "BBB"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); assertEquals(2, getMapSize()); myMap.put("AAA", "ANOTHER_AAA_VALUE"); assertEquals("ANOTHER_AAA_VALUE", myMap.get("AAA")); - assertEquals(ContainerUtil.set("AAA", "BBB"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); + assertEquals(Set.of("AAA", "BBB"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); assertEquals(2, getMapSize()); myMap.remove("AAA"); assertEquals(1, getMapSize()); assertNull(myMap.get("AAA")); assertEquals("BBB_VALUE", myMap.get("BBB")); - assertEquals(ContainerUtil.set("BBB"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); + assertEquals(Set.of("BBB"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); myMap.remove("BBB"); assertNull(myMap.get("AAA")); @@ -110,7 +110,7 @@ public class PersistentMapTest extends PersistentMapTestBase { myMap.put("AAA", "FINAL_AAA_VALUE"); assertEquals("FINAL_AAA_VALUE", myMap.get("AAA")); assertNull(myMap.get("BBB")); - assertEquals(ContainerUtil.set("AAA"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); + assertEquals(Set.of("AAA"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); assertEquals(1, getMapSize()); } @@ -417,7 +417,7 @@ public class PersistentMapTest extends PersistentMapTestBase { assertEquals("AAA_VALUE", myMap.get("AAA")); assertNull(myMap.get("BBB")); - assertEquals(ContainerUtil.set("AAA"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); + assertEquals(Set.of("AAA"), new HashSet<>(myMap.getAllKeysWithExistingMapping())); try { myMap.remove("AAA"); diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index d911ebaf4d7c..2c0f83ca3a6c 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -24,7 +24,6 @@ import java.util.stream.Stream; * @see CollectionFactory * @see com.intellij.concurrency.ConcurrentCollectionFactory */ -@ApiStatus.NonExtendable public final class ContainerUtil { private static final int INSERTION_SORT_THRESHOLD = 10; @@ -93,10 +92,12 @@ public final class ContainerUtil { /** * @deprecated Use {@link LinkedList#LinkedList()} + + * DO NOT REMOVE this method until {@link ContainerUtil#newLinkedList(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. */ @Contract(pure = true) @Deprecated - @ApiStatus.ScheduledForRemoval public static @NotNull LinkedList newLinkedList() { return new LinkedList<>(); } @@ -111,6 +112,9 @@ public final class ContainerUtil { /** * @deprecated Use {@link ArrayList#ArrayList()} + + * DO NOT REMOVE this method until {@link ContainerUtil#newArrayList(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. */ @Deprecated @Contract(pure = true) @@ -118,6 +122,9 @@ public final class ContainerUtil { return new ArrayList<>(); } + /** + * Please use {@link List#of(Object[])} or {@link Arrays#asList(Object[])} instead as more immutable + */ @SafeVarargs @Contract(pure = true) public static @NotNull ArrayList newArrayList(E @NotNull ... array) { @@ -230,6 +237,9 @@ public final class ContainerUtil { /** * @deprecated Use {@link HashSet#HashSet()} + + * DO NOT REMOVE this method until {@link ContainerUtil#newHashSet(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. */ @Contract(pure = true) @Deprecated @@ -285,6 +295,9 @@ public final class ContainerUtil { /** * @deprecated Use {@link LinkedHashSet#LinkedHashSet()} + + * DO NOT REMOVE this method until {@link ContainerUtil#newLinkedHashSet(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. */ @Contract(pure = true) @Deprecated @@ -415,6 +428,32 @@ public final class ContainerUtil { return new ImmutableListBackedByArray<>(array); } + /** + * @deprecated use {@link Collections#emptyList()} + + * DO NOT REMOVE this method until {@link ContainerUtil#immutableList(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. + */ + @Contract(pure = true) + @Deprecated + @Unmodifiable + public static @NotNull List immutableList() { + return Collections.emptyList(); + } + + /** + * @deprecated use {@link List#of(Object)} or {@link Collections#singletonList(Object)} as more memory-consious alternatives + + * DO NOT REMOVE this method until {@link ContainerUtil#immutableList(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. + */ + @Contract(pure = true) + @Deprecated + @Unmodifiable + public static @NotNull List immutableList(E element) { + return Collections.singletonList(element); + } + /** * @return unmodifiable list (mutation methods throw UnsupportedOperationException) which contains {@code element}. * This collection doesn't contain {@code modCount} field, unlike the {@link Collections#singletonList(Object)}, so it might be useful in extremely space-conscious places. @@ -1979,8 +2018,36 @@ public final class ContainerUtil { return result; } - @SafeVarargs + /** + * @deprecated use {@link Collections#emptySet()} + + * DO NOT REMOVE this method until {@link ContainerUtil#set(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. + */ + @Deprecated @Contract(pure = true) + @Unmodifiable + public static @NotNull Set set() { + return Collections.emptySet(); + } + + /** + * @deprecated use {@link Collections#singleton(Object)} + + * DO NOT REMOVE this method until {@link ContainerUtil#set(Object[])} is removed. + * The former method is here to highlight incorrect usages of the latter. + */ + @Deprecated + @Contract(pure = true) + @Unmodifiable + public static @NotNull Set set(T t) { + return Collections.singleton(t); + } + + /** + * please use {@link Set#of(Object[])} instead + */ + @SafeVarargs public static @NotNull Set set(T @NotNull ... items) { //noinspection SSBasedInspection return new HashSet<>(Arrays.asList(items)); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index 5ef56cbd5cc4..1a37274f7e26 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -89,7 +89,6 @@ import static com.intellij.openapi.vcs.changes.ui.ChangesTree.GROUP_BY_ACTION_GR import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.LOCAL_CHANGES; import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.getToolWindowFor; import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManagerKt.isCommitToolWindowShown; -import static com.intellij.util.containers.ContainerUtil.set; import static com.intellij.util.ui.JBUI.Panels.simplePanel; import static java.util.Arrays.asList; import static org.jetbrains.concurrency.Promises.cancelledPromise; @@ -830,7 +829,7 @@ public class ChangesViewManager implements ChangesViewEx, } public void setGrouping(@NotNull String groupingKey) { - myView.getGroupingSupport().setGroupingKeysOrSkip(set(groupingKey)); + myView.getGroupingSupport().setGroupingKeysOrSkip(Set.of(groupingKey)); } public void selectFile(@Nullable VirtualFile vFile) { diff --git a/plugins/gradle/native/src/project/GradleNativeProjectResolver.java b/plugins/gradle/native/src/project/GradleNativeProjectResolver.java index 360d63d3aa89..6e4b7905c9c9 100644 --- a/plugins/gradle/native/src/project/GradleNativeProjectResolver.java +++ b/plugins/gradle/native/src/project/GradleNativeProjectResolver.java @@ -9,7 +9,6 @@ import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceTyp import com.intellij.openapi.externalSystem.model.project.ModuleData; import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; import com.intellij.openapi.externalSystem.util.Order; -import com.intellij.util.containers.ContainerUtil; import org.gradle.tooling.model.DomainObjectSet; import org.gradle.tooling.model.Task; import org.gradle.tooling.model.cpp.CppExecutable; @@ -67,13 +66,13 @@ public final class GradleNativeProjectResolver extends AbstractProjectResolverEx @NotNull @Override public Set> getExtraProjectModelClasses() { - return ContainerUtil.set(org.gradle.tooling.model.cpp.CppProject.class, CppProject.class); + return Set.of(org.gradle.tooling.model.cpp.CppProject.class, CppProject.class); } @NotNull @Override public Set> getToolingExtensionsClasses() { - return ContainerUtil.set( + return Set.of( // native-gradle-tooling jar CppModelBuilder.class ); @@ -81,7 +80,7 @@ public final class GradleNativeProjectResolver extends AbstractProjectResolverEx @Override public Set> getTargetTypes() { - return ContainerUtil.set( + return Set.of( org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppExecutable.class, org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppSharedLibrary.class, org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppStaticLibrary.class diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java index 04e018d21526..d9d3660fb568 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java @@ -16,7 +16,6 @@ import com.intellij.openapi.roots.CompilerProjectExtension; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.util.SmartList; -import com.intellij.util.containers.ContainerUtil; import org.gradle.initialization.BuildLayoutParameters; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -138,7 +137,7 @@ public class GradleAutoImportAware implements ExternalSystemAutoImportAware { // add gradle scripts Set subProjectPaths = projectSettings != null && /*!projectSettings.getModules().isEmpty() &&*/ FileUtil.pathsEqual(projectSettings.getExternalProjectPath(), projectPath) - ? projectSettings.getModules() : ContainerUtil.set(projectPath); + ? projectSettings.getModules() : Set.of(projectPath); for (String path : subProjectPaths) { ProgressManager.checkCanceled(); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/LibraryDataNodeSubstitutor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/LibraryDataNodeSubstitutor.java index e73978eb305f..542e3651b4fe 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/LibraryDataNodeSubstitutor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/LibraryDataNodeSubstitutor.java @@ -83,7 +83,7 @@ public class LibraryDataNodeSubstitutor { if (sourceTypePair == null) { moduleId = artifactsMap.get(path); if (moduleId != null) { - targetModuleOutputPaths = ContainerUtil.set(path); + targetModuleOutputPaths = Set.of(path); } } else { diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java index f9ea8378cfe7..a1e4e2ddc01f 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java @@ -59,7 +59,6 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static com.intellij.util.containers.ContainerUtil.set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assume.assumeThat; @@ -150,7 +149,7 @@ public abstract class AbstractModelBuilderTest { boolean isCompositeBuildsSupported = _gradleVersion.compareTo(GradleVersion.version("3.1")) >= 0; final ProjectImportAction projectImportAction = new ProjectImportAction(false, isCompositeBuildsSupported); projectImportAction.addProjectImportModelProvider(new ClassSetImportModelProvider(getModels(), - ContainerUtil.>set(IdeaProject.class))); + Collections.>singleton(IdeaProject.class))); BuildActionExecuter buildActionExecutor = connection.action(projectImportAction); GradleExecutionSettings executionSettings = new GradleExecutionSettings(null, null, DistributionType.BUNDLED, false); GradleExecutionHelper.attachTargetPathMapperInitScript(executionSettings); @@ -184,7 +183,7 @@ public abstract class AbstractModelBuilderTest { @NotNull public static Set> getToolingExtensionClasses() { - return set( + return ContainerUtil.set( // external-system-rt.jar ExternalSystemSourceType.class, // gradle-tooling-extension-api jar diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java index 80e0d9df9075..6365aa650bae 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java @@ -26,6 +26,7 @@ import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions; import org.junit.Test; import java.io.File; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -91,6 +92,6 @@ public class ModelBuildScriptClasspathBuilderImplTest extends AbstractModelBuild @Override protected Set> getModels() { - return ContainerUtil.>set(BuildScriptClasspathModel.class); + return Collections.>singleton(BuildScriptClasspathModel.class); } } diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java index f7d60f100e17..b5761040708e 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java @@ -25,6 +25,7 @@ import org.jetbrains.plugins.gradle.model.scala.ScalaCompileOptions; import org.jetbrains.plugins.gradle.model.scala.ScalaModel; import org.junit.Test; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -62,6 +63,6 @@ public class ScalaModelBuilderImplTest extends AbstractModelBuilderTest { @Override protected Set> getModels() { - return ContainerUtil.>set(ScalaModel.class); + return Collections.>singleton(ScalaModel.class); } } diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java index f682bc1ce8f4..8d1e3381ac95 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.model.web.WebConfiguration; import org.junit.Test; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -71,6 +72,6 @@ public class WebConfigurationBuilderImplTest extends AbstractModelBuilderTest { @Override protected Set> getModels() { - return ContainerUtil.>set(WebConfiguration.class); + return Collections.>singleton(WebConfiguration.class); } } diff --git a/plugins/kotlin/base/obsolete-compat/src/org/jetbrains/kotlin/idea/core/KotlinFileTypeFactoryUtils.java b/plugins/kotlin/base/obsolete-compat/src/org/jetbrains/kotlin/idea/core/KotlinFileTypeFactoryUtils.java index dc9441af59bc..7d690f942fca 100644 --- a/plugins/kotlin/base/obsolete-compat/src/org/jetbrains/kotlin/idea/core/KotlinFileTypeFactoryUtils.java +++ b/plugins/kotlin/base/obsolete-compat/src/org/jetbrains/kotlin/idea/core/KotlinFileTypeFactoryUtils.java @@ -2,7 +2,6 @@ package org.jetbrains.kotlin.idea.core; import com.intellij.openapi.fileTypes.FileType; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.kotlin.idea.KotlinFileType; import java.util.Set; @@ -13,5 +12,5 @@ import java.util.Set; @Deprecated public class KotlinFileTypeFactoryUtils { public final static String[] KOTLIN_EXTENSIONS = new String[] { "kt", "kts" }; - public final static Set KOTLIN_FILE_TYPES_SET = ContainerUtil.set(KotlinFileType.INSTANCE); + public final static Set KOTLIN_FILE_TYPES_SET = Set.of(KotlinFileType.INSTANCE); } diff --git a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtUsefulTestCase.java b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtUsefulTestCase.java index 78e6999cda77..695c9fe5050d 100644 --- a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtUsefulTestCase.java +++ b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtUsefulTestCase.java @@ -669,7 +669,7 @@ public abstract class KtUsefulTestCase extends TestCase { if (collection.size() != checkers.length) { Assert.fail(toString(collection)); } - Set> checkerSet = ContainerUtil.set(checkers); + Set> checkerSet = ContainerUtil.newHashSet(checkers); int i = 0; Throwable lastError = null; for (final T actual : collection) { diff --git a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/language/LombokConfigCompletionContributor.java b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/language/LombokConfigCompletionContributor.java index 7931dd206fc5..2a8414aa8d75 100644 --- a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/language/LombokConfigCompletionContributor.java +++ b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/language/LombokConfigCompletionContributor.java @@ -6,7 +6,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.patterns.PsiJavaPatterns; import com.intellij.psi.PsiElement; import com.intellij.util.ProcessingContext; -import com.intellij.util.containers.ContainerUtil; import de.plushnikov.intellij.plugin.language.psi.LombokConfigProperty; import de.plushnikov.intellij.plugin.language.psi.LombokConfigPsiUtil; import de.plushnikov.intellij.plugin.language.psi.LombokConfigTypes; @@ -15,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.HashSet; +import java.util.Set; public class LombokConfigCompletionContributor extends CompletionContributor { @@ -23,7 +23,7 @@ public class LombokConfigCompletionContributor extends CompletionContributor { private static final String LOMBOK_ACCESSORS_JAVA_BEANS_SPEC_CAPITALIZATION = ConfigKey.ACCESSORS_JAVA_BEANS_SPEC_CAPITALIZATION.getConfigKey(); public LombokConfigCompletionContributor() { - final Collection booleanOptions = ContainerUtil.set( + final Collection booleanOptions = Set.of( ConfigKey.CONFIG_STOP_BUBBLING.getConfigKey(), ConfigKey.ACCESSORS_CHAIN.getConfigKey(), ConfigKey.ACCESSORS_FLUENT.getConfigKey(), ConfigKey.ACCESSORS_MAKE_FINAL.getConfigKey(), @@ -38,7 +38,7 @@ public class LombokConfigCompletionContributor extends CompletionContributor { ConfigKey.FIELDDEFAULTS_FINAL.getConfigKey(), ConfigKey.FIELDDEFAULTS_PRIVATE.getConfigKey(), ConfigKey.NO_ARGS_CONSTRUCTOR_EXTRA_PRIVATE.getConfigKey()); - final Collection flagUsageOptions = ContainerUtil.set( + final Collection flagUsageOptions = Set.of( "lombok.accessors.flagUsage", "lombok.allArgsConstructor.flagUsage", "lombok.anyConstructor.flagUsage", "lombok.builder.flagUsage", "lombok.cleanup.flagUsage", "lombok.data.flagUsage", "lombok.delegate.flagUsage", "lombok.equalsAndHashCode.flagUsage", "lombok.experimental.flagUsage", "lombok.extensionMethod.flagUsage", @@ -51,9 +51,9 @@ public class LombokConfigCompletionContributor extends CompletionContributor { "lombok.synchronized.flagUsage", "lombok.toString.flagUsage", "lombok.val.flagUsage", "lombok.value.flagUsage", "lombok.wither.flagUsage"); - final Collection flagUsageAllowable = ContainerUtil.set("lombok.var.flagUsage"); + final Collection flagUsageAllowable = Set.of("lombok.var.flagUsage"); - final Collection otherOptions = ContainerUtil.set( + final Collection otherOptions = Set.of( ConfigKey.ACCESSORS_PREFIX.getConfigKey(), LOMBOK_ACCESSORS_JAVA_BEANS_SPEC_CAPITALIZATION, ConfigKey.COPYABLE_ANNOTATIONS.getConfigKey(), ConfigKey.LOG_FIELDNAME.getConfigKey(), ConfigKey.LOG_CUSTOM_DECLARATION.getConfigKey(), diff --git a/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java b/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java index 56f79e086e05..6176d8d772aa 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java @@ -21,7 +21,6 @@ import com.intellij.ide.DataManager; import com.intellij.openapi.editor.actionSystem.EditorActionManager; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PlatformTestUtil; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.io.File; @@ -31,7 +30,7 @@ import java.util.Set; * @author Maxim.Mossienko */ public class XmlPerformanceTest extends LightQuickFixTestCase { - private final Set ourTestsWithFolding = ContainerUtil.set("IndentUnindent2"); + private final Set ourTestsWithFolding = Set.of("IndentUnindent2"); @Override protected String getBasePath() {