diff --git a/java/java-impl/src/com/intellij/psi/impl/EmptySubstitutorImpl.java b/java/java-impl/src/com/intellij/psi/impl/EmptySubstitutorImpl.java index 4dcb6ebbba09..25f6718202f6 100644 --- a/java/java-impl/src/com/intellij/psi/impl/EmptySubstitutorImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/EmptySubstitutorImpl.java @@ -38,13 +38,12 @@ public final class EmptySubstitutorImpl extends EmptySubstitutor { } public PsiSubstitutor put(PsiTypeParameter classParameter, PsiType mapping){ - final PsiSubstitutor substitutor = new PsiSubstitutorImpl(); - return substitutor.put(classParameter, mapping); + return new PsiSubstitutorImpl(classParameter, mapping); } + public PsiSubstitutor putAll(PsiClass parentClass, PsiType[] mappings){ if(!parentClass.hasTypeParameters()) return this; - final PsiSubstitutor substitutor = new PsiSubstitutorImpl(); - return substitutor.putAll(parentClass, mappings); + return new PsiSubstitutorImpl(parentClass, mappings); } public PsiSubstitutor putAll(PsiSubstitutor another) { diff --git a/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java index 3c8ddda9659b..ac2afc346ab8 100644 --- a/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java @@ -59,6 +59,16 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { mySubstitutionMap = new THashMap(2, PSI_EQUIVALENCE); } + PsiSubstitutorImpl(@NotNull PsiTypeParameter typeParameter, PsiType mapping) { + this(); + mySubstitutionMap.put(typeParameter, mapping); + } + + PsiSubstitutorImpl(@NotNull PsiClass parentClass, PsiType[] mappings) { + this(); + putAllInternal(parentClass, mappings); + } + public PsiType substitute(@NotNull PsiTypeParameter typeParameter) { if (containsInMap(typeParameter)) { return getFromMap(typeParameter); @@ -353,26 +363,30 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { return new PsiSubstitutorImpl(mySubstitutionMap); } - public synchronized PsiSubstitutor put(@NotNull PsiTypeParameter typeParameter, PsiType mapping) { + public PsiSubstitutor put(@NotNull PsiTypeParameter typeParameter, PsiType mapping) { PsiSubstitutorImpl ret = clone(); ret.mySubstitutionMap.put(typeParameter, mapping); return ret; } - public synchronized PsiSubstitutor putAll(@NotNull PsiClass parentClass, PsiType[] mappings) { + private void putAllInternal(@NotNull PsiClass parentClass, PsiType[] mappings) { final PsiTypeParameter[] params = parentClass.getTypeParameters(); - PsiSubstitutorImpl substitutor = clone(); + for (int i = 0; i < params.length; i++) { PsiTypeParameter param = params[i]; assert param != null; if (mappings != null && mappings.length > i) { - substitutor.mySubstitutionMap.put(param, mappings[i]); + mySubstitutionMap.put(param, mappings[i]); } else { - substitutor.mySubstitutionMap.put(param, null); + mySubstitutionMap.put(param, null); } } + } + public PsiSubstitutor putAll(@NotNull PsiClass parentClass, PsiType[] mappings) { + PsiSubstitutorImpl substitutor = clone(); + substitutor.putAllInternal(parentClass, mappings); return substitutor; } diff --git a/platform/funcTests/project1/.idea/vcs.xml b/platform/funcTests/project1/.idea/vcs.xml index f05d78fd07e1..def6a6a18457 100644 --- a/platform/funcTests/project1/.idea/vcs.xml +++ b/platform/funcTests/project1/.idea/vcs.xml @@ -1,8 +1,5 @@ - - diff --git a/platform/funcTests/project1/.idea/workspace.xml b/platform/funcTests/project1/.idea/workspace.xml index 645d39a9b216..470bc5e4dcfb 100644 --- a/platform/funcTests/project1/.idea/workspace.xml +++ b/platform/funcTests/project1/.idea/workspace.xml @@ -71,17 +71,7 @@ - - - - - - - - - - - + @@ -100,10 +90,10 @@ - @@ -118,7 +108,7 @@ - @@ -133,7 +123,6 @@ - @@ -210,6 +199,7 @@ + @@ -227,8 +217,8 @@ - + @@ -252,7 +242,6 @@ - + @@ -371,16 +360,19 @@ - - + + + +