mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
cleanup. Convert empty arrays to constants (new T[0] -> T.EMPTY)
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -80,7 +80,7 @@ public class FunctionalExpressionCompletionProvider extends CompletionProvider<C
|
||||
final PsiType functionalInterfaceType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(defaultType);
|
||||
final PsiMethod functionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType);
|
||||
if (functionalInterfaceMethod != null) {
|
||||
PsiParameter[] params = new PsiParameter[0];
|
||||
PsiParameter[] params = PsiParameter.EMPTY_ARRAY;
|
||||
final PsiElement originalPosition = parameters.getPosition();
|
||||
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(functionalInterfaceMethod, PsiUtil.resolveGenericsClassInType(functionalInterfaceType));
|
||||
if (!functionalInterfaceMethod.hasTypeParameters()) {
|
||||
|
||||
@@ -906,7 +906,7 @@ public class JavaDocInfoGenerator {
|
||||
generateAnnotations(buffer, owner, ownerModifierList.getAnnotations(), false, generateLink, splitAnnotations, useShortNames);
|
||||
PsiAnnotation[] externalAnnotations = ExternalAnnotationsManager.getInstance(owner.getProject()).findExternalAnnotations(owner);
|
||||
if (externalAnnotations == null) {
|
||||
externalAnnotations = new PsiAnnotation[]{};
|
||||
externalAnnotations = PsiAnnotation.EMPTY_ARRAY;
|
||||
}
|
||||
PsiAnnotation[] inferredAnnotations = InferredAnnotationsManager.getInstance(owner.getProject()).findInferredAnnotations(owner);
|
||||
externalAnnotations = ArrayUtil.mergeArrays(externalAnnotations, inferredAnnotations, PsiAnnotation.ARRAY_FACTORY);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -33,7 +33,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StaticIconFieldsAction extends AnAction {
|
||||
@@ -45,7 +44,7 @@ public class StaticIconFieldsAction extends AnAction {
|
||||
final UsageViewPresentation presentation = new UsageViewPresentation();
|
||||
presentation.setTabName("Statics");
|
||||
presentation.setTabText("Statitcs");
|
||||
final UsageView view = UsageViewManager.getInstance(project).showUsages(UsageTarget.EMPTY_ARRAY, new Usage[0], presentation);
|
||||
final UsageView view = UsageViewManager.getInstance(project).showUsages(UsageTarget.EMPTY_ARRAY, Usage.EMPTY_ARRAY, presentation);
|
||||
|
||||
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Searching icons usages") {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -101,7 +101,7 @@ public class ConvertToInstanceMethodProcessor extends BaseRefactoringProcessor {
|
||||
final Project project = myMethod.getProject();
|
||||
|
||||
final PsiReference[] methodReferences =
|
||||
ReferencesSearch.search(myMethod, GlobalSearchScope.projectScope(project), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(myMethod, GlobalSearchScope.projectScope(project), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
List<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
for (final PsiReference ref : methodReferences) {
|
||||
final PsiElement element = ref.getElement();
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -104,7 +104,8 @@ public abstract class ExtractSuperBaseProcessor extends TurnRefsToSuperProcessor
|
||||
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
final ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
detectTurnToSuperRefs(refs, result);
|
||||
final PsiPackage originalPackage = JavaDirectoryService.getInstance().getPackage(myClass.getContainingFile().getContainingDirectory());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -55,7 +55,6 @@ import com.intellij.refactoring.rename.RenameJavaVariableProcessor;
|
||||
import com.intellij.refactoring.util.*;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -1108,7 +1107,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (isAccessedForWriting) {
|
||||
if (refVar.hasModifierProperty(PsiModifier.FINAL) || shouldBeFinal) return false;
|
||||
PsiReference[] refs =
|
||||
ReferencesSearch.search(refVar, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(refVar, GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
return refs.length == 1; //TODO: control flow
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -31,6 +31,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.FileTypeUtils;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
@@ -40,7 +41,6 @@ import com.intellij.refactoring.util.EnumConstantsUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.psi.util.FileTypeUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -295,7 +295,7 @@ public abstract class LocalToFieldHandler {
|
||||
final boolean rebindNeeded2 = !myVariableName.equals(myFieldName) || myRebindNeeded;
|
||||
final PsiReference[] refs;
|
||||
if (rebindNeeded2) {
|
||||
refs = ReferencesSearch.search(myLocal, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
refs = ReferencesSearch.search(myLocal, GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
}
|
||||
else {
|
||||
refs = null;
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -35,7 +35,6 @@ import com.intellij.refactoring.util.CanonicalTypes;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.javadoc.MethodJavaDocHelper;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -304,7 +303,7 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor<
|
||||
|
||||
PsiElement anchor = null;
|
||||
PsiExpressionList argList = null;
|
||||
PsiExpression[] exprs = new PsiExpression[0];
|
||||
PsiExpression[] exprs = PsiExpression.EMPTY_ARRAY;
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
argList = ((PsiMethodCallExpression)parent).getArgumentList();
|
||||
exprs = argList.getExpressions();
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.intention.AddAnnotationFix;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -552,7 +551,7 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
|
||||
}
|
||||
if (doLookup) {
|
||||
final PsiReference[] references =
|
||||
ReferencesSearch.search(field, new LocalSearchScope(statement), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(field, new LocalSearchScope(statement), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
if (commonInitializerCandidate == null && references.length > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -155,7 +155,7 @@ public class PullUpConflictsUtil {
|
||||
ContainerUtil.addIfNotNull(checkModuleConflictsList, method.getTypeParameterList());
|
||||
}
|
||||
RefactoringConflictsUtil.analyzeModuleConflicts(subclass.getProject(), checkModuleConflictsList,
|
||||
new UsageInfo[0], targetRepresentativeElement, conflicts);
|
||||
UsageInfo.EMPTY_ARRAY, targetRepresentativeElement, conflicts);
|
||||
|
||||
final PsiFile psiFile = PsiTreeUtil.getParentOfType(subclass, PsiClassOwner.class);
|
||||
final boolean toDifferentPackage = !Comparing.strEqual(targetPackage.getQualifiedName(),
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -211,7 +211,7 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate {
|
||||
return;
|
||||
}
|
||||
final MoveClassesOrPackagesToNewDirectoryDialog dlg =
|
||||
new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], new PsiElement[0], false, callback) {
|
||||
new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], PsiElement.EMPTY_ARRAY, false, callback) {
|
||||
@Override
|
||||
protected BaseRefactoringProcessor createRefactoringProcessor(Project project,
|
||||
final PsiDirectory targetDirectory,
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SearchUtils{
|
||||
|
||||
public static Iterable<PsiReference> findAllReferences(PsiElement element, SearchScope scope){
|
||||
|
||||
return new ArrayIterable<PsiReference>(ReferencesSearch.search(element, scope, true).toArray(new PsiReference[0]));
|
||||
return new ArrayIterable<PsiReference>(ReferencesSearch.search(element, scope, true).toArray(PsiReference.EMPTY_ARRAY));
|
||||
/*
|
||||
try {
|
||||
Class<?> searchClass = Class.forName("com.intellij.psi.search.searches.ReferencesSearch");
|
||||
@@ -59,12 +59,12 @@ public class SearchUtils{
|
||||
}
|
||||
|
||||
public static Iterable<PsiMethod> findOverridingMethods(PsiMethod method){
|
||||
return new ArrayIterable<PsiMethod>(OverridingMethodsSearch.search(method).toArray(new PsiMethod[0]));
|
||||
return new ArrayIterable<PsiMethod>(OverridingMethodsSearch.search(method).toArray(PsiMethod.EMPTY_ARRAY));
|
||||
// return OverridingMethodsSearch.search(method, method.getUseScope(), true).findAll();
|
||||
}
|
||||
|
||||
public static Iterable<PsiClass> findClassInheritors(PsiClass aClass, boolean deep){
|
||||
return new ArrayIterable<PsiClass>(ClassInheritorsSearch.search(aClass, deep).toArray(new PsiClass[0]));
|
||||
return new ArrayIterable<PsiClass>(ClassInheritorsSearch.search(aClass, deep).toArray(PsiClass.EMPTY_ARRAY));
|
||||
// return ClassInheritorsSearch.search(aClass, deep);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -28,7 +28,7 @@ public class ReplaceConstructorWithBuilderViewDescriptor extends UsageViewDescri
|
||||
|
||||
@NotNull
|
||||
public PsiElement[] getElements() {
|
||||
return new PsiElement[0];
|
||||
return PsiElement.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public String getProcessedElementsHeader() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -79,7 +79,8 @@ public class TempWithQueryHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
final PsiReference[] refs = ReferencesSearch.search(local, GlobalSearchScope.projectScope(project), false).toArray(new PsiReference[0]);
|
||||
final PsiReference[] refs = ReferencesSearch.search(local, GlobalSearchScope.projectScope(project), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
|
||||
if (refs.length == 0) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.never.used", localName));
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -68,7 +68,8 @@ public class TurnRefsToSuperProcessor extends TurnRefsToSuperProcessorBase {
|
||||
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
final PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
final PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
|
||||
final ArrayList<UsageInfo> result = detectTurnToSuperRefs(refs, new ArrayList<UsageInfo>());
|
||||
|
||||
|
||||
@@ -823,7 +823,8 @@ public class TypeMigrationLabeler {
|
||||
}
|
||||
|
||||
public PsiReference[] markRootUsages(final PsiElement element, final PsiType migrationType) {
|
||||
return markRootUsages(element, migrationType, ReferencesSearch.search(element, myRules.getSearchScope(), false).toArray(new PsiReference[0]));
|
||||
return markRootUsages(element, migrationType, ReferencesSearch.search(element, myRules.getSearchScope(), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
PsiReference[] markRootUsages(final PsiElement element, final PsiType migrationType, final PsiReference[] refs) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -30,7 +30,7 @@ public class ClassReferenceSearchingScanner extends ClassReferenceScanner {
|
||||
|
||||
public PsiReference[] findReferences() {
|
||||
GlobalSearchScope projectScope = GlobalSearchScope.projectScope(myClass.getProject());
|
||||
return ReferencesSearch.search(myClass, projectScope, false).toArray(new PsiReference[0]);
|
||||
return ReferencesSearch.search(myClass, projectScope, false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ class SliceUtil {
|
||||
// for erased method calls for which we cannot determine target substitutor,
|
||||
// rely on call argument types. I.e. new Pair(1,2) -> Pair<Integer, Integer>
|
||||
if (element instanceof PsiTypeParameterListOwner && PsiUtil.isRawSubstitutor((PsiTypeParameterListOwner)element, substitutor)) {
|
||||
PsiTypeParameter[] typeParameters = substitutor.getSubstitutionMap().keySet().toArray(new PsiTypeParameter[0]);
|
||||
PsiTypeParameter[] typeParameters = substitutor.getSubstitutionMap().keySet().toArray(PsiTypeParameter.EMPTY_ARRAY);
|
||||
|
||||
PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(project).getResolveHelper();
|
||||
substitutor = resolveHelper.inferTypeArguments(typeParameters, actualParameters, expressions, parentSubstitutor, argumentList,
|
||||
|
||||
Reference in New Issue
Block a user