mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 09:03:31 +07:00
cleanup
This commit is contained in:
@@ -47,19 +47,19 @@ public final class ActionManagerImpl extends ActionManagerEx implements JDOMExte
|
||||
private static final int UPDATE_DELAY_AFTER_TYPING = 500;
|
||||
|
||||
private final Object myLock = new Object();
|
||||
private THashMap<String,Object> myId2Action;
|
||||
private THashMap<PluginId, THashSet<String>> myPlugin2Id;
|
||||
private TObjectIntHashMap<String> myId2Index;
|
||||
private THashMap<Object,String> myAction2Id;
|
||||
private ArrayList<String> myNotRegisteredInternalActionIds;
|
||||
private final THashMap<String,Object> myId2Action;
|
||||
private final THashMap<PluginId, THashSet<String>> myPlugin2Id;
|
||||
private final TObjectIntHashMap<String> myId2Index;
|
||||
private final THashMap<Object,String> myAction2Id;
|
||||
private final ArrayList<String> myNotRegisteredInternalActionIds;
|
||||
private MyTimer myTimer;
|
||||
|
||||
private int myRegisteredActionsCount;
|
||||
private ArrayList<AnActionListener> myActionListeners;
|
||||
private final ArrayList<AnActionListener> myActionListeners;
|
||||
private AnActionListener[] myCachedActionListeners;
|
||||
private String myLastPreformedActionId;
|
||||
private KeymapManager myKeymapManager;
|
||||
private DataManager myDataManager;
|
||||
private final KeymapManager myKeymapManager;
|
||||
private final DataManager myDataManager;
|
||||
private String myPrevPerformedActionId;
|
||||
private long myLastTimeEditorWasTypedIn = 0;
|
||||
@NonNls private static final String ACTION_ELEMENT_NAME = "action";
|
||||
@@ -171,11 +171,13 @@ public final class ActionManagerImpl extends ActionManagerEx implements JDOMExte
|
||||
}
|
||||
|
||||
private AnAction getActionImpl(String id, boolean canReturnStub) {
|
||||
synchronized (myLock) {
|
||||
AnAction action = (AnAction)myId2Action.get(id);
|
||||
if (!canReturnStub && action instanceof ActionStub) {
|
||||
action = convert((ActionStub)action);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +185,6 @@ public final class ActionManagerImpl extends ActionManagerEx implements JDOMExte
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private AnAction convert(ActionStub stub) {
|
||||
synchronized (myLock) {
|
||||
LOG.assertTrue(myAction2Id.contains(stub));
|
||||
myAction2Id.remove(stub);
|
||||
|
||||
@@ -237,7 +238,6 @@ public final class ActionManagerImpl extends ActionManagerEx implements JDOMExte
|
||||
myAction2Id.put(obj, stub.getId());
|
||||
|
||||
return (AnAction)obj;
|
||||
}
|
||||
}
|
||||
|
||||
public String getId(@NotNull AnAction action) {
|
||||
@@ -513,7 +513,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements JDOMExte
|
||||
assertActionIsGroupOrStub(action);
|
||||
}
|
||||
|
||||
String actionName = (action instanceof ActionStub) ? ((ActionStub) action).getClassName() : action.getClass().getName();
|
||||
String actionName = action instanceof ActionStub ? ((ActionStub)action).getClassName() : action.getClass().getName();
|
||||
|
||||
if (!ADD_TO_GROUP_ELEMENT_NAME.equals(element.getName())) {
|
||||
LOG.error("unexpected name of element \"" + element.getName() + "\"");
|
||||
@@ -695,7 +695,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements JDOMExte
|
||||
return action;
|
||||
}
|
||||
|
||||
public void processActionsElement(Element element, ClassLoader loader, PluginId pluginId) {
|
||||
private void processActionsElement(Element element, ClassLoader loader, PluginId pluginId) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("enter: processActionsNode(" + element.getName() + ")");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.apache.oro.text.regex.Pattern;
|
||||
import org.apache.oro.text.regex.PatternMatcher;
|
||||
import org.apache.oro.text.regex.Perl5Matcher;
|
||||
@@ -55,7 +54,6 @@ public class LookupImpl extends LightweightHint implements Lookup {
|
||||
private DocumentListener myDocumentListener;
|
||||
|
||||
private ArrayList<LookupListener> myListeners = new ArrayList<LookupListener>();
|
||||
private HashMap myUserMap = new HashMap();
|
||||
|
||||
private boolean myCanceled = true;
|
||||
private boolean myDisposed = false;
|
||||
@@ -502,19 +500,6 @@ public class LookupImpl extends LightweightHint implements Lookup {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getUserData(Key<T> key){
|
||||
return (T)myUserMap.get(key);
|
||||
}
|
||||
|
||||
public <T> void putUserData(Key<T> key, T value){
|
||||
if (value != null){
|
||||
myUserMap.put(key, value);
|
||||
}
|
||||
else{
|
||||
myUserMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isNarrowDownMode(){
|
||||
return CodeInsightSettings.getInstance().NARROW_DOWN_LOOKUP_LIST;
|
||||
}
|
||||
|
||||
@@ -143,12 +143,14 @@ public abstract class CodeInsightTestCase extends PsiTestCase {
|
||||
if (projectRoot != null) {
|
||||
FileUtil.copyDir(projectRoot, toDirIO);
|
||||
VirtualFile fromDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(projectRoot);
|
||||
editorInfos = copyFilesFillingEditorInfos(fromDir, toDir, ContainerUtil.map2Array(vFiles, String.class, new Function<VirtualFile, String>() {
|
||||
public String fun(final VirtualFile s) {
|
||||
return s.getPath().substring(projectRoot.getPath().length());
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
editorInfos =
|
||||
copyFilesFillingEditorInfos(fromDir, toDir, ContainerUtil.map2Array(vFiles, String.class, new Function<VirtualFile, String>() {
|
||||
public String fun(final VirtualFile s) {
|
||||
return s.getPath().substring(projectRoot.getPath().length());
|
||||
}
|
||||
}));
|
||||
}
|
||||
else {
|
||||
editorInfos = new LinkedHashMap<VirtualFile, EditorInfo>();
|
||||
for (final VirtualFile vFile : vFiles) {
|
||||
editorInfos.putAll(copyFilesFillingEditorInfos(vFile.getParent(), toDir, vFile.getName()));
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class LocalFileSystemImpl extends LocalFileSystem implements Applic
|
||||
private static final Key DELETED_STATUS = Key.create("DELETED_STATUS");
|
||||
|
||||
private List<LocalFileOperationsHandler> myHandlers = new ArrayList<LocalFileOperationsHandler>();
|
||||
public Map<String, VirtualFileImpl> myUnaccountedFiles = SystemInfo.isFileSystemCaseSensitive
|
||||
public final Map<String, VirtualFileImpl> myUnaccountedFiles = SystemInfo.isFileSystemCaseSensitive
|
||||
? new THashMap<String, VirtualFileImpl>()
|
||||
: new THashMap<String, VirtualFileImpl>(
|
||||
new CaseInsensitiveStringHashingStrategy()
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -91,13 +92,13 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
|
||||
}
|
||||
|
||||
public static PsiVariable[] getAllVariables(PsiElement scope, PsiElement place) {
|
||||
final List<PsiVariable> result = new ArrayList<PsiVariable>();
|
||||
final List<PsiVariable> result = new SmartList<PsiVariable>();
|
||||
PsiScopesUtil.processScope(scope, new FilterScopeProcessor(new ClassFilter(PsiVariable.class), result), PsiSubstitutor.UNKNOWN, null, place);
|
||||
return result.toArray(new PsiVariable[result.size()]);
|
||||
}
|
||||
|
||||
public static PsiMethod[] getAllMethods(PsiElement scope, PsiElement place) {
|
||||
final List<PsiMethod> result = new ArrayList<PsiMethod>();
|
||||
final List<PsiMethod> result = new SmartList<PsiMethod>();
|
||||
PsiScopesUtil.processScope(scope, new FilterScopeProcessor(new ClassFilter(PsiMethod.class), result), PsiSubstitutor.UNKNOWN, null, place);
|
||||
return result.toArray(new PsiMethod[result.size()]);
|
||||
}
|
||||
|
||||
@@ -266,17 +266,17 @@ public class InjectedLanguageUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiLanguageInjectionHost findInjectionHost(PsiElement element) {
|
||||
if (element == null) return null;
|
||||
if (element == null || element instanceof PsiFile) return null;
|
||||
if (element instanceof PsiLanguageInjectionHost) {
|
||||
return (PsiLanguageInjectionHost)element;
|
||||
}
|
||||
element = element.getParent();
|
||||
if (element == null) return null;
|
||||
if (element == null || element instanceof PsiFile) return null;
|
||||
if (element instanceof PsiLanguageInjectionHost) {
|
||||
return (PsiLanguageInjectionHost)element;
|
||||
}
|
||||
element = element.getParent();
|
||||
if (element == null) return null;
|
||||
if (element == null || element instanceof PsiFile) return null;
|
||||
if (element instanceof PsiLanguageInjectionHost) {
|
||||
return (PsiLanguageInjectionHost)element;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,10 @@ package com.intellij.ui;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.wm.ex.LayoutFocusTraversalPolicyExt;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.popup.JBPopupImpl;
|
||||
import gnu.trove.THashMap;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.EventListenerList;
|
||||
@@ -18,14 +16,12 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.EventListener;
|
||||
import java.util.EventObject;
|
||||
import java.util.Map;
|
||||
|
||||
public class LightweightHint implements Hint, UserDataHolder {
|
||||
public class LightweightHint extends UserDataHolderBase implements Hint {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.LightweightHint");
|
||||
|
||||
private final JComponent myComponent;
|
||||
private JComponent myFocusBackComponent;
|
||||
private final Map<Key, Object> myUserMap = new THashMap<Key, Object>(1);
|
||||
private final EventListenerList myListenerList = new EventListenerList();
|
||||
private MyEscListener myEscListener;
|
||||
private JBPopup myPopup;
|
||||
@@ -192,20 +188,6 @@ public class LightweightHint implements Hint, UserDataHolder {
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T> T getUserData(final Key<T> key) {
|
||||
return (T)myUserMap.get(key);
|
||||
}
|
||||
|
||||
public <T> void putUserData(final Key<T> key, final T value) {
|
||||
if (value != null) {
|
||||
myUserMap.put(key, value);
|
||||
}
|
||||
else {
|
||||
myUserMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public final void addHintListener(final HintListener listener) {
|
||||
myListenerList.add(HintListener.class, listener);
|
||||
}
|
||||
@@ -220,7 +202,7 @@ public class LightweightHint implements Hint, UserDataHolder {
|
||||
|
||||
private final class MyEscListener implements ActionListener {
|
||||
public final void actionPerformed(final ActionEvent e) {
|
||||
LightweightHint.this.hide();
|
||||
hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,48 @@ public class SmartList<E> extends AbstractList<E> {
|
||||
else {
|
||||
oldValue = ((List<E>)myElem).set(index, element);
|
||||
}
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public E remove(final int index) {
|
||||
if (index < 0 || index >= mySize) {
|
||||
throw new IndexOutOfBoundsException("index= " + index + ". Must be index > 0 && index < " + mySize);
|
||||
}
|
||||
ArrayList<E> old = new ArrayList<E>(this);
|
||||
|
||||
final E oldValue;
|
||||
if (mySize == 1) {
|
||||
oldValue = (E)myElem;
|
||||
myElem = null;
|
||||
}
|
||||
else if (mySize == 2) {
|
||||
final Object[] array = (Object[])myElem;
|
||||
oldValue = (E)array[index];
|
||||
myElem = array[1 - index];
|
||||
}
|
||||
else if (mySize == 3) {
|
||||
List<E> list = (List<E>)myElem;
|
||||
oldValue = list.get(index);
|
||||
Object[] array = new Object[2];
|
||||
int i0 = index==0 ? 1 : index==1 ? 0 : 0;
|
||||
int i1 = index==0 ? 2 : index==1 ? 2 : 1;
|
||||
array[0] = list.get(i0);
|
||||
array[1] = list.get(i1);
|
||||
myElem = array;
|
||||
}
|
||||
else {
|
||||
List<E> list = (List<E>)myElem;
|
||||
oldValue = list.remove(index);
|
||||
}
|
||||
mySize--;
|
||||
{
|
||||
List<E> list = new ArrayList<E>(subList(0, index));
|
||||
list.add(oldValue);
|
||||
list.addAll(subList(index, mySize));
|
||||
if (!list.equals(old)) {
|
||||
int i = 0;
|
||||
}
|
||||
}
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user