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:
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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 com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.generation.EqualsHashCodeTemplatesManager;
|
||||
@@ -13,12 +28,12 @@ public class GenerateEquals15Test extends GenerateEqualsTestCase {
|
||||
}
|
||||
|
||||
public void testDifferentTypes() throws Exception {
|
||||
doTest(Function.ID, Function.ID, fields -> new PsiField[0], true
|
||||
doTest(Function.ID, Function.ID, fields -> PsiField.EMPTY_ARRAY, true
|
||||
);
|
||||
}
|
||||
|
||||
public void testDifferentTypesGetters() throws Exception {
|
||||
doTest(Function.ID, Function.ID, fields -> new PsiField[0], true, true);
|
||||
doTest(Function.ID, Function.ID, fields -> PsiField.EMPTY_ARRAY, true, true);
|
||||
}
|
||||
|
||||
public void testDifferentTypesAllNotNull() throws Exception {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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 com.intellij.find.findUsages;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
@@ -25,7 +40,7 @@ public class FindParameterTest extends PsiTestCase {
|
||||
final PsiMethod methodFromText = elementFactory.createMethodFromText(text, null);
|
||||
final PsiParameter[] parameters = methodFromText.getParameterList().getParameters();
|
||||
final PsiReference[] references =
|
||||
ReferencesSearch.search(parameters[0], new LocalSearchScope(methodFromText), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(parameters[0], new LocalSearchScope(methodFromText), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
Assert.assertEquals(references.length, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -47,12 +46,12 @@ public class FindUsages15Test extends PsiTestCase{
|
||||
PsiMethod[] constructors = enumClass.getConstructors();
|
||||
assertEquals(2, constructors.length);
|
||||
PsiReference[] references0 =
|
||||
ReferencesSearch.search(constructors[0], GlobalSearchScope.moduleScope(myModule), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(constructors[0], GlobalSearchScope.moduleScope(myModule), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
assertEquals(2, references0.length);
|
||||
assertTrue(references0[0].getElement() instanceof PsiEnumConstant);
|
||||
assertTrue(references0[1].getElement() instanceof PsiEnumConstant);
|
||||
PsiReference[] references1 =
|
||||
ReferencesSearch.search(constructors[1], GlobalSearchScope.moduleScope(myModule), false).toArray(new PsiReference[0]);
|
||||
ReferencesSearch.search(constructors[1], GlobalSearchScope.moduleScope(myModule), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
assertEquals(1, references1.length);
|
||||
assertTrue(references1[0].getElement() instanceof PsiEnumConstant);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -148,7 +148,7 @@ public class SearchInLibsTest extends PsiTestCase {
|
||||
final PsiClass aClass = myJavaFacade.findClass(classNameToSearch);
|
||||
assertNotNull(aClass);
|
||||
|
||||
PsiReference[] refs = ReferencesSearch.search(aClass, scope, false).toArray(new PsiReference[0]);
|
||||
PsiReference[] refs = ReferencesSearch.search(aClass, scope, false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
|
||||
ArrayList<PsiFile> files = new ArrayList<>();
|
||||
for (PsiReference ref : refs) {
|
||||
|
||||
@@ -45,13 +45,15 @@ import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@PlatformTestCase.WrapInCommand
|
||||
public class UpdateCacheTest extends PsiTestCase {
|
||||
@@ -406,7 +408,8 @@ public class UpdateCacheTest extends PsiTestCase {
|
||||
}
|
||||
|
||||
private void checkUsages(PsiElement element, @NonNls String[] expectedFiles){
|
||||
PsiReference[] refs = ReferencesSearch.search(element, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
|
||||
PsiReference[] refs = ReferencesSearch.search(element, GlobalSearchScope.projectScope(myProject), false).toArray(
|
||||
PsiReference.EMPTY_ARRAY);
|
||||
|
||||
List<PsiFile> files = new ArrayList<PsiFile>();
|
||||
for (PsiReference ref : refs) {
|
||||
|
||||
Reference in New Issue
Block a user