mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -139,18 +139,21 @@ public class AnActionEvent implements PlaceProvider<String> {
|
||||
}
|
||||
|
||||
@NonNls
|
||||
public static String injectedId(String dataId) {
|
||||
@NotNull
|
||||
public static String injectedId(@NotNull String dataId) {
|
||||
synchronized(ourInjectedIds) {
|
||||
return ourInjectedIds.computeIfAbsent(dataId, i -> ourInjectedPrefix + i);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@NotNull
|
||||
public static String uninjectedId(@NotNull String dataId) {
|
||||
return StringUtil.trimStart(dataId, ourInjectedPrefix);
|
||||
}
|
||||
|
||||
public static DataContext getInjectedDataContext(final DataContext context) {
|
||||
@NotNull
|
||||
public static DataContext getInjectedDataContext(@NotNull DataContext context) {
|
||||
return new DataContextWrapper(context) {
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @see DataContext
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DataProvider {
|
||||
/**
|
||||
* Returns the object corresponding to the specified data identifier. Some of the supported
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
@@ -46,8 +47,6 @@ import java.awt.event.MouseEvent;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.intellij.openapi.keymap.KeymapUtil.getActiveKeymapShortcuts;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
@@ -56,10 +55,11 @@ public class LineTooltipRenderer extends ComparableObject.Impl implements Toolti
|
||||
@NonNls @Nullable protected String myText;
|
||||
|
||||
//is used for suppressing some events while processing links
|
||||
private volatile boolean myActiveLink = false;
|
||||
private volatile boolean myActiveLink;
|
||||
//mostly is used as a marker that we are in popup with description
|
||||
protected final int myCurrentWidth;
|
||||
|
||||
@FunctionalInterface
|
||||
protected interface TooltipReloader {
|
||||
void reload(boolean toExpand);
|
||||
}
|
||||
@@ -75,8 +75,7 @@ public class LineTooltipRenderer extends ComparableObject.Impl implements Toolti
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected JPanel createMainPanel(@NotNull final HintHint hintHint,
|
||||
@NotNull JComponent pane) {
|
||||
private JPanel createMainPanel(@NotNull final HintHint hintHint, @NotNull JComponent pane) {
|
||||
JPanel grid = new JPanel(new GridBagLayout());
|
||||
GridBag bag = new GridBag()
|
||||
.anchor(GridBagConstraints.CENTER)
|
||||
@@ -162,19 +161,19 @@ public class LineTooltipRenderer extends ComparableObject.Impl implements Toolti
|
||||
};
|
||||
|
||||
|
||||
TooltipReloader reloader = (toExpand) -> reloadFor(hint, editor, p, editorPane, alignToRight, group, hintHint, toExpand);
|
||||
TooltipReloader reloader = toExpand -> reloadFor(hint, editor, p, editorPane, alignToRight, group, hintHint, toExpand);
|
||||
|
||||
actions.add(new AnAction() {
|
||||
// an action to expand description when tooltip was shown after mouse move; need to unregister from editor component
|
||||
{
|
||||
registerCustomShortcutSet(getActiveKeymapShortcuts(IdeActions.ACTION_SHOW_ERROR_DESCRIPTION), contentComponent);
|
||||
registerCustomShortcutSet(KeymapUtil.getActiveKeymapShortcuts(IdeActions.ACTION_SHOW_ERROR_DESCRIPTION), contentComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
// The tooltip gets the focus if using a screen reader and invocation through a keyboard shortcut.
|
||||
hintHint.setRequestFocus(ScreenReader.isActive() && (e.getInputEvent() instanceof KeyEvent));
|
||||
ActionsCollector.getInstance().record("tooltip.actions.show.description.shortcut", this.getClass());
|
||||
hintHint.setRequestFocus(ScreenReader.isActive() && e.getInputEvent() instanceof KeyEvent);
|
||||
ActionsCollector.getInstance().record("tooltip.actions.show.description.shortcut", getClass());
|
||||
reloader.reload(!expanded);
|
||||
}
|
||||
});
|
||||
@@ -202,7 +201,7 @@ public class LineTooltipRenderer extends ComparableObject.Impl implements Toolti
|
||||
return;
|
||||
}
|
||||
|
||||
ActionsCollector.getInstance().record("tooltip.actions.show.description.morelink", this.getClass());
|
||||
ActionsCollector.getInstance().record("tooltip.actions.show.description.morelink", getClass());
|
||||
|
||||
reloader.reload(!expanded);
|
||||
}
|
||||
|
||||
@@ -287,8 +287,14 @@ public class VfsData {
|
||||
// non-final field accesses are synchronized on this instance, but this happens in VirtualDirectoryImpl
|
||||
public static class DirectoryData {
|
||||
private static final AtomicFieldUpdater<DirectoryData, KeyFMap> updater = AtomicFieldUpdater.forFieldOfType(DirectoryData.class, KeyFMap.class);
|
||||
@NotNull volatile KeyFMap myUserMap = KeyFMap.EMPTY_MAP;
|
||||
@NotNull int[] myChildrenIds = ArrayUtil.EMPTY_INT_ARRAY; // guarded by this
|
||||
@NotNull
|
||||
volatile KeyFMap myUserMap = KeyFMap.EMPTY_MAP;
|
||||
/**
|
||||
* sorted by {@link VfsData#getNameByFileId(int)}
|
||||
* @see VirtualDirectoryImpl#findIndex(int[], CharSequence, boolean)
|
||||
*/
|
||||
@NotNull
|
||||
int[] myChildrenIds = ArrayUtil.EMPTY_INT_ARRAY; // guarded by this
|
||||
private Set<CharSequence> myAdoptedNames; // guarded by this
|
||||
|
||||
@NotNull
|
||||
@@ -323,7 +329,7 @@ public class VfsData {
|
||||
}
|
||||
myAdoptedNames.add(name);
|
||||
}
|
||||
void addAdoptedNames(Collection<CharSequence> names, boolean caseSensitive) {
|
||||
void addAdoptedNames(Collection<? extends CharSequence> names, boolean caseSensitive) {
|
||||
if (myAdoptedNames == null) {
|
||||
myAdoptedNames = new THashSet<>(0, caseSensitive ? CharSequenceHashingStrategy.CASE_SENSITIVE : CharSequenceHashingStrategy.CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class FileIndexBase implements FileIndex {
|
||||
!isScopeDisposed() && isInContent(file));
|
||||
};
|
||||
|
||||
public FileIndexBase(@NotNull DirectoryIndex directoryIndex, @NotNull FileTypeRegistry fileTypeManager) {
|
||||
FileIndexBase(@NotNull DirectoryIndex directoryIndex, @NotNull FileTypeRegistry fileTypeManager) {
|
||||
myDirectoryIndex = directoryIndex;
|
||||
myFileTypeRegistry = fileTypeManager;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jps.model.fileTypes.FileNameMatcherFactory;
|
||||
import java.util.*;
|
||||
|
||||
public class RootIndex {
|
||||
public static final Comparator<OrderEntry> BY_OWNER_MODULE = (o1, o2) -> {
|
||||
static final Comparator<OrderEntry> BY_OWNER_MODULE = (o1, o2) -> {
|
||||
String name1 = o1.getOwnerModule().getName();
|
||||
String name2 = o2.getOwnerModule().getName();
|
||||
return name1.compareTo(name2);
|
||||
@@ -54,8 +54,7 @@ public class RootIndex {
|
||||
private final PackageDirectoryCache myPackageDirectoryCache;
|
||||
private OrderEntryGraph myOrderEntryGraph;
|
||||
|
||||
// made public for Upsource
|
||||
public RootIndex(@NotNull Project project) {
|
||||
RootIndex(@NotNull Project project) {
|
||||
myProject = project;
|
||||
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
@@ -312,7 +311,7 @@ public class RootIndex {
|
||||
private MultiMap<VirtualFile, OrderEntry> myLibClassRootEntries;
|
||||
private MultiMap<VirtualFile, OrderEntry> myLibSourceRootEntries;
|
||||
|
||||
public OrderEntryGraph(Project project, RootInfo rootInfo) {
|
||||
OrderEntryGraph(Project project, RootInfo rootInfo) {
|
||||
myProject = project;
|
||||
myRootInfo = rootInfo;
|
||||
myAllRoots = myRootInfo.getAllRoots();
|
||||
@@ -431,7 +430,6 @@ public class RootIndex {
|
||||
if (roots == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<OrderEntry> result = new ArrayList<>();
|
||||
Stack<Node> stack = new Stack<>();
|
||||
for (VirtualFile root : roots) {
|
||||
Collection<Node> nodes = myRoots.get(root);
|
||||
@@ -441,6 +439,7 @@ public class RootIndex {
|
||||
}
|
||||
|
||||
Set<Node> seen = new HashSet<>();
|
||||
List<OrderEntry> result = new ArrayList<>();
|
||||
while (!stack.isEmpty()) {
|
||||
Node node = stack.pop();
|
||||
if (seen.contains(node)) {
|
||||
@@ -475,7 +474,7 @@ public class RootIndex {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<String> getDependentUnloadedModules(@NotNull Module module) {
|
||||
Set<String> getDependentUnloadedModules(@NotNull Module module) {
|
||||
return myDependentUnloadedModulesCache.get(module);
|
||||
}
|
||||
|
||||
@@ -483,9 +482,9 @@ public class RootIndex {
|
||||
* @return names of unloaded modules which directly or transitively via exported dependencies depend on the specified module
|
||||
*/
|
||||
private Set<String> collectDependentUnloadedModules(@NotNull Module module) {
|
||||
ArrayDeque<OrderEntryGraph.Node> stack = new ArrayDeque<>();
|
||||
Node start = myGraph.myNodes.get(module);
|
||||
if (start == null) return Collections.emptySet();
|
||||
Deque<Node> stack = new ArrayDeque<>();
|
||||
stack.push(start);
|
||||
Set<Node> seen = new HashSet<>();
|
||||
Set<String> result = null;
|
||||
@@ -574,7 +573,7 @@ public class RootIndex {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static String getPackageNameForSubdir(@Nullable String parentPackageName, @NotNull String subdirName) {
|
||||
private static String getPackageNameForSubdir(@Nullable String parentPackageName, @NotNull String subdirName) {
|
||||
if (parentPackageName == null) return null;
|
||||
return parentPackageName.isEmpty() ? subdirName : parentPackageName + "." + subdirName;
|
||||
}
|
||||
@@ -899,7 +898,7 @@ public class RootIndex {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getDependentUnloadedModules(@NotNull Module module) {
|
||||
Set<String> getDependentUnloadedModules(@NotNull Module module) {
|
||||
return getOrderEntryGraph().getDependentUnloadedModules(module);
|
||||
}
|
||||
|
||||
@@ -910,7 +909,7 @@ public class RootIndex {
|
||||
abstract static class SynchronizedSLRUCache<K, V> extends SLRUMap<K, V> {
|
||||
protected final Object myLock = new Object();
|
||||
|
||||
protected SynchronizedSLRUCache(final int protectedQueueSize, final int probationalQueueSize) {
|
||||
SynchronizedSLRUCache(final int protectedQueueSize, final int probationalQueueSize) {
|
||||
super(protectedQueueSize, probationalQueueSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,15 +37,17 @@ public class SortedIdSet implements Cloneable, RandomAccessIntContainer {
|
||||
return mySize == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(int value) {
|
||||
assert value > 0;
|
||||
int pos;
|
||||
|
||||
if (mySetLength == 0 || (mySetLength > 0 && Math.abs(mySet[mySetLength -1]) < value)) {
|
||||
if (mySetLength == 0 || mySetLength > 0 && Math.abs(mySet[mySetLength - 1]) < value) {
|
||||
pos = -mySetLength-1; // most of the time during bulk indexing we add near the end
|
||||
}
|
||||
else {
|
||||
@@ -74,6 +76,7 @@ public class SortedIdSet implements Cloneable, RandomAccessIntContainer {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(int value) {
|
||||
assert value > 0;
|
||||
int pos = binarySearch(mySet, 0, mySetLength, value);
|
||||
@@ -136,12 +139,12 @@ public class SortedIdSet implements Cloneable, RandomAccessIntContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private static int binarySearch(int[] set, int off, int length, int key) {
|
||||
int low = off;
|
||||
int high = length - 1;
|
||||
private static int binarySearch(final int[] set, int startOffset, int endOffset, int key) {
|
||||
int low = startOffset;
|
||||
int high = endOffset - 1;
|
||||
|
||||
while (low <= high) {
|
||||
int mid = (low + high) >>> 1;
|
||||
int mid = low + high >>> 1;
|
||||
int midVal = Math.abs(set[mid]);
|
||||
|
||||
if (midVal < key)
|
||||
@@ -161,6 +164,7 @@ public class SortedIdSet implements Cloneable, RandomAccessIntContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int value) {
|
||||
if(value <= 0) return false;
|
||||
int pos = binarySearch(mySet, 0, mySetLength, value);
|
||||
@@ -179,6 +183,7 @@ public class SortedIdSet implements Cloneable, RandomAccessIntContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compact() {
|
||||
if(2 * mySize < mySetLength && mySetLength > 5) {
|
||||
int positivePosition = -1;
|
||||
@@ -201,6 +206,7 @@ public class SortedIdSet implements Cloneable, RandomAccessIntContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomAccessIntContainer ensureContainerCapacity(int count) {
|
||||
int newSize = mySetLength + count;
|
||||
if (newSize < mySet.length) return this;
|
||||
|
||||
Reference in New Issue
Block a user