mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup: stop spreading new empty arrays
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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,6 +33,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.ClassUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -45,7 +46,7 @@ import java.util.Set;
|
||||
public class RefClassImpl extends RefJavaElementImpl implements RefClass {
|
||||
private static final Set<RefElement> EMPTY_SET = Collections.emptySet();
|
||||
private static final Set<RefClass> EMPTY_CLASS_SET = Collections.emptySet();
|
||||
private static final List<RefMethod> EMPTY_METHOD_LIST = new ArrayList<RefMethod>(0);
|
||||
private static final List<RefMethod> EMPTY_METHOD_LIST = ContainerUtil.emptyList();
|
||||
private static final int IS_ANONYMOUS_MASK = 0x10000;
|
||||
private static final int IS_INTERFACE_MASK = 0x20000;
|
||||
private static final int IS_UTILITY_MASK = 0x40000;
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -36,6 +36,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -48,7 +49,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RefElementImpl extends RefEntityImpl implements RefElement {
|
||||
private static final List<RefElement> EMPTY_REFERNCES_LIST = new ArrayList<RefElement>(0);
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.reference.RefElement");
|
||||
|
||||
private static final int IS_ENTRY_MASK = 0x80;
|
||||
@@ -168,7 +168,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement
|
||||
@NotNull
|
||||
public Collection<RefElement> getOutReferences() {
|
||||
if (myOutReferences == null){
|
||||
return EMPTY_REFERNCES_LIST;
|
||||
return ContainerUtil.emptyList();
|
||||
}
|
||||
return myOutReferences;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement
|
||||
@NotNull
|
||||
public Collection<RefElement> getInReferences() {
|
||||
if (myInReferences == null){
|
||||
return EMPTY_REFERNCES_LIST;
|
||||
return ContainerUtil.emptyList();
|
||||
}
|
||||
return myInReferences;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MergeActionGroup extends ActionGroup {
|
||||
private final MergeOperations myOperations;
|
||||
@@ -31,14 +31,16 @@ public class MergeActionGroup extends ActionGroup {
|
||||
myOperations = new MergeOperations(diffPanel, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
ArrayList<MergeOperations.Operation> operations = myOperations.getOperations();
|
||||
List<MergeOperations.Operation> operations = myOperations.getOperations();
|
||||
AnAction[] actions = new AnAction[operations.size() + 2];
|
||||
actions[0] = new SelectSuggestionAction(myOperations);
|
||||
actions[1] = Separator.getInstance();
|
||||
for (int i = 2; i < actions.length; i++)
|
||||
for (int i = 2; i < actions.length; i++) {
|
||||
actions[i] = new OperationAction(operations.get(i - 2));
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -51,10 +53,12 @@ public class MergeActionGroup extends ActionGroup {
|
||||
myOperations = operations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myOperations.selectSuggestion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(myOperations.getCurrentFragment() != null);
|
||||
}
|
||||
@@ -68,6 +72,7 @@ public class MergeActionGroup extends ActionGroup {
|
||||
myOperation = operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myOperation.perform(PlatformDataKeys.PROJECT.getData(e.getDataContext()));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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,15 +31,18 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MergeOperations {
|
||||
private final DiffPanelImpl myDiffPanel;
|
||||
private final FragmentSide mySide;
|
||||
private static final ArrayList<Operation> NO_OPERATIONS = new ArrayList<Operation>(0);
|
||||
private static final List<Operation> NO_OPERATIONS = ContainerUtil.emptyList();
|
||||
private static final Condition<Fragment> NOT_EQUAL_FRAGMENT = new Condition<Fragment>() {
|
||||
public boolean value(Fragment fragment) {
|
||||
return fragment.getType() != null;
|
||||
@@ -51,7 +54,8 @@ public class MergeOperations {
|
||||
mySide = side;
|
||||
}
|
||||
|
||||
public ArrayList<Operation> getOperations() {
|
||||
@NotNull
|
||||
public List<Operation> getOperations() {
|
||||
Fragment fragment = getCurrentFragment();
|
||||
if (fragment == null) return NO_OPERATIONS;
|
||||
ArrayList<Operation> operations = new ArrayList<Operation>(3);
|
||||
|
||||
Reference in New Issue
Block a user