mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-psi-impl] use Couple
This commit is contained in:
+6
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.impl.source.resolve.graphInference;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.constraints.ConstraintFormula;
|
||||
@@ -305,9 +306,9 @@ public class InferenceIncorporationPhase {
|
||||
* then for all i, 1 ≤ i ≤ n, if Si and Ti are types (not wildcards), the constraint ⟨Si = Ti⟩ is implied.
|
||||
*/
|
||||
private boolean upUp(List<PsiType> upperBounds) {
|
||||
return findParameterizationOfTheSameGenericClass(upperBounds, new Processor<Pair<PsiType, PsiType>>() {
|
||||
return findParameterizationOfTheSameGenericClass(upperBounds, new Processor<Couple<PsiType>>() {
|
||||
@Override
|
||||
public boolean process(Pair<PsiType, PsiType> pair) {
|
||||
public boolean process(Couple<PsiType> pair) {
|
||||
final PsiType sType = pair.first;
|
||||
final PsiType tType = pair.second;
|
||||
if (!mySession.isProperType(sType) && !mySession.isProperType(tType)) {
|
||||
@@ -320,7 +321,7 @@ public class InferenceIncorporationPhase {
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean findParameterizationOfTheSameGenericClass(List<PsiType> upperBounds, Processor<Pair<PsiType, PsiType>> processor) {
|
||||
public static boolean findParameterizationOfTheSameGenericClass(List<PsiType> upperBounds, Processor<Couple<PsiType>> processor) {
|
||||
for (int i = 0; i < upperBounds.size(); i++) {
|
||||
final PsiType sBound = upperBounds.get(i);
|
||||
final PsiClass sClass = PsiUtil.resolveClassInClassTypeOnly(sBound);
|
||||
@@ -342,7 +343,7 @@ public class InferenceIncorporationPhase {
|
||||
for (PsiTypeParameter typeParameter : gClass.getTypeParameters()) {
|
||||
final PsiType sType = sSubstitutor.substitute(typeParameter);
|
||||
final PsiType tType = tSubstitutor.substitute(typeParameter);
|
||||
if (!processor.process(Pair.create(sType, tType))) {
|
||||
if (!processor.process(Couple.newOne(sType, tType))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,8 +17,8 @@ package com.intellij.psi.impl.source.resolve.graphInference;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.constraints.*;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
@@ -476,9 +476,9 @@ public class InferenceSession {
|
||||
private static boolean hasWildcardParameterization(InferenceVariable inferenceVariable, PsiClassType targetType) {
|
||||
if (!FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) {
|
||||
final List<PsiType> bounds = inferenceVariable.getBounds(InferenceBound.LOWER);
|
||||
final Processor<Pair<PsiType, PsiType>> differentParameterizationProcessor = new Processor<Pair<PsiType, PsiType>>() {
|
||||
final Processor<Couple<PsiType>> differentParameterizationProcessor = new Processor<Couple<PsiType>>() {
|
||||
@Override
|
||||
public boolean process(Pair<PsiType, PsiType> pair) {
|
||||
public boolean process(Couple<PsiType> pair) {
|
||||
return pair.first == null || pair.second == null || pair.first.equals(pair.second);
|
||||
}
|
||||
};
|
||||
@@ -723,9 +723,9 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
private PsiType getLowerBound(InferenceVariable var, PsiSubstitutor substitutor) {
|
||||
return composeBound(var, InferenceBound.LOWER, new Function<Pair<PsiType, PsiType>, PsiType>() {
|
||||
return composeBound(var, InferenceBound.LOWER, new Function<Couple<PsiType>, PsiType>() {
|
||||
@Override
|
||||
public PsiType fun(Pair<PsiType, PsiType> pair) {
|
||||
public PsiType fun(Couple<PsiType> pair) {
|
||||
return GenericsUtil.getLeastUpperBound(pair.first, pair.second, myManager);
|
||||
}
|
||||
}, substitutor);
|
||||
@@ -755,18 +755,18 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
private PsiType getUpperBound(InferenceVariable var, PsiSubstitutor substitutor) {
|
||||
return composeBound(var, InferenceBound.UPPER, new Function<Pair<PsiType, PsiType>, PsiType>() {
|
||||
return composeBound(var, InferenceBound.UPPER, new Function<Couple<PsiType>, PsiType>() {
|
||||
@Override
|
||||
public PsiType fun(Pair<PsiType, PsiType> pair) {
|
||||
public PsiType fun(Couple<PsiType> pair) {
|
||||
return GenericsUtil.getGreatestLowerBound(pair.first, pair.second);
|
||||
}
|
||||
}, substitutor);
|
||||
}
|
||||
|
||||
public PsiType getEqualsBound(InferenceVariable var, PsiSubstitutor substitutor) {
|
||||
return composeBound(var, InferenceBound.EQ, new Function<Pair<PsiType, PsiType>, PsiType>() {
|
||||
return composeBound(var, InferenceBound.EQ, new Function<Couple<PsiType>, PsiType>() {
|
||||
@Override
|
||||
public PsiType fun(Pair<PsiType, PsiType> pair) {
|
||||
public PsiType fun(Couple<PsiType> pair) {
|
||||
return pair.first; //todo check if equals
|
||||
}
|
||||
}, substitutor);
|
||||
@@ -774,7 +774,7 @@ public class InferenceSession {
|
||||
|
||||
private PsiType composeBound(InferenceVariable variable,
|
||||
InferenceBound boundType,
|
||||
Function<Pair<PsiType, PsiType>, PsiType> fun,
|
||||
Function<Couple<PsiType>, PsiType> fun,
|
||||
PsiSubstitutor substitutor) {
|
||||
final List<PsiType> lowerBounds = variable.getBounds(boundType);
|
||||
PsiType lub = PsiType.NULL;
|
||||
@@ -789,7 +789,7 @@ public class InferenceSession {
|
||||
lub = lowerBound;
|
||||
}
|
||||
else {
|
||||
lub = fun.fun(Pair.create(lub, lowerBound));
|
||||
lub = fun.fun(Couple.newOne(lub, lowerBound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.psi.impl.source.tree.java;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
@@ -92,7 +92,7 @@ public class PsiCodeBlockImpl extends LazyParseablePsiElement implements PsiCode
|
||||
|
||||
// return Pair(classes, locals) or null if there was conflict
|
||||
@Nullable
|
||||
private Pair<Set<String>, Set<String>> buildMaps() {
|
||||
private Couple<Set<String>> buildMaps() {
|
||||
Set<String> set1 = myClassesSet;
|
||||
Set<String> set2 = myVariablesSet;
|
||||
boolean wasConflict = myConflict;
|
||||
@@ -129,7 +129,7 @@ public class PsiCodeBlockImpl extends LazyParseablePsiElement implements PsiCode
|
||||
myVariablesSet = set2 = localsSet.isEmpty() ? Collections.<String>emptySet() : localsSet;
|
||||
myConflict = wasConflict = conflict.get();
|
||||
}
|
||||
return wasConflict ? null : Pair.create(set1, set2);
|
||||
return wasConflict ? null : Couple.newOne(set1, set2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +218,7 @@ public class PsiCodeBlockImpl extends LazyParseablePsiElement implements PsiCode
|
||||
// Parent element should not see our vars
|
||||
return true;
|
||||
}
|
||||
Pair<Set<String>, Set<String>> pair = buildMaps();
|
||||
Couple<Set<String>> pair = buildMaps();
|
||||
boolean conflict = pair == null;
|
||||
final Set<String> classesSet = conflict ? null : pair.getFirst();
|
||||
final Set<String> variablesSet = conflict ? null : pair.getSecond();
|
||||
|
||||
Reference in New Issue
Block a user