let GrMapType always be LinkedHashMap, thus avoid a costly check at its creation

This commit is contained in:
peter
2015-10-06 16:59:10 +02:00
parent 2f00162511
commit 17aefed9d3
2 changed files with 2 additions and 8 deletions
@@ -34,7 +34,6 @@ import java.util.*;
* @author peter
*/
public abstract class GrMapType extends GrLiteralClassType {
private final String myJavaClassName;
private final VolatileNotNullLazyValue<PsiType[]> myParameters = new VolatileNotNullLazyValue<PsiType[]>() {
@NotNull
@@ -58,22 +57,18 @@ public abstract class GrMapType extends GrLiteralClassType {
GlobalSearchScope scope,
LanguageLevel languageLevel) {
super(languageLevel, scope, facade);
myJavaClassName = facade.findClass(
GroovyCommonClassNames.JAVA_UTIL_LINKED_HASH_MAP, scope) != null ? GroovyCommonClassNames.JAVA_UTIL_LINKED_HASH_MAP
: CommonClassNames.JAVA_UTIL_MAP;
}
@NotNull
@Override
protected String getJavaClassName() {
return myJavaClassName;
return GroovyCommonClassNames.JAVA_UTIL_LINKED_HASH_MAP;
}
@Override
@NotNull
public String getClassName() {
return StringUtil.getShortName(myJavaClassName);
return "LinkedHashMap";
}
@Nullable
@@ -192,7 +192,6 @@ public class GrListOrMapImpl extends GrExpressionImpl implements GrListOrMap {
GlobalSearchScope scope = listOrMap.getResolveScope();
JavaPsiFacade facade = JavaPsiFacade.getInstance(listOrMap.getProject());
PsiClass hashMap = facade.findClass(GroovyCommonClassNames.JAVA_UTIL_LINKED_HASH_MAP, scope);
if (hashMap == null) hashMap = facade.findClass(CommonClassNames.JAVA_UTIL_MAP, scope);
if (hashMap != null) {
PsiSubstitutor mapSubstitutor = PsiSubstitutor.EMPTY.
put(hashMap.getTypeParameters()[0], com.intellij.psi.util.PsiUtil.substituteTypeParameter(lType, CommonClassNames.JAVA_UTIL_MAP, 0, false)).