diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/ParameterObjectBuilder.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/ParameterObjectBuilder.java index ae0fc205a68c..ac91a848aae8 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/ParameterObjectBuilder.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/ParameterObjectBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -137,8 +137,8 @@ class ParameterObjectBuilder { out.append(CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_PARAMETERS ? " final " : ""); final String parameterName = parameter.getName(); final PsiType type = field.getType(); - final PsiType fieldType = parameter.isVarArgs() && type instanceof PsiArrayType ? - PsiEllipsisType.createEllipsis(((PsiArrayType)type).getComponentType(), PsiAnnotation.EMPTY_ARRAY) : type; + final PsiType fieldType = parameter.isVarArgs() && type instanceof PsiArrayType ? + new PsiEllipsisType(((PsiArrayType)type).getComponentType()) : type; out.append(' ' + fieldType.getCanonicalText() + ' ' + parameterName); if (iterator.hasNext()) { out.append(", "); diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java index aaf7141512ab..aa050b311359 100644 --- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -376,11 +376,14 @@ public class GenericsUtil { LOG.assertTrue(toPut == null || toPut.isValid(), toPut); substitutor = substitutor.put(typeParameter, toPut); } - final PsiAnnotation[] applicableAnnotations = classType.getApplicableAnnotations(); - if (substitutor == PsiSubstitutor.EMPTY && !toExtend && applicableAnnotations.length == 0 && !(aClass instanceof PsiTypeParameter)) return classType; + PsiAnnotation[] applicableAnnotations = classType.getApplicableAnnotations(); + if (substitutor == PsiSubstitutor.EMPTY && !toExtend && applicableAnnotations.length == 0 && !(aClass instanceof PsiTypeParameter)) { + return classType; + } PsiManager manager = aClass.getManager(); PsiType result = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory() - .createType(aClass, substitutor, PsiUtil.getLanguageLevel(aClass), applicableAnnotations); + .createType(aClass, substitutor, PsiUtil.getLanguageLevel(aClass)) + .annotate(TypeAnnotationProvider.Static.create(applicableAnnotations)); if (toExtend) result = PsiWildcardType.createExtends(manager, result); return result; } diff --git a/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java b/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java index 7c3999e37a7b..6b1f4f8532b5 100644 --- a/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java +++ b/java/java-psi-api/src/com/intellij/psi/JVMElementFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -34,7 +34,7 @@ public interface JVMElementFactory { * * @param name the name of the class to create. * @return the created class instance. - * @throws com.intellij.util.IncorrectOperationException + * @throws IncorrectOperationException * if name is not a valid Java identifier. */ @NotNull @@ -175,7 +175,7 @@ public interface JVMElementFactory { * * @param name the name of the annotation type to create. * @return the created annotation type instance. - * @throws com.intellij.util.IncorrectOperationException if name is not a valid Java identifier. + * @throws IncorrectOperationException if name is not a valid Java identifier. */ @NotNull PsiClass createAnnotationType(@NotNull @NonNls String name) throws IncorrectOperationException; @@ -201,13 +201,20 @@ public interface JVMElementFactory { @NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor); - /* - additional languageLevel parameter to memorize language level for allowing/prohibiting boxing/unboxing - */ + /** + * Creates a class type for the specified class, using the specified substitutor + * to replace generic type parameters on the class. + * + * @param resolve the class for which the class type is created. + * @param substitutor the substitutor to use. + * @param languageLevel to memorize language level for allowing/prohibiting boxing/unboxing. + * @return the class type instance. + */ @NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @NotNull LanguageLevel languageLevel); - @NotNull + /** @deprecated use {@link PsiType#annotate(TypeAnnotationProvider)} (to be removed in IDEA 18) */ + @SuppressWarnings("unused") PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @NotNull LanguageLevel languageLevel, diff --git a/java/java-psi-api/src/com/intellij/psi/PsiClassType.java b/java/java-psi-api/src/com/intellij/psi/PsiClassType.java index 5906e1d3c7c8..4c11523f2c46 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiClassType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiClassType.java @@ -55,6 +55,12 @@ public abstract class PsiClassType extends PsiType { myLanguageLevel = languageLevel; } + @NotNull + @Override + public PsiClassType annotate(@NotNull TypeAnnotationProvider provider) { + return (PsiClassType)super.annotate(provider); + } + /** * Resolves the class reference and returns the resulting class. * diff --git a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java index 41ac72898245..404a39672972 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java @@ -178,12 +178,6 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor @Override @NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @Nullable LanguageLevel languageLevel); - @Override - @NotNull PsiClassType createType(@NotNull PsiClass resolve, - @NotNull PsiSubstitutor substitutor, - @Nullable LanguageLevel languageLevel, - @NotNull PsiAnnotation[] annotations); - /** * Creates a class type for the specified reference pointing to a class. * diff --git a/java/java-psi-api/src/com/intellij/psi/PsiEllipsisType.java b/java/java-psi-api/src/com/intellij/psi/PsiEllipsisType.java index d7105defd1a2..0738462ee21c 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiEllipsisType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiEllipsisType.java @@ -41,7 +41,8 @@ public class PsiEllipsisType extends PsiArrayType { return provider == getAnnotationProvider() ? this : new PsiEllipsisType(getComponentType(), provider); } - @NotNull + /** @deprecated use {@link #annotate(TypeAnnotationProvider)} (to be removed in IDEA 18) */ + @SuppressWarnings("unused") public static PsiType createEllipsis(@NotNull PsiType componentType, @NotNull PsiAnnotation[] annotations) { return new PsiEllipsisType(componentType, annotations); } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiJavaParserFacade.java b/java/java-psi-api/src/com/intellij/psi/PsiJavaParserFacade.java index 70d7d3f46bd3..64fe93db80d4 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiJavaParserFacade.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiJavaParserFacade.java @@ -235,11 +235,14 @@ public interface PsiJavaParserFacade { /** * Creates a Java type from the specified text. * - * @param text the text of the type to create (a primitive type keyword). - * @param annotations array (possible empty) of annotations to annotate the created type. + * @param text the text of the type to create (a primitive type keyword). * @return the created type instance. * @throws IncorrectOperationException if some of the parameters are not valid. */ @NotNull + PsiType createPrimitiveTypeFromText(@NotNull String text) throws IncorrectOperationException; + + /** @deprecated use {@link PsiType#annotate(TypeAnnotationProvider)} (to be removed in IDEA 18) */ + @SuppressWarnings("unused") PsiType createPrimitiveType(@NotNull String text, @NotNull PsiAnnotation[] annotations) throws IncorrectOperationException; } \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java index 5ce28619f7fb..1862c29a916c 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java @@ -125,19 +125,18 @@ public class PsiPrimitiveType extends PsiType.Stub { @Nullable public static PsiPrimitiveType getUnboxedType(PsiType type) { if (!(type instanceof PsiClassType)) return null; + + assert type.isValid() : type; LanguageLevel languageLevel = ((PsiClassType)type).getLanguageLevel(); if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null; - assert type.isValid() : type; PsiClass psiClass = ((PsiClassType)type).resolve(); if (psiClass == null) return null; PsiPrimitiveType unboxed = ourQNameToUnboxed.get(psiClass.getQualifiedName()); - PsiAnnotation[] annotations = type.getAnnotations(); - if (unboxed != null && annotations.length > 0) { - unboxed = new PsiPrimitiveType(unboxed.myName, annotations); - } - return unboxed; + if (unboxed == null) return null; + + return unboxed.annotate(type.getAnnotationProvider()); } public String getBoxedTypeName() { @@ -152,31 +151,30 @@ public class PsiPrimitiveType extends PsiType.Stub { * it was not possible to resolve the reference to the class. */ @Nullable - public PsiClassType getBoxedType(PsiElement context) { + public PsiClassType getBoxedType(@NotNull PsiElement context) { PsiFile file = context.getContainingFile(); LanguageLevel languageLevel = PsiUtil.getLanguageLevel(file); if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null; String boxedQName = getBoxedTypeName(); - //[ven]previous call returns null for NULL, VOID if (boxedQName == null) return null; + JavaPsiFacade facade = JavaPsiFacade.getInstance(file.getProject()); PsiClass aClass = facade.findClass(boxedQName, file.getResolveScope()); if (aClass == null) return null; PsiElementFactory factory = facade.getElementFactory(); - return factory.createType(aClass, PsiSubstitutor.EMPTY, languageLevel, getAnnotations()); + return factory.createType(aClass, PsiSubstitutor.EMPTY, languageLevel).annotate(getAnnotationProvider()); } @Nullable - public PsiClassType getBoxedType(final PsiManager manager, final GlobalSearchScope resolveScope) { - final String boxedQName = getBoxedTypeName(); - - //[ven]previous call returns null for NULL, VOID + public PsiClassType getBoxedType(@NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope) { + String boxedQName = getBoxedTypeName(); if (boxedQName == null) return null; - final PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(boxedQName, resolveScope); + PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(boxedQName, resolveScope); if (aClass == null) return null; + return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(aClass); } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiType.java b/java/java-psi-api/src/com/intellij/psi/PsiType.java index 2b8f63b4ddbc..6220ffd8cba1 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiType.java @@ -56,13 +56,7 @@ public abstract class PsiType implements PsiAnnotationOwner { * Constructs a PsiType with given annotations */ protected PsiType(@NotNull final PsiAnnotation[] annotations) { - this(annotations.length == 0 ? TypeAnnotationProvider.EMPTY : new TypeAnnotationProvider() { - @NotNull - @Override - public PsiAnnotation[] getAnnotations() { - return annotations; - } - }); + this(TypeAnnotationProvider.Static.create(annotations)); } /** @@ -85,10 +79,8 @@ public abstract class PsiType implements PsiAnnotationOwner { return new PsiArrayType(this); } - /** - * Creates array type with this type as a component. - */ - @NotNull + /** @deprecated use {@link #annotate(TypeAnnotationProvider)} (to be removed in IDEA 18) */ + @SuppressWarnings("unused") public PsiArrayType createArrayType(@NotNull PsiAnnotation... annotations) { return new PsiArrayType(this, annotations); } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiWildcardType.java b/java/java-psi-api/src/com/intellij/psi/PsiWildcardType.java index 5ed01f39b4a8..263f02029ce4 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiWildcardType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiWildcardType.java @@ -75,15 +75,10 @@ public class PsiWildcardType extends PsiType.Stub { return new PsiWildcardType(manager, false, bound); } - @NotNull + /** @deprecated use {@link #annotate(TypeAnnotationProvider)} (to be removed in IDEA 18) */ + @SuppressWarnings("unused") public PsiWildcardType annotate(@NotNull final PsiAnnotation[] annotations) { - return annotations.length == 0 ? this : new PsiWildcardType(this, new TypeAnnotationProvider() { - @NotNull - @Override - public PsiAnnotation[] getAnnotations() { - return annotations; - } - }); + return annotations.length == 0 ? this : new PsiWildcardType(this, TypeAnnotationProvider.Static.create(annotations)); } @NotNull diff --git a/java/java-psi-api/src/com/intellij/psi/TypeAnnotationProvider.java b/java/java-psi-api/src/com/intellij/psi/TypeAnnotationProvider.java index 8184778ee46c..05600cffde2f 100644 --- a/java/java-psi-api/src/com/intellij/psi/TypeAnnotationProvider.java +++ b/java/java-psi-api/src/com/intellij/psi/TypeAnnotationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -36,4 +36,24 @@ public interface TypeAnnotationProvider { @NotNull PsiAnnotation[] getAnnotations(); -} + + + class Static implements TypeAnnotationProvider { + private final PsiAnnotation[] myAnnotations; + + private Static(PsiAnnotation[] annotations) { + myAnnotations = annotations; + } + + @NotNull + @Override + public PsiAnnotation[] getAnnotations() { + return myAnnotations; + } + + @NotNull + public static TypeAnnotationProvider create(@NotNull PsiAnnotation[] annotations) { + return annotations.length == 0 ? EMPTY : new Static(annotations); + } + } +} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java index 956490c77384..121ba9dbc33b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -383,13 +383,18 @@ public class PsiJavaParserFacadeImpl implements PsiJavaParserFacade { } @NotNull - @Override - public PsiType createPrimitiveType(@NotNull final String text, @NotNull final PsiAnnotation[] annotations) throws IncorrectOperationException { - final PsiPrimitiveType primitiveType = getPrimitiveType(text); + public PsiType createPrimitiveTypeFromText(@NotNull String text) throws IncorrectOperationException { + PsiPrimitiveType primitiveType = getPrimitiveType(text); if (primitiveType == null) { throw new IncorrectOperationException("Incorrect primitive type '" + text + "'"); } - return annotations.length == 0 ? primitiveType : new PsiPrimitiveType(text, annotations); + return primitiveType; + } + + @NotNull + @Override + public PsiType createPrimitiveType(@NotNull String text, @NotNull PsiAnnotation[] annotations) throws IncorrectOperationException { + return createPrimitiveTypeFromText(text).annotate(TypeAnnotationProvider.Static.create(annotations)); } public static PsiPrimitiveType getPrimitiveType(final String text) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java index 18ff2d110ad9..07fcb8023c55 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -48,7 +48,7 @@ public class JavaSharedImplUtil { List allAnnotations = collectAnnotations(anchor, stopAt); if (allAnnotations == null) return null; for (PsiAnnotation[] annotations : allAnnotations) { - type = type.createArrayType(annotations); + type = type.createArrayType().annotate(TypeAnnotationProvider.Static.create(annotations)); } return type; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java index 7862a7381011..f093215ee502 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -73,20 +73,22 @@ public class PsiNewExpressionImpl extends ExpressionPsiElement implements PsiNew else if (ElementType.PRIMITIVE_TYPE_BIT_SET.contains(elementType)) { assert type == null : this; PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); - type = factory.createPrimitiveType(child.getText(), ContainerUtil.copyAndClear(annotations, PsiAnnotation.ARRAY_FACTORY, true)); + PsiAnnotation[] copy = ContainerUtil.copyAndClear(annotations, PsiAnnotation.ARRAY_FACTORY, true); + type = factory.createPrimitiveTypeFromText(child.getText()).annotate(TypeAnnotationProvider.Static.create(copy)); if (stop) return type; } else if (elementType == JavaTokenType.LBRACKET) { assert type != null : this; - type = type.createArrayType(ContainerUtil.copyAndClear(annotations, PsiAnnotation.ARRAY_FACTORY, true)); + PsiAnnotation[] copy = ContainerUtil.copyAndClear(annotations, PsiAnnotation.ARRAY_FACTORY, true); + type = type.createArrayType().annotate(TypeAnnotationProvider.Static.create(copy)); if (stop) return type; } else if (elementType == JavaElementType.ANONYMOUS_CLASS) { PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); PsiClass aClass = (PsiClass)child.getPsi(); PsiSubstitutor substitutor = aClass instanceof PsiTypeParameter ? PsiSubstitutor.EMPTY : factory.createRawSubstitutor(aClass); - type = factory.createType(aClass, substitutor, PsiUtil.getLanguageLevel(aClass), - ContainerUtil.copyAndClear(annotations, PsiAnnotation.ARRAY_FACTORY, true)); + PsiAnnotation[] copy = ContainerUtil.copyAndClear(annotations, PsiAnnotation.ARRAY_FACTORY, true); + type = factory.createType(aClass, substitutor, PsiUtil.getLanguageLevel(aClass)).annotate(TypeAnnotationProvider.Static.create(copy)); if (stop) return type; } } diff --git a/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java b/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java index 056020a814fe..99c1dad3c89c 100644 --- a/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java +++ b/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java @@ -50,10 +50,10 @@ public class CanonicalTypes { } private abstract static class AnnotatedType extends Type { - protected final PsiAnnotation[] myAnnotations; + protected final TypeAnnotationProvider myProvider; - protected AnnotatedType(@NotNull PsiAnnotation[] annotations) { - myAnnotations = annotations; + public AnnotatedType(@NotNull TypeAnnotationProvider provider) { + myProvider = TypeAnnotationProvider.Static.create(provider.getAnnotations()); } } @@ -61,14 +61,14 @@ public class CanonicalTypes { private final PsiPrimitiveType myType; private Primitive(@NotNull PsiPrimitiveType type) { - super(type.getAnnotations()); + super(type.getAnnotationProvider()); myType = type; } @NotNull @Override public PsiType getType(PsiElement context, PsiManager manager) { - return myAnnotations.length == 0 ? myType : new PsiPrimitiveType(myType.getCanonicalText(false), myAnnotations); + return myType.annotate(myProvider); } @Override @@ -81,14 +81,14 @@ public class CanonicalTypes { protected final Type myComponentType; private Array(@NotNull PsiType original, @NotNull Type componentType) { - super(original.getAnnotations()); + super(original.getAnnotationProvider()); myComponentType = componentType; } @NotNull @Override public PsiType getType(PsiElement context, PsiManager manager) throws IncorrectOperationException { - return myComponentType.getType(context, manager).createArrayType(myAnnotations); + return myComponentType.getType(context, manager).createArrayType().annotate(myProvider); } @Override @@ -115,7 +115,7 @@ public class CanonicalTypes { @NotNull @Override public PsiType getType(PsiElement context, PsiManager manager) throws IncorrectOperationException { - return new PsiEllipsisType(myComponentType.getType(context, manager), myAnnotations); + return new PsiEllipsisType(myComponentType.getType(context, manager)).annotate(myProvider); } @Override @@ -129,7 +129,7 @@ public class CanonicalTypes { private final Type myBound; private WildcardType(@NotNull PsiType original, boolean isExtending, @Nullable Type bound) { - super(original.getAnnotations()); + super(original.getAnnotationProvider()); myIsExtending = isExtending; myBound = bound; } @@ -147,7 +147,7 @@ public class CanonicalTypes { else { type = PsiWildcardType.createSuper(manager, myBound.getType(context, manager)); } - return type.annotate(myAnnotations); + return type.annotate(myProvider); } @Override @@ -205,7 +205,7 @@ public class CanonicalTypes { private final Map mySubstitutor; private ClassType(@NotNull PsiType original, @NotNull String classQName, @NotNull Map substitutor) { - super(original.getAnnotations()); + super(original.getAnnotationProvider()); myPresentableText = original.getPresentableText(); myClassQName = classQName; mySubstitutor = substitutor; @@ -227,7 +227,7 @@ public class CanonicalTypes { Type substitute = mySubstitutor.get(typeParameter.getName()); substitutionMap.put(typeParameter, substitute != null ? substitute.getType(context, manager) : null); } - return factory.createType(aClass, factory.createSubstitutor(substitutionMap), null, myAnnotations); + return factory.createType(aClass, factory.createSubstitutor(substitutionMap), null).annotate(myProvider); } @Override diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java index 2c0212fafc2f..384b63aa7545 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -20,8 +20,6 @@ import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.search.searches.ReferencesSearch; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.Query; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.InspectionGadgetsFix; import org.jetbrains.annotations.NotNull; @@ -90,7 +88,7 @@ public class ConvertToVarargsMethodFix extends InspectionGadgetsFix { final PsiArrayType arrayType = (PsiArrayType)type; final PsiType componentType = arrayType.getComponentType(); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(method.getProject()); - final PsiType ellipsisType = PsiEllipsisType.createEllipsis(componentType, type.getAnnotations()); + final PsiType ellipsisType = new PsiEllipsisType(componentType, TypeAnnotationProvider.Static.create(type.getAnnotations())); final PsiTypeElement newTypeElement = factory.createTypeElement(ellipsisType); final PsiTypeElement typeElement = lastParameter.getTypeElement(); if (typeElement != null) { diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/varargs/MakeMethodVarargsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/varargs/MakeMethodVarargsIntention.java index 2b0617c673a6..24881155584b 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/varargs/MakeMethodVarargsIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/varargs/MakeMethodVarargsIntention.java @@ -48,7 +48,7 @@ public class MakeMethodVarargsIntention extends Intention { final PsiElementFactory factory = JavaPsiFacade.getInstance(element.getProject()).getElementFactory(); final PsiTypeElement typeElement = lastParameter.getTypeElement(); LOG.assertTrue(typeElement != null); - final PsiType ellipsisType = PsiEllipsisType.createEllipsis(((PsiArrayType)type).getComponentType(), type.getAnnotations()); + final PsiType ellipsisType = new PsiEllipsisType(((PsiArrayType)type).getComponentType(), TypeAnnotationProvider.Static.create(type.getAnnotations())); typeElement.replace(factory.createTypeElement(ellipsisType)); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 2a2db5ecaeb9..33003a77b739 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -1131,6 +1131,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { return JavaPsiFacade.getElementFactory(myProject).createType(resolve, substitutor, languageLevel); } + @SuppressWarnings("deprecation") @NotNull @Override public PsiClassType createType(@NotNull PsiClass resolve,