method chain completion: rename

This commit is contained in:
Dmitry Batkovich
2017-05-15 17:03:57 +03:00
parent 0fcbe62730
commit ba7f988b9b
7 changed files with 21 additions and 21 deletions
@@ -247,7 +247,7 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceServiceEx imp
count);
}))
.filter(Objects::nonNull)
.collect(Collectors.groupingBy(x -> x.getUnderlying(), Collectors.summarizingInt(x -> x.getOccurrences())))
.collect(Collectors.groupingBy(x -> x.getUnderlying(), Collectors.summarizingInt(x -> x.getOccurrenceCount())))
.entrySet()
.stream()
.map(e -> new OccurrencesAware<>(e.getKey(), (int)e.getValue().getSum()))
@@ -80,8 +80,8 @@ public class ChainSearcher {
.getVertices()
.stream()
.map(
signAndWeight -> new OccurrencesAware<>(MethodChain.create(signAndWeight.getUnderlying(), signAndWeight.getOccurrences(), context),
signAndWeight.getOccurrences()))
signAndWeight -> new OccurrencesAware<>(MethodChain.create(signAndWeight.getUnderlying(), signAndWeight.getOccurrenceCount(), context),
signAndWeight.getOccurrenceCount()))
.filter(Objects::nonNull)
.collect(Collectors.toCollection(LinkedList::new));
@@ -89,7 +89,7 @@ public class ChainSearcher {
while (!q.isEmpty()) {
ProgressManager.checkCanceled();
OccurrencesAware<MethodChain> currentVertex = q.poll();
int currentVertexDistance = currentVertex.getOccurrences();
int currentVertexDistance = currentVertex.getOccurrenceCount();
MethodChain currentChain = currentVertex.getUnderlying();
MethodIncompleteSignature headSignature = currentChain.getHeadSignature();
MethodChain currentVertexMethodChain = knownDistance.get(headSignature);
@@ -107,12 +107,12 @@ public class ChainSearcher {
String targetQName = context.getTarget().getClassQName();
for (OccurrencesAware<MethodIncompleteSignature> indexValue : nextMethods) {
MethodIncompleteSignature vertex = indexValue.getUnderlying();
int occurrences = indexValue.getOccurrences();
int occurrences = indexValue.getOccurrenceCount();
if (vertex.isStatic() || !vertex.getOwner().equals(targetQName)) {
int vertexDistance = Math.min(currentVertexDistance, occurrences);
MethodChain knownVertexMethodChain = knownDistance.get(vertex);
if ((knownVertexMethodChain == null || knownVertexMethodChain.getChainWeight() < vertexDistance)) {
if (currentSignatures.isEmpty() || currentSignatures.last().getOccurrences() < vertexDistance) {
if (currentSignatures.isEmpty() || currentSignatures.last().getOccurrenceCount() < vertexDistance) {
if (currentVertexMethodChain.size() < pathMaximalLength - 1) {
MethodChain newBestMethodChain =
currentVertexMethodChain.continuation(indexValue.getUnderlying(), vertexDistance, context);
@@ -138,7 +138,7 @@ public class ChainSearcher {
boolean stopChain = sign.getUnderlying().isStatic() || context.hasQualifier(context.resolveQualifierClass(sign.getUnderlying()));
if (stopChain) {
updated = true;
MethodChain continuation = currentChain.continuation(sign.getUnderlying(), sign.getOccurrences(), context);
MethodChain continuation = currentChain.continuation(sign.getUnderlying(), sign.getOccurrenceCount(), context);
if (continuation != null) {
result.add(continuation);
}
@@ -147,9 +147,9 @@ public class ChainSearcher {
else {
updated = true;
MethodChain methodChain =
currentChain.continuation(sign.getUnderlying(), sign.getOccurrences(), context);
currentChain.continuation(sign.getUnderlying(), sign.getOccurrenceCount(), context);
if (methodChain != null) {
q.addFirst(new OccurrencesAware<>(methodChain, sign.getOccurrences()));
q.addFirst(new OccurrencesAware<>(methodChain, sign.getOccurrenceCount()));
continue;
}
}
@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING;
public class MethodsChainLookupRangingHelper {
public class MethodChainLookupRangingHelper {
@Nullable
public static LookupElement chainToWeightableLookupElement(MethodChain chain,
ChainCompletionContext context) {
@@ -30,13 +30,13 @@ public class OccurrencesAware<V> implements Comparable<OccurrencesAware<V>> {
return myUnderlying;
}
public int getOccurrences() {
public int getOccurrenceCount() {
return myOccurrences;
}
@Override
public int compareTo(@NotNull final OccurrencesAware<V> that) {
final int sub = -getOccurrences() + that.getOccurrences();
final int sub = -getOccurrenceCount() + that.getOccurrenceCount();
if (sub != 0) {
return sub;
}
@@ -45,6 +45,6 @@ public class OccurrencesAware<V> implements Comparable<OccurrencesAware<V>> {
@Override
public String toString() {
return getOccurrences() + " for " + myUnderlying;
return getOccurrenceCount() + " for " + myUnderlying;
}
}
@@ -37,7 +37,7 @@ public class SearchInitializer {
int bestOccurrences = -1;
for (OccurrencesAware<MethodIncompleteSignature> indexValue : indexValues) {
if (add(indexValue)) {
int occurrences = indexValue.getOccurrences();
int occurrences = indexValue.getOccurrenceCount();
if (bestOccurrences == -1) {
bestOccurrences = occurrences;
}
@@ -50,7 +50,7 @@ public class SearchInitializer {
private boolean add(OccurrencesAware<MethodIncompleteSignature> indexValue) {
MethodIncompleteSignature methodInvocation = indexValue.getUnderlying();
int occurrences = indexValue.getOccurrences();
int occurrences = indexValue.getOccurrenceCount();
MethodChain methodChain = MethodChain.create(indexValue.getUnderlying(), occurrences, myContext);
if (methodChain != null) {
myChains.put(methodInvocation, Pair.create(methodChain, occurrences));
@@ -23,7 +23,7 @@ import com.intellij.compiler.backwardRefs.ReferenceIndexUnavailableException;
import com.intellij.compiler.chainsSearch.ChainSearchMagicConstants;
import com.intellij.compiler.chainsSearch.ChainSearcher;
import com.intellij.compiler.chainsSearch.MethodChain;
import com.intellij.compiler.chainsSearch.MethodsChainLookupRangingHelper;
import com.intellij.compiler.chainsSearch.MethodChainLookupRangingHelper;
import com.intellij.compiler.chainsSearch.context.ChainCompletionContext;
import com.intellij.compiler.chainsSearch.context.ChainSearchTarget;
import com.intellij.openapi.application.ApplicationManager;
@@ -111,7 +111,7 @@ public class MethodChainCompletionContributor extends CompletionContributor {
return searchResult
.stream()
.filter(ch -> ch.getChainWeight() * ChainSearchMagicConstants.FILTER_RATIO >= maxWeight)
.map(ch -> MethodsChainLookupRangingHelper.chainToWeightableLookupElement(ch, context))
.map(ch -> MethodChainLookupRangingHelper.chainToWeightableLookupElement(ch, context))
.collect(Collectors.toList());
}
@@ -38,10 +38,10 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ChainCompletionContext {
private static final String[] WIDE_USED_CLASS_NAMES = new String [] {CommonClassNames.JAVA_LANG_STRING,
private static final String[] WIDELY_USED_CLASS_NAMES = new String [] {CommonClassNames.JAVA_LANG_STRING,
CommonClassNames.JAVA_LANG_OBJECT,
CommonClassNames.JAVA_LANG_CLASS};
private static final Set<String> WIDE_USED_SHORT_NAMES = ContainerUtil.set("String", "Object", "Class");
private static final Set<String> WIDELY_USED_SHORT_NAMES = ContainerUtil.set("String", "Object", "Class");
@NotNull
private final ChainSearchTarget myTarget;
@@ -260,12 +260,12 @@ public class ChainCompletionContext {
type = type.getDeepComponentType();
if (type instanceof PsiPrimitiveType) return true;
if (!(type instanceof PsiClassType)) return false;
if (WIDE_USED_SHORT_NAMES.contains(((PsiClassType)type).getClassName())) return false;
if (WIDELY_USED_SHORT_NAMES.contains(((PsiClassType)type).getClassName())) return false;
final PsiClass resolvedClass = ((PsiClassType)type).resolve();
if (resolvedClass == null) return false;
final String qName = resolvedClass.getQualifiedName();
if (qName == null) return false;
for (String name : WIDE_USED_CLASS_NAMES) {
for (String name : WIDELY_USED_CLASS_NAMES) {
if (name.equals(qName)) {
return true;
}