mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use a map with a stable order in GrMapType to fix tests
This commit is contained in:
+5
-5
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
@@ -94,7 +94,7 @@ public abstract class GrMapType extends GrLiteralClassType {
|
||||
protected abstract List<Couple<PsiType>> getOtherEntries();
|
||||
|
||||
@NotNull
|
||||
protected abstract Map<String, PsiType> getStringEntries();
|
||||
protected abstract LinkedHashMap<String, PsiType> getStringEntries();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -149,7 +149,7 @@ public abstract class GrMapType extends GrLiteralClassType {
|
||||
public static GrMapType merge(GrMapType l, GrMapType r) {
|
||||
final GlobalSearchScope scope = l.getScope().intersectWith(r.getResolveScope());
|
||||
|
||||
final Map<String, PsiType> strings = new HashMap<String, PsiType>();
|
||||
final LinkedHashMap<String, PsiType> strings = ContainerUtil.newLinkedHashMap();
|
||||
strings.putAll(l.getStringEntries());
|
||||
strings.putAll(r.getStringEntries());
|
||||
|
||||
@@ -162,7 +162,7 @@ public abstract class GrMapType extends GrLiteralClassType {
|
||||
|
||||
public static GrMapType create(JavaPsiFacade facade,
|
||||
GlobalSearchScope scope,
|
||||
Map<String, PsiType> stringEntries,
|
||||
LinkedHashMap<String, PsiType> stringEntries,
|
||||
List<Couple<PsiType>> otherEntries) {
|
||||
return new GrMapTypeImpl(facade, scope, stringEntries, otherEntries, LanguageLevel.JDK_1_5);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public abstract class GrMapType extends GrLiteralClassType {
|
||||
public static GrMapType create(GlobalSearchScope scope) {
|
||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(scope.getProject());
|
||||
List<Couple<PsiType>> otherEntries = Collections.emptyList();
|
||||
Map<String, PsiType> stringEntries = Collections.emptyMap();
|
||||
LinkedHashMap<String, PsiType> stringEntries = ContainerUtil.newLinkedHashMap();
|
||||
return new GrMapTypeImpl(facade, scope, stringEntries, otherEntries, LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
|
||||
+7
-10
@@ -32,17 +32,14 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgument
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by Max Medvedev on 07/04/14
|
||||
*/
|
||||
public class GrMapTypeFromNamedArgs extends GrMapType {
|
||||
|
||||
private final Map<String, GrExpression> myStringEntries;
|
||||
private final LinkedHashMap<String, GrExpression> myStringEntries;
|
||||
private final List<Couple<GrExpression>> myOtherEntries;
|
||||
|
||||
private final VolatileNotNullLazyValue<List<Couple<PsiType>>> myTypesOfOtherEntries = new VolatileNotNullLazyValue<List<Couple<PsiType>>>() {
|
||||
@@ -58,11 +55,11 @@ public class GrMapTypeFromNamedArgs extends GrMapType {
|
||||
}
|
||||
};
|
||||
|
||||
private final VolatileNotNullLazyValue<Map<String, PsiType>> myTypesOfStringEntries = new VolatileNotNullLazyValue<Map<String,PsiType>>() {
|
||||
private final VolatileNotNullLazyValue<LinkedHashMap<String, PsiType>> myTypesOfStringEntries = new VolatileNotNullLazyValue<LinkedHashMap<String,PsiType>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<String, PsiType> compute() {
|
||||
HashMap<String, PsiType> result = ContainerUtil.newHashMap();
|
||||
protected LinkedHashMap<String, PsiType> compute() {
|
||||
LinkedHashMap<String, PsiType> result = ContainerUtil.newLinkedHashMap();
|
||||
for (Map.Entry<String, GrExpression> entry : myStringEntries.entrySet()) {
|
||||
result.put(entry.getKey(), inferTypePreventingRecursion(entry.getValue()));
|
||||
}
|
||||
@@ -78,7 +75,7 @@ public class GrMapTypeFromNamedArgs extends GrMapType {
|
||||
public GrMapTypeFromNamedArgs(@NotNull JavaPsiFacade facade, @NotNull GlobalSearchScope scope, @NotNull GrNamedArgument[] namedArgs) {
|
||||
super(facade, scope);
|
||||
|
||||
myStringEntries = ContainerUtil.newHashMap();
|
||||
myStringEntries = ContainerUtil.newLinkedHashMap();
|
||||
myOtherEntries = ContainerUtil.newArrayList();
|
||||
for (GrNamedArgument namedArg : namedArgs) {
|
||||
final GrArgumentLabel label = namedArg.getLabel();
|
||||
@@ -161,7 +158,7 @@ public class GrMapTypeFromNamedArgs extends GrMapType {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<String, PsiType> getStringEntries() {
|
||||
protected LinkedHashMap<String, PsiType> getStringEntries() {
|
||||
return myTypesOfStringEntries.getValue();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -25,20 +25,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by Max Medvedev on 07/04/14
|
||||
*/
|
||||
public class GrMapTypeImpl extends GrMapType {
|
||||
private final Map<String, PsiType> myStringEntries;
|
||||
private final LinkedHashMap<String, PsiType> myStringEntries;
|
||||
private final List<Couple<PsiType>> myOtherEntries;
|
||||
|
||||
GrMapTypeImpl(JavaPsiFacade facade,
|
||||
GlobalSearchScope scope,
|
||||
Map<String, PsiType> stringEntries,
|
||||
LinkedHashMap<String, PsiType> stringEntries,
|
||||
List<Couple<PsiType>> otherEntries,
|
||||
LanguageLevel languageLevel) {
|
||||
super(facade, scope, languageLevel);
|
||||
@@ -92,7 +92,7 @@ public class GrMapTypeImpl extends GrMapType {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<String, PsiType> getStringEntries() {
|
||||
protected LinkedHashMap<String, PsiType> getStringEntries() {
|
||||
return myStringEntries;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class FooBool {
|
||||
b = ["true"]
|
||||
b = [true]
|
||||
b = [1] as List
|
||||
b = <error descr="Constructor 'Boolean' in 'java.lang.Boolean' cannot be applied to '(['b':java.lang.Integer, 'c':java.lang.Integer,...])'">[a: 1, b: 2, c: 3]</error>
|
||||
b = <error descr="Constructor 'Boolean' in 'java.lang.Boolean' cannot be applied to '(['a':java.lang.Integer, 'b':java.lang.Integer,...])'">[a: 1, b: 2, c: 3]</error>
|
||||
b = [a: 1, b: 2, c: 3] as Map
|
||||
b = [a: 1, b: 2, c: 3] as List
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class FooBool {
|
||||
boolean b20 = [] as List
|
||||
boolean b21 = <error descr="Constructor 'Boolean' in 'java.lang.Boolean' cannot be applied to '(java.lang.Integer, java.lang.Integer, java.lang.Integer)'">[1, 2, 3]</error>
|
||||
boolean b22 = [1, 2, 3] as List
|
||||
boolean b23 = <error descr="Constructor 'Boolean' in 'java.lang.Boolean' cannot be applied to '(['b':java.lang.Integer, 'c':java.lang.Integer,...])'">[a: 1, b: 2, c: 3]</error>
|
||||
boolean b23 = <error descr="Constructor 'Boolean' in 'java.lang.Boolean' cannot be applied to '(['a':java.lang.Integer, 'b':java.lang.Integer,...])'">[a: 1, b: 2, c: 3]</error>
|
||||
boolean b24 = [a: 1, b: 2, c: 3] as Map
|
||||
boolean b25 = [a: 1, b: 2, c: 3] as List
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user