diff options
Diffstat (limited to 'java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder')
3 files changed, 36 insertions, 35 deletions
diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/ReductionSystem.java b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/ReductionSystem.java index 271c686b7fa9..a23d6d033c74 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/ReductionSystem.java +++ b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/ReductionSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -31,19 +31,19 @@ import java.util.*; * @author db */ public class ReductionSystem { - final HashSet<Constraint> myConstraints = new HashSet<Constraint>(); - final HashSet<PsiElement> myElements; - final HashMap<PsiTypeCastExpression, PsiType> myCastToOperandType; - final HashMap<PsiElement, PsiType> myTypes; + final Set<Constraint> myConstraints = new HashSet<Constraint>(); + final Set<PsiElement> myElements; + final Map<PsiTypeCastExpression, PsiType> myCastToOperandType; + final Map<PsiElement, PsiType> myTypes; final PsiTypeVariableFactory myTypeVariableFactory; final Project myProject; final Settings mySettings; - HashSet<PsiTypeVariable> myBoundVariables; + Set<PsiTypeVariable> myBoundVariables; public ReductionSystem(final Project project, - final HashSet<PsiElement> elements, - final HashMap<PsiElement, PsiType> types, + final Set<PsiElement> elements, + final Map<PsiElement, PsiType> types, final PsiTypeVariableFactory factory, final Settings settings) { myProject = project; @@ -59,7 +59,7 @@ public class ReductionSystem { return myProject; } - public HashSet<Constraint> getConstraints() { + public Set<Constraint> getConstraints() { return myConstraints; } @@ -165,7 +165,7 @@ public class ReductionSystem { class Node { int myComponent = -1; Constraint myConstraint; - HashSet<Node> myNeighbours = new HashSet<Node>(); + Set<Node> myNeighbours = new HashSet<Node>(); public Node() { myConstraint = null; @@ -189,7 +189,7 @@ public class ReductionSystem { final Node[] typeVariableNodes = new Node[myTypeVariableFactory.getNumber()]; final Node[] constraintNodes = new Node[myConstraints.size()]; - final HashMap<Constraint, HashSet<PsiTypeVariable>> boundVariables = new HashMap<Constraint, HashSet<PsiTypeVariable>>(); + final Map<Constraint, Set<PsiTypeVariable>> boundVariables = new HashMap<Constraint, Set<PsiTypeVariable>>(); for (int i = 0; i < typeVariableNodes.length; i++) { typeVariableNodes[i] = new Node(); @@ -207,7 +207,7 @@ public class ReductionSystem { int l = 0; for (final Constraint constraint : myConstraints) { - final HashSet<PsiTypeVariable> boundVars = new HashSet<PsiTypeVariable>(); + final Set<PsiTypeVariable> boundVars = new LinkedHashSet<PsiTypeVariable>(); final Node constraintNode = constraintNodes[l++]; new Object() { @@ -266,9 +266,9 @@ public class ReductionSystem { } } - final LinkedList<HashSet<PsiTypeVariable>> clusters = myTypeVariableFactory.getClusters(); + List<Set<PsiTypeVariable>> clusters = myTypeVariableFactory.getClusters(); - for (final HashSet<PsiTypeVariable> cluster : clusters) { + for (final Set<PsiTypeVariable> cluster : clusters) { Node prev = null; for (final PsiTypeVariable variable : cluster) { @@ -327,7 +327,7 @@ public class ReductionSystem { return systems; } - private void addConstraint(final Constraint constraint, final HashSet<PsiTypeVariable> vars) { + private void addConstraint(final Constraint constraint, final Set<PsiTypeVariable> vars) { if (myBoundVariables == null) { myBoundVariables = vars; } @@ -342,7 +342,7 @@ public class ReductionSystem { return myTypeVariableFactory; } - public HashSet<PsiTypeVariable> getBoundVariables() { + public Set<PsiTypeVariable> getBoundVariables() { return myBoundVariables; } diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/Result.java b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/Result.java index 31e67a451e7f..a74fc23261e3 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/Result.java +++ b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/Result.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -25,9 +25,9 @@ import com.intellij.refactoring.typeCook.deductive.resolver.Binding; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * @author db @@ -35,10 +35,10 @@ import java.util.Map; public class Result { private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.typeCook.deductive.builder.Result"); - private final HashSet<PsiElement> myVictims; - private final HashMap<PsiElement, PsiType> myTypes; + private final Set<PsiElement> myVictims; + private final Map<PsiElement, PsiType> myTypes; private final Settings mySettings; - private final HashMap<PsiTypeCastExpression, PsiType> myCastToOperandType; + private final Map<PsiTypeCastExpression, PsiType> myCastToOperandType; private int myCookedNumber = -1; private int myCastsRemoved = -1; @@ -92,10 +92,10 @@ public class Result { return originalType; } - public HashSet<PsiElement> getCookedElements() { + public Set<PsiElement> getCookedElements() { myCookedNumber = 0; - final HashSet<PsiElement> set = new HashSet<PsiElement>(); + final Set<PsiElement> set = new HashSet<PsiElement>(); for (final PsiElement element : myVictims) { final PsiType originalType = Util.getType(element); @@ -137,7 +137,7 @@ public class Result { return false; } - public void apply(final HashSet<PsiElement> victims) { + public void apply(final Set<PsiElement> victims) { for (final PsiElement element : victims) { if (element instanceof PsiTypeCastExpression && myCastToOperandType.containsKey(element)) { final PsiTypeCastExpression cast = ((PsiTypeCastExpression)element); diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/SystemBuilder.java b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/SystemBuilder.java index 2cd9045ba121..8b0514143ba6 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/SystemBuilder.java +++ b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/builder/SystemBuilder.java @@ -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. @@ -37,6 +37,7 @@ import com.intellij.util.containers.HashMap; import java.util.Arrays; import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * Created by IntelliJ IDEA. @@ -49,11 +50,11 @@ public class SystemBuilder { private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.typeCook.deductive.builder.SystemBuilder"); private final PsiManager myManager; - private final HashMap<PsiElement, Boolean> myMethodCache; - private final HashMap<PsiParameter, PsiParameter> myParameters; - private final HashMap<PsiMethod, PsiMethod> myMethods; - private final HashMap<PsiElement, PsiType> myTypes; - private final HashSet<PsiAnchor> myVisitedConstructions; + private final Map<PsiElement, Boolean> myMethodCache; + private final Map<PsiParameter, PsiParameter> myParameters; + private final Map<PsiMethod, PsiMethod> myMethods; + private final Map<PsiElement, PsiType> myTypes; + private final Set<PsiAnchor> myVisitedConstructions; private final Settings mySettings; private final PsiTypeVariableFactory myTypeVariableFactory; private final Project myProject; @@ -70,11 +71,11 @@ public class SystemBuilder { myTypeVariableFactory = new PsiTypeVariableFactory(); } - private HashSet<PsiElement> collect(final PsiElement[] scopes) { + private Set<PsiElement> collect(final PsiElement[] scopes) { return new VictimCollector(scopes, mySettings).getVictims(); } - private boolean verifyMethod(final PsiElement element, final HashSet<PsiElement> victims, final PsiSearchHelper helper) { + private boolean verifyMethod(final PsiElement element, final Set<PsiElement> victims, final PsiSearchHelper helper) { PsiMethod method; PsiParameter parameter = null; int index = 0; @@ -352,7 +353,7 @@ public class SystemBuilder { final PsiExpression qualifier = expr instanceof PsiMethodCallExpression ? ((PsiMethodCallExpression)expr).getMethodExpression().getQualifierExpression() : null; - final HashSet<PsiTypeParameter> typeParameters = new HashSet<PsiTypeParameter>(Arrays.asList(methodTypeParameters)); + final Set<PsiTypeParameter> typeParameters = new HashSet<PsiTypeParameter>(Arrays.asList(methodTypeParameters)); PsiSubstitutor qualifierSubstitutor = PsiSubstitutor.EMPTY; PsiSubstitutor supertypeSubstitutor = PsiSubstitutor.EMPTY; @@ -397,7 +398,7 @@ public class SystemBuilder { } } - final HashMap<PsiTypeParameter, PsiType> mapping = new HashMap<PsiTypeParameter, PsiType>(); + final Map<PsiTypeParameter, PsiType> mapping = new HashMap<PsiTypeParameter, PsiType>(); for (int i = 0; i < Math.min(parameters.length, arguments.length); i++) { final PsiType argumentType = evaluateType(arguments[i], system); @@ -913,7 +914,7 @@ public class SystemBuilder { return build(collect(scopes)); } - public ReductionSystem build(final HashSet<PsiElement> victims) { + public ReductionSystem build(final Set<PsiElement> victims) { final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject()); ReductionSystem system = new ReductionSystem(myProject, victims, myTypes, myTypeVariableFactory, mySettings); |