mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -50,6 +50,7 @@ public class MethodSignatureBackedByPsiMethod extends MethodSignatureBase {
|
||||
return myMethod.isConstructor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof MethodSignatureBackedByPsiMethod){ // optimization
|
||||
if (((MethodSignatureBackedByPsiMethod)o).myMethod == myMethod) return true;
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.intellij.util.concurrency.EdtScheduledExecutorService;
|
||||
import com.intellij.util.concurrency.QueueProcessor;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import org.jetbrains.annotations.Async;
|
||||
@@ -26,7 +25,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
@@ -224,18 +222,19 @@ public class Alarm implements Disposable {
|
||||
|
||||
public boolean cancelRequest(@NotNull Runnable request) {
|
||||
synchronized (LOCK) {
|
||||
cancelRequest(request, myRequests);
|
||||
cancelRequest(request, myPendingRequests);
|
||||
cancelAndRemoveRequestFrom(request, myRequests);
|
||||
cancelAndRemoveRequestFrom(request, myPendingRequests);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelRequest(@NotNull Runnable request, @NotNull List<Request> list) {
|
||||
private void cancelAndRemoveRequestFrom(@NotNull Runnable request, @NotNull List<Request> list) {
|
||||
for (int i = list.size()-1; i>=0; i--) {
|
||||
Request r = list.get(i);
|
||||
if (r.myTask == request) {
|
||||
r.cancel();
|
||||
list.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,11 +315,6 @@ public class Alarm implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEventDispatchThread() {
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
return app != null && app.isDispatchThread() || EventQueue.isDispatchThread();
|
||||
}
|
||||
|
||||
private class Request implements Runnable {
|
||||
private Runnable myTask; // guarded by LOCK
|
||||
private final ModalityState myModalityState;
|
||||
@@ -358,17 +352,6 @@ public class Alarm implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
void invokeLater(@NotNull Runnable scheduledTask) {
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
if (app == null) {
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(scheduledTask);
|
||||
}
|
||||
else {
|
||||
app.invokeLater(scheduledTask, myModalityState == null ? ModalityState.any() : myModalityState);
|
||||
}
|
||||
}
|
||||
|
||||
@Async.Execute
|
||||
private void runSafely(@Nullable Runnable task) {
|
||||
try {
|
||||
|
||||
@@ -16,44 +16,39 @@
|
||||
package com.intellij.util.containers.hash;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
class HashUtil {
|
||||
static final int MIN_CAPACITY = 5;
|
||||
|
||||
static final float DEFAULT_LOAD_FACTOR = 1;
|
||||
|
||||
public static final int MIN_CAPACITY = 5;
|
||||
|
||||
public static final float DEFAULT_LOAD_FACTOR = 1;
|
||||
|
||||
public static final float CAPACITY_MULTIPLE = 1.618033989f;
|
||||
static final float CAPACITY_MULTIPLE = 1.618033989f;
|
||||
|
||||
|
||||
public static int hash(Object key) {
|
||||
|
||||
return key == null ? 0 : key.hashCode() & 0x7fffffff;
|
||||
|
||||
}
|
||||
|
||||
public static int hash(Object key, EqualityPolicy hashingStrategy) {
|
||||
|
||||
public static <K> int hash(K key, @NotNull EqualityPolicy<? super K> hashingStrategy) {
|
||||
return key == null ? 0 : hashingStrategy.getHashCode(key) & 0x7fffffff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static int adjustTableSize(int size) {
|
||||
static int adjustTableSize(int size) {
|
||||
|
||||
int i = Arrays.binarySearch(tableSizes, size);
|
||||
|
||||
if (i < 0) {
|
||||
|
||||
i = ~i;
|
||||
|
||||
}
|
||||
|
||||
return tableSizes[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -142,15 +137,11 @@ class HashUtil {
|
||||
|
||||
|
||||
Integer.MAX_VALUE,
|
||||
|
||||
};
|
||||
|
||||
|
||||
static {
|
||||
|
||||
Arrays.sort(tableSizes);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,14 @@ public class LinkedHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>
|
||||
this(capacity, loadFactor, (EqualityPolicy)EqualityPolicy.CANONICAL, accessOrder);
|
||||
}
|
||||
|
||||
public LinkedHashMap(EqualityPolicy<? super K> hashingStrategy) {
|
||||
public LinkedHashMap(@NotNull EqualityPolicy<? super K> hashingStrategy) {
|
||||
this(0, HashUtil.DEFAULT_LOAD_FACTOR, hashingStrategy);
|
||||
}
|
||||
|
||||
public LinkedHashMap(int capacity, float loadFactor, EqualityPolicy<? super K> hashingStrategy) {
|
||||
public LinkedHashMap(int capacity, float loadFactor, @NotNull EqualityPolicy<? super K> hashingStrategy) {
|
||||
this(capacity, loadFactor, hashingStrategy, false);
|
||||
}
|
||||
public LinkedHashMap(int capacity, float loadFactor, EqualityPolicy<? super K> hashingStrategy, boolean accessOrder) {
|
||||
public LinkedHashMap(int capacity, float loadFactor, @NotNull EqualityPolicy<? super K> hashingStrategy, boolean accessOrder) {
|
||||
this.loadFactor = loadFactor;
|
||||
this.hashingStrategy = hashingStrategy;
|
||||
clear(capacity);
|
||||
@@ -85,7 +85,7 @@ public class LinkedHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>
|
||||
@Override
|
||||
public V get(final Object key) {
|
||||
final Entry<K, V>[] table = this.table;
|
||||
final int hash = HashUtil.hash(key, hashingStrategy);
|
||||
final int hash = HashUtil.hash((K)key, hashingStrategy);
|
||||
final int index = hash % table.length;
|
||||
|
||||
for (Entry<K, V> e = table[index]; e != null; e = e.hashNext) {
|
||||
@@ -146,7 +146,7 @@ public class LinkedHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>
|
||||
@Override
|
||||
public V remove(final Object key) {
|
||||
final Entry<K, V>[] table = this.table;
|
||||
final int hash = HashUtil.hash(key, hashingStrategy);
|
||||
final int hash = HashUtil.hash((K)key, hashingStrategy);
|
||||
final int index = hash % table.length;
|
||||
Entry<K, V> e = table[index];
|
||||
if (e == null) {
|
||||
@@ -395,7 +395,7 @@ public class LinkedHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return LinkedHashMap.this.containsKey(o);
|
||||
return containsKey(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user