reverted SafeVarargs because of Oracle license restrictions

This commit is contained in:
Alexey Kudravtsev
2014-02-13 13:07:43 +04:00
parent 0383adf4ab
commit 9edcbfe944
58 changed files with 33 additions and 197 deletions
@@ -83,7 +83,6 @@ public final class MethodChainsSearchUtil {
return false;
}
@SafeVarargs
public static <T> HashSet<T> unionToHashSet(final Collection<T> collection, final T... items) {
final HashSet<T> result = new HashSet<T>();
result.addAll(collection);
@@ -156,7 +156,6 @@ public class MethodsChain {
return false;
}
@SafeVarargs
private static Set<String> joinSets(final Set<String>... sets) {
final Set<String> result = new HashSet<String>();
for (final Set<String> set : sets) {
@@ -178,7 +178,6 @@ public class ChainCompletionContext {
return myNotDeprecatedMethodsResolver.get(methodIncompleteSignature);
}
@SafeVarargs
private static <T> HashSet<T> unionToHashSet(final Collection<T>... collections) {
final HashSet<T> res = new HashSet<T>();
for (final Collection<T> set : collections) {
@@ -43,7 +43,6 @@ public abstract class InspectionValidator {
private final String myProgressIndicatorText;
private final Class<? extends LocalInspectionTool>[] myInspectionToolClasses;
@SafeVarargs
protected InspectionValidator(@NotNull final String description, @NotNull final String progressIndicatorText, final Class<? extends LocalInspectionTool>... inspectionToolClasses) {
myDescription = description;
myProgressIndicatorText = progressIndicatorText;
@@ -482,7 +482,6 @@ public class CreateFromUsageUtils {
});
}
@SafeVarargs
public static PsiReferenceExpression[] collectExpressions(final PsiExpression expression, Class<? extends PsiElement>... scopes) {
PsiElement parent = PsiTreeUtil.getParentOfType(expression, scopes);
@@ -32,8 +32,7 @@ public class AnnotatedElementsSearch extends ExtensibleQueryFactory<PsiModifierL
private final SearchScope myScope;
private final Class<? extends PsiModifierListOwner>[] myTypes;
@SafeVarargs
public Parameters(final PsiClass annotationClass, final SearchScope scope, @NotNull Class<? extends PsiModifierListOwner>... types) {
public Parameters(final PsiClass annotationClass, final SearchScope scope, Class<? extends PsiModifierListOwner>... types) {
myAnnotationClass = annotationClass;
myScope = scope;
myTypes = types;
@@ -47,19 +46,16 @@ public class AnnotatedElementsSearch extends ExtensibleQueryFactory<PsiModifierL
return myScope;
}
@NotNull
public Class<? extends PsiModifierListOwner>[] getTypes() {
return myTypes;
}
}
@SafeVarargs
private static Query<PsiModifierListOwner> createDelegateQuery(PsiClass annotationClass, SearchScope scope, @NotNull Class<? extends PsiModifierListOwner>... types) {
private static Query<PsiModifierListOwner> createDelegateQuery(PsiClass annotationClass, SearchScope scope, Class<? extends PsiModifierListOwner>... types) {
return INSTANCE.createQuery(new Parameters(annotationClass, scope, types));
}
@SafeVarargs
public static <T extends PsiModifierListOwner> Query<T> searchElements(@NotNull PsiClass annotationClass, @NotNull SearchScope scope, @NotNull Class<? extends T>... types) {
public static <T extends PsiModifierListOwner> Query<T> searchElements(@NotNull PsiClass annotationClass, @NotNull SearchScope scope, Class<? extends T>... types) {
return new InstanceofQuery<T>(createDelegateQuery(annotationClass, scope, types), types);
}
@@ -49,8 +49,7 @@ public class PsiJavaPatterns extends StandardPatterns{
return new PsiJavaElementPattern.Capture<T>(aClass);
}
@SafeVarargs
public static PsiJavaElementPattern.Capture<PsiElement> psiElement(@NotNull final Class<? extends PsiElement>... classAlternatives) {
public static PsiJavaElementPattern.Capture<PsiElement> psiElement(final Class<? extends PsiElement>... classAlternatives) {
return new PsiJavaElementPattern.Capture<PsiElement>(new InitialPatternCondition<PsiElement>(PsiElement.class) {
@Override
public boolean accepts(@Nullable Object o, ProcessingContext context) {
@@ -28,8 +28,7 @@ public class PsiMethodCallPattern extends PsiExpressionPattern<PsiMethodCallExpr
super(PsiMethodCallExpression.class);
}
@SafeVarargs
public final PsiMethodCallPattern withArguments(final ElementPattern<? extends PsiExpression>... arguments) {
public PsiMethodCallPattern withArguments(final ElementPattern<? extends PsiExpression>... arguments) {
return with(new PatternCondition<PsiMethodCallExpression>("withArguments") {
@Override
public boolean accepts(@NotNull PsiMethodCallExpression callExpression, ProcessingContext context) {
@@ -159,8 +159,7 @@ public abstract class AbstractLayoutCodeProcessorTest extends PsiTestCase {
EditorFactory.getInstance().releaseEditor(editor);
}
@SafeVarargs
protected final void checkFormationAndImportsOptimizationFor(@NotNull List<PsiFile>... fileCollection) {
protected void checkFormationAndImportsOptimizationFor(@NotNull List<PsiFile>... fileCollection) {
for (List<PsiFile> files : fileCollection) {
for (PsiFile file : files) {
String className = getClassNameFromJavaFile(file);
@@ -169,8 +168,7 @@ public abstract class AbstractLayoutCodeProcessorTest extends PsiTestCase {
}
}
@SafeVarargs
protected final void checkNoProcessingWasPerformedOn(@NotNull List<PsiFile>... fileCollections) {
protected void checkNoProcessingWasPerformedOn(@NotNull List<PsiFile>... fileCollections) {
for (List<PsiFile> files : fileCollections) {
for (PsiFile file : files) {
String className = getClassNameFromJavaFile(file);
@@ -179,8 +177,7 @@ public abstract class AbstractLayoutCodeProcessorTest extends PsiTestCase {
}
}
@SafeVarargs
protected final void checkRearrangeReformatAndOptimizeImportsHappend(@NotNull List<PsiFile>... fileCollections) {
protected void checkRearrangeReformatAndOptimizeImportsHappend(@NotNull List<PsiFile>... fileCollections) {
for (List<PsiFile> files : fileCollections) {
for (PsiFile file : files) {
String className = getClassNameFromJavaFile(file);
@@ -191,7 +191,6 @@ public class IndexTest extends IdeaTestCase {
}
*/
@SafeVarargs
private static <T> void assertDataEquals(List<T> actual, T... expected) {
assertTrue(new HashSet<T>(Arrays.asList(expected)).equals(new HashSet<T>(actual)));
}
@@ -89,7 +89,6 @@ public abstract class ObjectPattern<T, Self extends ObjectPattern<T, Self>> impl
});
}
@SuppressWarnings("unchecked")
@NotNull
public Self oneOf(final T... values) {
final Collection<T> list;
@@ -42,8 +42,7 @@ public abstract class TreeElementPattern<ParentType, T extends ParentType, Self
protected abstract ParentType[] getChildren(@NotNull final ParentType parentType);
@SafeVarargs
public final Self withParents(@NotNull final Class<? extends ParentType>... types) {
public Self withParents(@NotNull final Class<? extends ParentType>... types) {
return with(new PatternCondition<T>("withParents") {
@Override
public boolean accepts(@NotNull T t, ProcessingContext context) {
@@ -171,8 +170,7 @@ public abstract class TreeElementPattern<ParentType, T extends ParentType, Self
* @param strict
* @return Ensures that first elements in hierarchy accepted by patterns appear in specified order
*/
@SafeVarargs
public final Self insideSequence(final boolean strict, @NotNull final ElementPattern<? extends ParentType>... patterns) {
public Self insideSequence(final boolean strict, @NotNull final ElementPattern<? extends ParentType>... patterns) {
return with(new PatternCondition<T>("insideSequence") {
public boolean accepts(@NotNull final T t, final ProcessingContext context) {
int i = 0;
@@ -222,9 +222,8 @@ public class PsiTreeUtil {
* @param <T> type to cast found element to.
* @return first found element, or null if nothing found.
*/
@SafeVarargs
@Nullable
@Contract("null, _ -> null")
@Contract("null, _, _ -> null")
public static <T extends PsiElement> T findChildOfAnyType(@Nullable final PsiElement element, @NotNull final Class<? extends T>... classes) {
return findChildOfAnyType(element, true, classes);
}
@@ -238,7 +237,6 @@ public class PsiTreeUtil {
* @param <T> type to cast found element to.
* @return first found element, or null if nothing found.
*/
@SafeVarargs
@Nullable
@Contract("null, _, _ -> null")
public static <T extends PsiElement> T findChildOfAnyType(@Nullable final PsiElement element,
@@ -265,7 +263,6 @@ public class PsiTreeUtil {
return findChildrenOfAnyType(element, aClass);
}
@SafeVarargs
@NotNull
public static <T extends PsiElement> Collection<T> findChildrenOfAnyType(@Nullable final PsiElement element,
@NotNull final Class<? extends T>... classes) {
@@ -380,7 +377,6 @@ public class PsiTreeUtil {
* @return the element, or null if none was found.
* @since 5.1
*/
@SafeVarargs
@Nullable
@Contract("null, _ -> null")
public static <T extends PsiElement> T getChildOfAnyType(@Nullable PsiElement element, @NotNull Class<? extends T>... classes) {
@@ -470,7 +466,6 @@ public class PsiTreeUtil {
return getParentOfType(element, parentClass);
}
@SafeVarargs
@Nullable
@Contract("null, _, _, _ -> null")
public static <T extends PsiElement> T getContextOfType(@Nullable PsiElement element,
@@ -499,13 +494,11 @@ public class PsiTreeUtil {
return getContextOfType(element, strict, aClass);
}
@SafeVarargs
@Nullable
public static <T extends PsiElement> T getContextOfType(@Nullable PsiElement element, @NotNull Class<? extends T>... classes) {
return getContextOfType(element, true, classes);
}
@SafeVarargs
@Nullable
@Contract("null, _, _ -> null")
public static <T extends PsiElement> T getContextOfType(@Nullable PsiElement element,
@@ -544,7 +537,6 @@ public class PsiTreeUtil {
return null;
}
@SafeVarargs
@Nullable
@Contract("null, _, _, _ -> null")
public static <T extends PsiElement> T getParentOfType(@Nullable PsiElement element,
@@ -602,7 +594,6 @@ public class PsiTreeUtil {
return null;
}
@SafeVarargs
@Nullable
@Contract("null, _ -> null")
public static <T extends PsiElement> T getParentOfType(@Nullable final PsiElement element,
@@ -613,7 +604,6 @@ public class PsiTreeUtil {
return getNonStrictParentOfType(parent, classes);
}
@SafeVarargs
@Nullable
@Contract("null, _ -> null")
public static <T extends PsiElement> T getNonStrictParentOfType(@Nullable final PsiElement element,
@@ -638,7 +628,6 @@ public class PsiTreeUtil {
return processor.toArray();
}
@SafeVarargs
@NotNull
public static <T extends PsiElement> Collection<T> collectElementsOfType(@Nullable final PsiElement element,
@NotNull final Class<T>... classes) {
@@ -790,7 +779,6 @@ public class PsiTreeUtil {
return result;
}
@SafeVarargs
@Nullable
public static <T extends PsiElement> T findElementOfClassAtOffsetWithStopSet(@NotNull PsiFile file,
int offset,
@@ -32,7 +32,6 @@ import java.util.Iterator;
public class ArrayQuery<T> implements Query<T> {
private final T[] myArray;
@SafeVarargs
public ArrayQuery(@NotNull T... array) {
myArray = array;
}
@@ -26,7 +26,6 @@ public class InstanceofQuery<T> implements Query<T> {
private final Class<? extends T>[] myClasses;
private final Query<?> myDelegate;
@SafeVarargs
public InstanceofQuery(Query<?> delegate, Class<? extends T>... aClasses) {
myClasses = aClasses;
myDelegate = delegate;
@@ -119,7 +119,6 @@ public abstract class PlatformIdTableBuilding {
private static class CompositeTodoIndexer implements DataIndexer<TodoIndexEntry, Integer, FileContent> {
private final DataIndexer<TodoIndexEntry, Integer, FileContent>[] indexers;
@SafeVarargs
public CompositeTodoIndexer(@NotNull DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) {
this.indexers = indexers;
}
@@ -27,10 +27,9 @@ import java.net.URL;
public abstract class AbstractAction {
private static final Logger LOG = Logger.getInstance(AbstractAction.class.getName());
private static final String SERVER_URL = Registry.get("frameworks.download.libraries.server.url").asString();
private static String SERVER_URL = Registry.get("frameworks.download.libraries.server.url").asString();
private Pair<String, String>[] myParams;
@SafeVarargs
protected AbstractAction(Pair<String, String>... params) {
myParams = params;
}
@@ -40,7 +40,6 @@ public class ParameterInfoUtils {
return findParentOfTypeWithStopElements(file, offset, parentClass);
}
@SafeVarargs
@Nullable
public static <T extends PsiElement> T findParentOfTypeWithStopElements (PsiFile file, int offset, Class<T> parentClass, @NotNull Class<? extends PsiElement>... stopAt) {
PsiElement element = file.findElementAt(offset);
@@ -34,7 +34,6 @@ public class SemKey<T extends SemElement> {
private final SemKey<? super T>[] mySupers;
private final int myUniqueId;
@SafeVarargs
private SemKey(String debugName, SemKey<? super T>... supers) {
myDebugName = debugName;
mySupers = supers;
@@ -60,7 +59,6 @@ public class SemKey<T extends SemElement> {
return myDebugName;
}
@SafeVarargs
public static <T extends SemElement> SemKey<T> createKey(String debugName, SemKey<? super T>... supers) {
return new SemKey<T>(debugName, supers);
}
@@ -69,8 +67,7 @@ public class SemKey<T extends SemElement> {
return myUniqueId;
}
@SafeVarargs
public final <K extends T> SemKey<K> subKey(@NonNls String debugName, SemKey<? super T>... otherSupers) {
public <K extends T> SemKey<K> subKey(@NonNls String debugName, SemKey<? super T>... otherSupers) {
if (otherSupers.length == 0) {
return new SemKey<K>(debugName, this);
}
@@ -196,7 +196,6 @@ public class CompletionServiceImpl extends CompletionService{
}
}
@SafeVarargs
public static boolean assertPhase(Class<? extends CompletionPhase>... possibilities) {
if (!isPhase(possibilities)) {
LOG.error(ourPhase + "; set at " + ourPhaseTrace);
@@ -205,7 +204,6 @@ public class CompletionServiceImpl extends CompletionService{
return true;
}
@SafeVarargs
public static boolean isPhase(Class<? extends CompletionPhase>... possibilities) {
CompletionPhase phase = getCompletionPhase();
for (Class<? extends CompletionPhase> possibility : possibilities) {
@@ -41,7 +41,6 @@ public abstract class ChooseOneOrAllRunnable<T extends PsiElement> implements Ru
myTitle = title;
}
@SuppressWarnings("unchecked")
protected abstract void selected(T... classes);
@Override
@@ -86,7 +86,6 @@ public abstract class RunManagerEx extends RunManager {
@NotNull
public abstract Map<String, List<RunnerAndConfigurationSettings>> getStructure(@NotNull ConfigurationType type);
@SafeVarargs
public static void disableTasks(Project project, RunConfiguration settings, Key<? extends BeforeRunTask>... keys) {
for (Key<? extends BeforeRunTask> key : keys) {
List<? extends BeforeRunTask> tasks = getInstanceEx(project).getBeforeRunTasks(settings, key);
@@ -96,7 +95,6 @@ public abstract class RunManagerEx extends RunManager {
}
}
@SafeVarargs
public static int getTasksCount(Project project, RunConfiguration settings, Key<? extends BeforeRunTask>... keys) {
int result = 0;
for (Key<? extends BeforeRunTask> key : keys) {
@@ -176,8 +176,7 @@ public abstract class SmartEnterProcessorWithFixers extends SmartEnterProcessor
ContainerUtil.addAllNotNull(myEnterProcessors, processors);
}
@SafeVarargs
protected final void addFixers(Fixer<? extends SmartEnterProcessorWithFixers>... fixers) {
protected void addFixers(Fixer<? extends SmartEnterProcessorWithFixers>... fixers) {
ContainerUtil.addAllNotNull(myFixers, fixers);
}
@@ -38,7 +38,6 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
this((Collection<? extends T>)items);
}
@SafeVarargs
public CollectionListModel(final T... items) {
myItems = ContainerUtilRt.newArrayList(items);
}
@@ -84,8 +84,7 @@ public class SyncScrollSupport implements Disposable {
new Pair<FragmentSide, EditingSides>(FragmentSide.SIDE2, sideContainers[0]));
}
@SafeVarargs
private final void addSlavesScroller(Editor editor, Pair<FragmentSide, EditingSides>... contexts) {
private void addSlavesScroller(Editor editor, Pair<FragmentSide, EditingSides>... contexts) {
ScrollListener scroller = new ScrollListener(contexts, editor);
scroller.install();
myScrollers.add(scroller);
@@ -138,12 +138,10 @@ public abstract class LocalHistoryTestCase extends Assert {
return v.getChanges();
}
@SafeVarargs
public static <T> T[] array(T... objects) {
return objects;
}
@SafeVarargs
public static <T> List<T> list(T... objects) {
return Arrays.asList(objects);
}
@@ -91,7 +91,6 @@ public class ChunkGraphTest extends GraphTestCase {
}
}
@SafeVarargs
private static <T> Set<T> toSet(T... strings) {
return new HashSet<T>(Arrays.asList(strings));
}
@@ -384,12 +384,10 @@ public abstract class UsefulTestCase extends TestCase {
return builder.toString();
}
@SafeVarargs
public static <T> void assertOrderedEquals(T[] actual, T... expected) {
assertOrderedEquals(Arrays.asList(actual), expected);
}
@SafeVarargs
public static <T> void assertOrderedEquals(Iterable<T> actual, T... expected) {
assertOrderedEquals(null, actual, expected);
}
@@ -403,7 +401,6 @@ public abstract class UsefulTestCase extends TestCase {
}
}
@SafeVarargs
public static <T> void assertOrderedEquals(final String errorMsg, @NotNull Iterable<T> actual, @NotNull T... expected) {
Assert.assertNotNull(actual);
Assert.assertNotNull(expected);
@@ -429,18 +426,15 @@ public abstract class UsefulTestCase extends TestCase {
}
}
@SafeVarargs
public static <T> void assertOrderedCollection(T[] collection, @NotNull Consumer<T>... checkers) {
Assert.assertNotNull(collection);
assertOrderedCollection(Arrays.asList(collection), checkers);
}
@SafeVarargs
public static <T> void assertSameElements(T[] collection, T... expected) {
assertSameElements(Arrays.asList(collection), expected);
}
@SafeVarargs
public static <T> void assertSameElements(Collection<? extends T> collection, T... expected) {
assertSameElements(collection, Arrays.asList(expected));
}
@@ -458,8 +452,7 @@ public abstract class UsefulTestCase extends TestCase {
}
}
@SafeVarargs
public final <T> void assertContainsOrdered(Collection<? extends T> collection, T... expected) {
public <T> void assertContainsOrdered(Collection<? extends T> collection, T... expected) {
assertContainsOrdered(collection, Arrays.asList(expected));
}
@@ -469,8 +462,7 @@ public abstract class UsefulTestCase extends TestCase {
assertOrderedEquals(toString(collection), copy, expected);
}
@SafeVarargs
public final <T> void assertContainsElements(Collection<? extends T> collection, T... expected) {
public <T> void assertContainsElements(Collection<? extends T> collection, T... expected) {
assertContainsElements(collection, Arrays.asList(expected));
}
@@ -484,8 +476,7 @@ public abstract class UsefulTestCase extends TestCase {
return toString(Arrays.asList(collection), separator);
}
@SafeVarargs
public final <T> void assertDoesntContain(Collection<? extends T> collection, T... notExpected) {
public <T> void assertDoesntContain(Collection<? extends T> collection, T... notExpected) {
assertDoesntContain(collection, Arrays.asList(notExpected));
}
@@ -515,7 +506,6 @@ public abstract class UsefulTestCase extends TestCase {
return builder.toString();
}
@SafeVarargs
public static <T> void assertOrderedCollection(Collection<? extends T> collection, Consumer<T>... checkers) {
Assert.assertNotNull(collection);
if (collection.size() != checkers.length) {
@@ -534,12 +524,10 @@ public abstract class UsefulTestCase extends TestCase {
}
}
@SafeVarargs
public static <T> void assertUnorderedCollection(T[] collection, Consumer<T>... checkers) {
assertUnorderedCollection(Arrays.asList(collection), checkers);
}
@SafeVarargs
public static <T> void assertUnorderedCollection(Collection<? extends T> collection, Consumer<T>... checkers) {
Assert.assertNotNull(collection);
if (collection.size() != checkers.length) {
@@ -598,7 +586,6 @@ public abstract class UsefulTestCase extends TestCase {
return ts[0];
}
@SafeVarargs
public static <T> void assertOneOf(T value, T... values) {
boolean found = false;
for (T v : values) {
@@ -226,7 +226,6 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
*/
void enableInspections(@NotNull InspectionProfileEntry... inspections);
@SuppressWarnings("unchecked")
void enableInspections(@NotNull Class<? extends LocalInspectionTool>... inspections);
void enableInspections(@NotNull Collection<Class<? extends LocalInspectionTool>> inspections);
@@ -264,9 +264,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
return myPsiManager != null;
}
@SafeVarargs
@Override
public final void enableInspections(@NotNull final Class<? extends LocalInspectionTool>... inspections) {
public void enableInspections(@NotNull final Class<? extends LocalInspectionTool>... inspections) {
enableInspections(Arrays.asList(inspections));
}
@@ -18,7 +18,6 @@ package com.intellij.openapi.util;
import com.intellij.reference.SoftReference;
import com.intellij.util.ArrayUtilRt;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
@@ -44,8 +43,7 @@ public class Conditions {
};
}
@SafeVarargs
public static <T> Condition<T> oneOf(@NotNull final T... options) {
public static <T> Condition<T> oneOf(final T... options) {
return new Condition<T>() {
@Override
public boolean value(T t) {
@@ -107,7 +107,6 @@ public class ContainerUtilRt {
return new LinkedList<T>();
}
@SafeVarargs
@NotNull
public static <T> LinkedList<T> newLinkedList(@NotNull T... elements) {
final LinkedList<T> list = newLinkedList();
@@ -125,7 +124,6 @@ public class ContainerUtilRt {
return new ArrayList<T>();
}
@SafeVarargs
@NotNull
public static <T> ArrayList<T> newArrayList(@NotNull T... elements) {
ArrayList<T> list = newArrayListWithCapacity(elements.length);
@@ -170,7 +168,6 @@ public class ContainerUtilRt {
return new com.intellij.util.containers.HashSet<T>(initialCapacity);
}
@SafeVarargs
@NotNull
public static <T> HashSet<T> newHashSet(@NotNull T... elements) {
return new com.intellij.util.containers.HashSet<T>(Arrays.asList(elements));
@@ -197,7 +194,6 @@ public class ContainerUtilRt {
return new com.intellij.util.containers.LinkedHashSet<T>();
}
@SafeVarargs
@NotNull
public static <T> LinkedHashSet<T> newLinkedHashSet(@NotNull T... elements) {
return newLinkedHashSet(Arrays.asList(elements));
@@ -217,7 +213,6 @@ public class ContainerUtilRt {
return new TreeSet<T>();
}
@SafeVarargs
@NotNull
public static <T> TreeSet<T> newTreeSet(@NotNull T... elements) {
TreeSet<T> set = newTreeSet();
@@ -245,7 +240,6 @@ public class ContainerUtilRt {
return new Stack<T>(elements);
}
@SafeVarargs
@NotNull
public static <T> Stack<T> newStack(@NotNull T... initial) {
return new Stack<T>(Arrays.asList(initial));
@@ -15,7 +15,6 @@
*/
package com.intellij.util.containers;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -37,8 +36,7 @@ public class Stack<T> extends ArrayList<T> {
super(init);
}
@SafeVarargs
public Stack(@NotNull T... items) {
public Stack(T... items) {
for (T item : items) {
push(item);
}
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package java.lang;
import java.lang.annotation.*;
@Deprecated
/**
as soon as we migrate jdk7+, remove this
see also {@link com.intellij.Patches.USE_REFLECTION_TO_ACCESS_JDK7}
retention changed to source because it is not the real SafeVarargs, it's just a stub to be compilation-compatible with jdk7
*/
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
public @interface SafeVarargs {
}
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.util;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -39,8 +38,7 @@ public class MultiValuesMap<K, V>{
}
}
@SafeVarargs
public final void putAll(K key, @NotNull V... values) {
public void putAll(K key, V... values) {
for (V value : values) {
put(key, value);
}
@@ -20,7 +20,6 @@ package com.intellij.util;
*/
public interface ArrayConsumer<T> extends Consumer<T[]>{
@SuppressWarnings("unchecked")
@Override
void consume(final T... ts);
}
@@ -38,7 +38,6 @@ public class ContainerUtil extends ContainerUtilRt {
private static final int INSERTION_SORT_THRESHOLD = 10;
private static final int DEFAULT_CONCURRENCY_LEVEL = Math.min(16, Runtime.getRuntime().availableProcessors());
@SafeVarargs
@NotNull
public static <T> T[] ar(@NotNull T... elements) {
return elements;
@@ -54,7 +53,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newHashMap(map);
}
@SafeVarargs
@NotNull
public static <K, V> Map<K, V> newHashMap(@NotNull Pair<K, V> first, Pair<K, V>... entries) {
return ContainerUtilRt.newHashMap(first, entries);
@@ -85,9 +83,8 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newLinkedHashMap(map);
}
@SafeVarargs
@NotNull
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(@NotNull Pair<K, V> first, @NotNull Pair<K, V>... entries) {
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(@NotNull Pair<K, V> first, Pair<K, V>... entries) {
return ContainerUtilRt.newLinkedHashMap(first, entries);
}
@@ -128,7 +125,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newLinkedList();
}
@SafeVarargs
@NotNull
public static <T> LinkedList<T> newLinkedList(@NotNull T... elements) {
return ContainerUtilRt.newLinkedList(elements);
@@ -144,7 +140,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newArrayList();
}
@SafeVarargs
@NotNull
public static <E> ArrayList<E> newArrayList(@NotNull E... array) {
return ContainerUtilRt.newArrayList(array);
@@ -193,7 +188,6 @@ public class ContainerUtil extends ContainerUtilRt {
return new SmartList<T>(element);
}
@SafeVarargs
@NotNull
public static <T> List<T> newSmartList(@NotNull T... elements) {
return new SmartList<T>(elements);
@@ -209,7 +203,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newHashSet(initialCapacity);
}
@SafeVarargs
@NotNull
public static <T> HashSet<T> newHashSet(@NotNull T... elements) {
return ContainerUtilRt.newHashSet(elements);
@@ -241,7 +234,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newLinkedHashSet(elements);
}
@SafeVarargs
@NotNull
public static <T> LinkedHashSet<T> newLinkedHashSet(@NotNull T... elements) {
return ContainerUtilRt.newLinkedHashSet(elements);
@@ -257,13 +249,11 @@ public class ContainerUtil extends ContainerUtilRt {
return new THashSet<T>(strategy);
}
@SafeVarargs
@NotNull
public static <T> THashSet<T> newTroveSet(@NotNull T... elements) {
return newTroveSet(Arrays.asList(elements));
}
@SafeVarargs
@NotNull
public static <T> THashSet<T> newTroveSet(@NotNull TObjectHashingStrategy<T> strategy, @NotNull T... elements) {
return new THashSet<T>(Arrays.asList(elements), strategy);
@@ -308,7 +298,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newTreeSet(elements);
}
@SafeVarargs
@NotNull
public static <T> TreeSet<T> newTreeSet(@NotNull T... elements) {
return ContainerUtilRt.newTreeSet(elements);
@@ -375,13 +364,11 @@ public class ContainerUtil extends ContainerUtilRt {
return result;
}
@SafeVarargs
@NotNull
public static <E> Set<E> immutableSet(@NotNull E ... elements) {
return Collections.unmodifiableSet(new THashSet<E>(Arrays.asList(elements)));
}
@SafeVarargs
@NotNull
public static <E> ImmutableList<E> immutableList(@NotNull E ... array) {
return new ImmutableListBackedByArray<E>(array);
@@ -809,7 +796,6 @@ public class ContainerUtil extends ContainerUtilRt {
return result.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : result.toNativeArray();
}
@SafeVarargs
@NotNull
public static <T> List<T> filter(@NotNull Condition<? super T> condition, @NotNull T... collection) {
return findAll(collection, condition);
@@ -1027,7 +1013,6 @@ public class ContainerUtil extends ContainerUtilRt {
}
}
@SafeVarargs
@NotNull
public static <T, A extends T, C extends Collection<T>> C addAll(@NotNull C collection, @NotNull A... elements) {
//noinspection ManualArrayToCollectionCopy
@@ -1040,7 +1025,6 @@ public class ContainerUtil extends ContainerUtilRt {
/**
* Adds all not-null elements from the {@code elements}, ignoring nulls
*/
@SafeVarargs
@NotNull
public static <T, A extends T, C extends Collection<T>> C addAllNotNull(@NotNull C collection, @NotNull A... elements) {
for (T element : elements) {
@@ -1051,7 +1035,6 @@ public class ContainerUtil extends ContainerUtilRt {
return collection;
}
@SafeVarargs
public static <T> boolean removeAll(@NotNull Collection<T> collection, @NotNull T... elements) {
boolean modified = false;
for (T element : elements) {
@@ -1110,9 +1093,8 @@ public class ContainerUtil extends ContainerUtilRt {
* @param appendTail specify whether additional values should be appended in front or after the list
* @return read-only list consisting of the elements from specified list with some additional values
*/
@SafeVarargs
@NotNull
public static <T> List<T> concat(boolean appendTail, @NotNull List<? extends T> list, @NotNull T... values) {
public static <T> List<T> concat(boolean appendTail, @NotNull List<? extends T> list, T... values) {
return appendTail ? concat(list, list(values)) : concat(list(values), list);
}
@@ -1141,7 +1123,6 @@ public class ContainerUtil extends ContainerUtilRt {
};
}
@SafeVarargs
@NotNull
public static <T> Iterable<T> concat(@NotNull final Iterable<? extends T>... iterables) {
return new Iterable<T>() {
@@ -1158,7 +1139,6 @@ public class ContainerUtil extends ContainerUtilRt {
};
}
@SafeVarargs
@NotNull
public static <T> Iterator<T> concatIterators(@NotNull Iterator<T>... iterators) {
return new SequenceIterator<T>(iterators);
@@ -1169,7 +1149,6 @@ public class ContainerUtil extends ContainerUtilRt {
return new SequenceIterator<T>(iterators);
}
@SafeVarargs
@NotNull
public static <T> Iterable<T> concat(@NotNull final T[]... iterables) {
return new Iterable<T>() {
@@ -1189,7 +1168,6 @@ public class ContainerUtil extends ContainerUtilRt {
/**
* @return read-only list consisting of the lists added together
*/
@SafeVarargs
@NotNull
public static <T> List<T> concat(@NotNull final List<? extends T>... lists) {
int size = 0;
@@ -1550,7 +1528,6 @@ public class ContainerUtil extends ContainerUtilRt {
/**
* @return read-only list consisting of the elements with nulls filtered out
*/
@SafeVarargs
@NotNull
public static <T> List<T> packNullables(@NotNull T... elements) {
List<T> list = new ArrayList<T>();
@@ -1586,7 +1563,6 @@ public class ContainerUtil extends ContainerUtilRt {
return result.toArray(emptyArray);
}
@SafeVarargs
@NotNull
public static <T> Set<T> set(@NotNull T ... items) {
return newHashSet(items);
@@ -1689,7 +1665,6 @@ public class ContainerUtil extends ContainerUtilRt {
return items.subList(0, items.size() - 1);
}
@SafeVarargs
@NotNull
public static <T> List<T> list(@NotNull T... items) {
return Arrays.asList(items);
@@ -1972,7 +1947,6 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newStack(initial);
}
@SafeVarargs
@NotNull
public static <T> Stack<T> newStack(@NotNull T... initial) {
return ContainerUtilRt.newStack(initial);
@@ -17,7 +17,6 @@ package com.intellij.util.containers;
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@@ -62,8 +61,7 @@ public class OpenTHashSet<T> extends THashSet<T> {
super(ts, strategy);
}
@SafeVarargs
public OpenTHashSet(final TObjectHashingStrategy<T> strategy, @NotNull T... ts) {
public OpenTHashSet(final TObjectHashingStrategy<T> strategy, final T... ts) {
super(Arrays.asList(ts), strategy);
}
@@ -25,7 +25,6 @@ public class SequenceIterator<T> implements Iterator<T> {
private final Iterator<T>[] myIterators;
private int myCurrentIndex;
@SafeVarargs
public SequenceIterator(@NotNull Iterator<T>... iterators){
myIterators = new Iterator[iterators.length];
System.arraycopy(iterators, 0, myIterators, 0, iterators.length);
@@ -21,7 +21,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.util.Consumer;
import com.intellij.util.concurrency.Semaphore;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.LinkedList;
@@ -42,7 +41,7 @@ public class ConcurrentTasks<T> {
final EmptyProgressIndicator pi = new EmptyProgressIndicator() {
@Override
public void checkCanceled() {
if (myResultKnown || myParentIndicator != null && myParentIndicator.isCanceled()) {
if (myResultKnown || (myParentIndicator != null) && myParentIndicator.isCanceled()) {
super.cancel();
}
super.checkCanceled();
@@ -92,7 +91,7 @@ public class ConcurrentTasks<T> {
}
// in it possible to even interrupt() threads involved, but at the moment it's better for tasks themselves to check cancel status
for (Future<?> future : futures) {
if (!future.isCancelled() && !future.isDone()) {
if ((! future.isCancelled() && (! future.isDone()))) {
future.cancel(true);
}
}
@@ -106,8 +105,7 @@ public class ConcurrentTasks<T> {
return myResult;
}
@SafeVarargs
public ConcurrentTasks(final ProgressIndicator parentIndicator, @NotNull Consumer<Consumer<T>>... tasks) {
public ConcurrentTasks(final ProgressIndicator parentIndicator, final Consumer<Consumer<T>>... tasks) {
myParentIndicator = parentIndicator;
myTasks = Arrays.asList(tasks);
mySemaphore = new Semaphore();
@@ -149,7 +149,6 @@ public abstract class BaseInspection extends BaseJavaBatchLocalInspectionTool {
return null;
}
@SafeVarargs
protected static void parseString(String string, List<String>... outs) {
final List<String> strings = StringUtil.split(string, ",");
for (List<String> out : outs) {
@@ -169,7 +168,6 @@ public abstract class BaseInspection extends BaseJavaBatchLocalInspectionTool {
}
}
@SafeVarargs
protected static String formatString(List<String>... strings) {
final StringBuilder buffer = new StringBuilder();
final int size = strings[0].size();
@@ -257,7 +257,6 @@ public class IfCanBeSwitchInspection extends BaseInspection {
}
}
@SafeVarargs
@Nullable
public static <T extends PsiElement> T getPrevSiblingOfType(@Nullable PsiElement element, @NotNull Class<T> aClass,
@NotNull Class<? extends PsiElement>... stopAt) {
@@ -133,7 +133,6 @@ public class ReplaceIfWithSwitchIntention extends Intention {
}
}
@SafeVarargs
@Nullable
public static <T extends PsiElement> T getPrevSiblingOfType(@Nullable PsiElement element, @NotNull Class<T> aClass,
@NotNull Class<? extends PsiElement>... stopAt) {
@@ -34,8 +34,7 @@ public class GroovyMethodCallPattern extends GroovyExpressionPattern<GrCallExpre
super(GrCallExpression.class);
}
@SafeVarargs
public final GroovyMethodCallPattern withArguments(final ElementPattern<? extends GrExpression>... arguments) {
public GroovyMethodCallPattern withArguments(final ElementPattern<? extends GrExpression>... arguments) {
return with(new PatternCondition<GrCallExpression>("withArguments") {
@Override
public boolean accepts(@NotNull GrCallExpression callExpression, ProcessingContext context) {
@@ -392,7 +392,6 @@ public class ResolveUtil {
return resolveExistingElement(place, processor, PsiClass.class);
}
@SafeVarargs
@Nullable
public static <T> T resolveExistingElement(PsiElement place, ResolverProcessor processor, Class<? extends T>... classes) {
treeWalkUp(place, processor, true);
@@ -504,17 +504,14 @@ public abstract class MavenTestCase extends UsefulTestCase {
new SetWithToString<String>(new THashSet<String>(actual, FileUtil.PATH_HASHING_STRATEGY)));
}
@SafeVarargs
protected static <T> void assertUnorderedElementsAreEqual(T[] actual, T... expected) {
assertUnorderedElementsAreEqual(Arrays.asList(actual), expected);
}
@SafeVarargs
protected static <T> void assertUnorderedElementsAreEqual(Collection<T> actual, T... expected) {
assertUnorderedElementsAreEqual(actual, Arrays.asList(expected));
}
@SafeVarargs
protected static <T, U> void assertOrderedElementsAreEqual(Collection<U> actual, T... expected) {
String s = "\nexpected: " + Arrays.asList(expected) + "\nactual: " + new ArrayList<U>(actual);
assertEquals(s, expected.length, actual.size());
@@ -527,13 +524,11 @@ public abstract class MavenTestCase extends UsefulTestCase {
}
}
@SafeVarargs
protected static <T> void assertContain(List<? extends T> actual, T... expected) {
List<T> expectedList = Arrays.asList(expected);
assertTrue("expected: " + expectedList + "\n" + "actual: " + actual.toString(), actual.containsAll(expectedList));
}
@SafeVarargs
protected static <T> void assertDoNotContain(List<T> actual, T... expected) {
List<T> actualCopy = new ArrayList<T>(actual);
actualCopy.removeAll(Arrays.asList(expected));
@@ -102,7 +102,6 @@ public class GenericRepositoryUtil {
return StringUtil.capitalizeWords(prettyName, true);
}
@SafeVarargs
public static <T> List<T> concat(List<? extends T> list, T... values) {
return ContainerUtil.concat(true, list, values);
}
@@ -295,7 +295,6 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
return findAfterCaret(node, PyStatement.class);
}
@SafeVarargs
private static PsiElement findBeforeCaret(ASTNode atCaret, Class<? extends PsiElement>... classes) {
while (atCaret != null) {
atCaret = TreeUtil.prevLeaf(atCaret);
@@ -306,7 +305,6 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
return null;
}
@SafeVarargs
private static PsiElement findAfterCaret(ASTNode atCaret, Class<? extends PsiElement>... classes) {
while (atCaret != null) {
if (atCaret.getElementType() != TokenType.WHITE_SPACE) {
@@ -317,7 +315,6 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
return null;
}
@SafeVarargs
@Nullable
private static <T extends PsiElement> T getNonStrictParentOfType(@NotNull PsiElement element, @NotNull Class<? extends T>... classes) {
PsiElement run = element;
@@ -693,7 +693,6 @@ public class PyPackageManagerImpl extends PyPackageManager {
myExceptionCache = null;
}
@SafeVarargs
private static <T> List<T> list(T... xs) {
return Arrays.asList(xs);
}
@@ -1003,7 +1003,6 @@ public class PyUtil {
* @param variants things to search among
* @return true iff what.equals() one of the variants.
*/
@SafeVarargs
public static <T> boolean among(@NotNull T what, T... variants) {
for (T s : variants) {
if (what.equals(s)) return true;
@@ -100,7 +100,6 @@ public class PyRequirementTest extends PyTestCase {
PyRequirement.fromString("git+git://github.com/django/django.git@stable/1.5.x"));
}
@SafeVarargs
private static <T> List<T> list(T... xs) {
return Arrays.asList(xs);
}
@@ -44,8 +44,7 @@ public class PyCodeFragmentTest extends LightMarkedTestCase {
final private String END_MARKER = "<end>";
final private String RESULT_MARKER = "<result>";
@SafeVarargs
private final void doTest(Pair<String, String>... files2Create) throws Exception {
private void doTest(Pair<String, String>... files2Create) throws Exception {
final String testName = getTestName(false).toLowerCase();
final String fullPath = getTestDataPath() + testName + ".test";
@@ -131,8 +131,7 @@ public class NavigationGutterIconBuilder<T> {
return setTargets(ContainerUtil.createMaybeSingletonList(target));
}
@SafeVarargs
public final NavigationGutterIconBuilder<T> setTargets(@NotNull T... targets) {
public NavigationGutterIconBuilder<T> setTargets(@NotNull T... targets) {
return setTargets(Arrays.asList(targets));
}
@@ -200,8 +200,7 @@ public class ModelMergerImpl implements ModelMerger {
myMergingStrategyClasses.add(aClass);
}
@SafeVarargs
public final <T> T mergeModels(final Class<T> aClass, final T... implementations) {
public <T> T mergeModels(final Class<T> aClass, final T... implementations) {
if (implementations.length == 1) return implementations[0];
final MergingInvocationHandler<T> handler = new MergingInvocationHandler<T>(aClass, Arrays.asList(implementations));
return _mergeModels(aClass, handler, implementations);
@@ -212,8 +211,7 @@ public class ModelMergerImpl implements ModelMerger {
}
@SafeVarargs
private final <T> T _mergeModels(final Class<? super T> aClass, final MergingInvocationHandler<T> handler, final T... implementations) {
private <T> T _mergeModels(final Class<? super T> aClass, final MergingInvocationHandler<T> handler, final T... implementations) {
final Set<Class> commonClasses = getCommonClasses(new THashSet<Class>(), implementations);
commonClasses.add(MERGED_OBJECT_CLASS);
commonClasses.add(aClass);
@@ -27,7 +27,6 @@ import java.util.List;
* @see DomManager#createModelMerger()
*/
public interface ModelMerger {
@SuppressWarnings("unchecked")
<T> T mergeModels(Class<T> aClass, T... implementations);
<T> T mergeModels(Class<T> aClass, Collection<? extends T> implementations);
@@ -50,7 +50,6 @@ public class ModelMergerUtil {
return null;
}
@SafeVarargs
@Nullable
public static <T, V> V getImplementation(final Class<V> clazz, final T... elements) {
return getImplementation(clazz, Arrays.asList(elements));
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
*/
public abstract class BasicDomElementsInspection<T extends DomElement> extends DomElementsInspection<T> {
@SafeVarargs
public BasicDomElementsInspection(@NotNull Class<? extends T> domClass, Class<? extends T>... additionalClasses) {
super(domClass, additionalClasses);
}
@@ -49,7 +49,6 @@ public abstract class DomElementsInspection<T extends DomElement> extends XmlSup
private final Set<Class<? extends T>> myDomClasses;
@SafeVarargs
public DomElementsInspection(Class<? extends T> domClass, @NotNull Class<? extends T>... additionalClasses) {
myDomClasses = new THashSet<Class<? extends T>>(Arrays.asList(additionalClasses));
myDomClasses.add(domClass);