mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
don't calculate completion proximity on EDT
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public interface ForceableComparable {
|
||||
void force();
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class WeighingComparable<T,Loc> implements Comparable<WeighingComparable<T,Loc>> {
|
||||
public class WeighingComparable<T,Loc> implements Comparable<WeighingComparable<T,Loc>>, ForceableComparable {
|
||||
private static final Comparable NULL = new Comparable() {
|
||||
public int compareTo(final Object o) {
|
||||
throw new UnsupportedOperationException("Method compareTo is not yet implemented in " + getClass().getName());
|
||||
@@ -45,8 +45,8 @@ public class WeighingComparable<T,Loc> implements Comparable<WeighingComparable<
|
||||
public void force() {
|
||||
for (int i = 0; i < myComputedWeighs.length; i++) {
|
||||
Comparable weight = getWeight(i);
|
||||
if (weight instanceof WeighingComparable) {
|
||||
((WeighingComparable)weight).force();
|
||||
if (weight instanceof ForceableComparable) {
|
||||
((ForceableComparable)weight).force();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -15,16 +15,25 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion.impl;
|
||||
|
||||
import com.intellij.psi.ForceableComparable;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class NegatingComparable<T extends NegatingComparable<T>> implements Comparable<T> {
|
||||
public class NegatingComparable<T extends NegatingComparable<T>> implements Comparable<T>, ForceableComparable {
|
||||
private final Comparable myWeigh;
|
||||
|
||||
public NegatingComparable(Comparable weigh) {
|
||||
myWeigh = weigh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void force() {
|
||||
if (myWeigh instanceof ForceableComparable) {
|
||||
((ForceableComparable)myWeigh).force();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(T o) {
|
||||
final Comparable w1 = myWeigh;
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.lookup;
|
||||
|
||||
import com.intellij.psi.WeighingComparable;
|
||||
import com.intellij.psi.ForceableComparable;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,8 +47,8 @@ public class CachingComparingClassifier extends ComparingClassifier<LookupElemen
|
||||
@Override
|
||||
public void addElement(LookupElement t) {
|
||||
Comparable weight = myWeigher.weigh(t);
|
||||
if (weight instanceof WeighingComparable) {
|
||||
((WeighingComparable)weight).force();
|
||||
if (weight instanceof ForceableComparable) {
|
||||
((ForceableComparable)weight).force();
|
||||
}
|
||||
myWeights.put(t, weight);
|
||||
super.addElement(t);
|
||||
|
||||
Reference in New Issue
Block a user