diff --git a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java index b9d13bc76073..c69c9250b8a2 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.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. @@ -48,7 +48,7 @@ public class PsiCapturedWildcardType extends PsiType.Stub { private PsiCapturedWildcardType(@NotNull PsiWildcardType existential, @NotNull PsiElement context, @Nullable PsiTypeParameter parameter) { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); myExistential = existential; myContext = context; myParameter = parameter; @@ -208,4 +208,4 @@ public class PsiCapturedWildcardType extends PsiType.Stub { public PsiTypeParameter getTypeParameter() { return myParameter; } -} +} \ No newline at end of file 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 8a322bca993b..5906e1d3c7c8 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiClassType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiClassType.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. @@ -30,9 +30,6 @@ import org.jetbrains.annotations.Nullable; * @author max */ public abstract class PsiClassType extends PsiType { - /** - * The empty array of PSI class types which can be reused to avoid unnecessary allocations. - */ public static final PsiClassType[] EMPTY_ARRAY = new PsiClassType[0]; public static final ArrayFactory ARRAY_FACTORY = new ArrayFactory() { @NotNull @@ -53,8 +50,8 @@ public abstract class PsiClassType extends PsiType { myLanguageLevel = languageLevel; } - public PsiClassType(LanguageLevel languageLevel, @NotNull TypeAnnotationProvider annotations) { - super(annotations); + public PsiClassType(LanguageLevel languageLevel, @NotNull TypeAnnotationProvider provider) { + super(provider); myLanguageLevel = languageLevel; } @@ -221,7 +218,7 @@ public abstract class PsiClassType extends PsiType { public abstract PsiClassType rawType(); /** - * Overrides {@link com.intellij.psi.PsiType#getResolveScope()} to narrow specify @NotNull. + * Overrides {@link PsiType#getResolveScope()} to narrow specify @NotNull. */ @Override @NotNull @@ -314,4 +311,4 @@ public abstract class PsiClassType extends PsiType { @Override public abstract String getCanonicalText(boolean annotated); } -} +} \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java b/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java index bc71843ee20b..8b92ec95a3ae 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.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. @@ -26,8 +26,8 @@ import java.util.List; public abstract class PsiDiamondType extends PsiType { public static final RecursionGuard ourDiamondGuard = RecursionManager.createGuard("diamondInference"); - public PsiDiamondType(PsiAnnotation[] annotations) { - super(annotations); + public PsiDiamondType() { + super(TypeAnnotationProvider.EMPTY); } public abstract DiamondInferenceResult resolveInferredTypes(); diff --git a/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java b/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java index 2b5299e35327..d2c4a2ea0651 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.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. @@ -39,7 +39,7 @@ public class PsiDisjunctionType extends PsiType.Stub { private final CachedValue myLubCache; public PsiDisjunctionType(@NotNull List types, @NotNull PsiManager psiManager) { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); myManager = psiManager; myTypes = Collections.unmodifiableList(types); @@ -168,4 +168,4 @@ public class PsiDisjunctionType extends PsiType.Stub { return true; } -} +} \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java b/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java index f46e68012ed9..0adc5e1c79e9 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.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. @@ -35,7 +35,7 @@ public class PsiIntersectionType extends PsiType.Stub { private final PsiType[] myConjuncts; private PsiIntersectionType(@NotNull PsiType[] conjuncts) { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); myConjuncts = conjuncts; } @@ -176,6 +176,7 @@ public class PsiIntersectionType extends PsiType.Stub { return myConjuncts[0]; } + @Override public boolean equals(final Object obj) { if (this == obj) return true; if (!(obj instanceof PsiIntersectionType)) return false; @@ -190,6 +191,7 @@ public class PsiIntersectionType extends PsiType.Stub { return true; } + @Override public int hashCode() { return myConjuncts[0].hashCode(); } @@ -221,4 +223,4 @@ public class PsiIntersectionType extends PsiType.Stub { } return null; } -} +} \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpressionType.java b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpressionType.java index db9db62596c1..7f6b0e7e53d2 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpressionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpressionType.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. @@ -26,7 +26,7 @@ public class PsiLambdaExpressionType extends PsiType { private final PsiLambdaExpression myExpression; public PsiLambdaExpressionType(PsiLambdaExpression expression) { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); myExpression = expression; } @@ -77,4 +77,4 @@ public class PsiLambdaExpressionType extends PsiType { public PsiLambdaExpression getExpression() { return myExpression; } -} +} \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiLambdaParameterType.java b/java/java-psi-api/src/com/intellij/psi/PsiLambdaParameterType.java index 6a1991c60b39..9d0e550c6feb 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiLambdaParameterType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiLambdaParameterType.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. @@ -26,7 +26,7 @@ public class PsiLambdaParameterType extends PsiType { private final PsiParameter myParameter; public PsiLambdaParameterType(PsiParameter parameter) { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); myParameter = parameter; } @@ -77,4 +77,4 @@ public class PsiLambdaParameterType extends PsiType { public PsiParameter getParameter() { return myParameter; } -} +} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/Bottom.java b/java/java-psi-impl/src/com/intellij/psi/Bottom.java index 022c8636800a..c128579b50cc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/Bottom.java +++ b/java/java-psi-impl/src/com/intellij/psi/Bottom.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. @@ -25,7 +25,7 @@ public class Bottom extends PsiType { public static final Bottom BOTTOM = new Bottom(); private Bottom() { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); } @NotNull @@ -56,12 +56,9 @@ public class Bottom extends PsiType { return text.equals("_"); } + @Override public boolean equals(Object o) { - if (o instanceof Bottom) { - return true; - } - - return false; + return o instanceof Bottom; } @Override @@ -84,4 +81,4 @@ public class Bottom extends PsiType { public GlobalSearchScope getResolveScope() { return null; } -} +} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java index 45dcee6e9460..537a4dcf5759 100644 --- a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.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. @@ -47,13 +47,12 @@ import java.util.*; * @since Jul 30, 2010 */ public class PsiDiamondTypeImpl extends PsiDiamondType { - private static final Logger LOG = Logger.getInstance("#" + PsiDiamondTypeImpl.class.getName()); + private static final Logger LOG = Logger.getInstance(PsiDiamondTypeImpl.class); private final PsiManager myManager; private final PsiTypeElement myTypeElement; public PsiDiamondTypeImpl(PsiManager manager, PsiTypeElement psiTypeElement) { - super(PsiAnnotation.EMPTY_ARRAY); myManager = manager; myTypeElement = psiTypeElement; } @@ -134,9 +133,9 @@ public class PsiDiamondTypeImpl extends PsiDiamondType { final DiamondInferenceResult inferenceResult = resolveInferredTypesNoCheck(newExpression, context); if (anonymousClass != null && PsiUtil.isLanguageLevel9OrHigher(newExpression)) { - final InferredAnonymTypeVisitor anonymTypeVisitor = new InferredAnonymTypeVisitor(context); + final InferredAnonymousTypeVisitor anonymousTypeVisitor = new InferredAnonymousTypeVisitor(context); for (PsiType type : inferenceResult.getInferredTypes()) { - final Boolean accepted = type.accept(anonymTypeVisitor); + final Boolean accepted = type.accept(anonymousTypeVisitor); if (accepted != null && !accepted.booleanValue()) { return PsiDiamondTypeImpl.DiamondInferenceResult.ANONYMOUS_INNER_RESULT; } @@ -150,17 +149,16 @@ public class PsiDiamondTypeImpl extends PsiDiamondType { final PsiSubstitutor inferredSubstitutor = ourDiamondGuard.doPreventingRecursion(context, false, new Computable() { @Override public PsiSubstitutor compute() { - final JavaResolveResult staticFactoryCandidateInfo = context == newExpression ? - CachedValuesManager.getCachedValue(newExpression, - new CachedValueProvider() { - @Nullable - @Override - public Result compute() { - return new Result(getStaticFactoryCandidateInfo(newExpression, newExpression), - PsiModificationTracker.MODIFICATION_COUNT); - } - }) - : getStaticFactoryCandidateInfo(newExpression, context); + final JavaResolveResult staticFactoryCandidateInfo = + context == newExpression + ? CachedValuesManager.getCachedValue(newExpression, new CachedValueProvider() { + @Nullable + @Override + public Result compute() { + return new Result(getStaticFactoryCandidateInfo(newExpression, newExpression), PsiModificationTracker.MODIFICATION_COUNT); + } + }) + : getStaticFactoryCandidateInfo(newExpression, context); staticFactoryRef.set(staticFactoryCandidateInfo); if (staticFactoryCandidateInfo != null) { PsiSubstitutor substitutor = staticFactoryCandidateInfo.getSubstitutor(); @@ -515,10 +513,10 @@ public class PsiDiamondTypeImpl extends PsiDiamondType { * The term "subexpression" includes type arguments of parameterized types (4.5), bounds of wildcards (4.5.1), and element types of array types (10.1). * It excludes bounds of type variables. */ - private static class InferredAnonymTypeVisitor extends PsiTypeVisitor { + private static class InferredAnonymousTypeVisitor extends PsiTypeVisitor { private final PsiElement myExpression; - public InferredAnonymTypeVisitor(PsiElement expression) { + public InferredAnonymousTypeVisitor(PsiElement expression) { myExpression = expression; } @@ -564,4 +562,4 @@ public class PsiDiamondTypeImpl extends PsiDiamondType { return true; } } -} +} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java b/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java index 872c8ded71ea..83ab83092689 100644 --- a/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java +++ b/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; */ public abstract class PsiTypeVariable extends PsiType { protected PsiTypeVariable() { - super(PsiAnnotation.EMPTY_ARRAY); + super(TypeAnnotationProvider.EMPTY); } public abstract int getIndex(); @@ -37,4 +37,4 @@ public abstract class PsiTypeVariable extends PsiType { return visitor.visitType(this); } } -} +} \ No newline at end of file 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 ccb12db66200..056020a814fe 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 @@ -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. @@ -326,7 +326,7 @@ public class CanonicalTypes { PsiType substitute = substitutor.substitute(typeParameter); substitutionMap.put(typeParameter.getName(), substitute != null ? substitute.accept(this) : null); } - String qualifiedName = ObjectUtils.notNull(aClass.getQualifiedName(), aClass.getName()); + String qualifiedName = ObjectUtils.notNull(aClass.getQualifiedName(), ObjectUtils.assertNotNull(aClass.getName())); return new ClassType(type, qualifiedName, substitutionMap); } } @@ -358,4 +358,4 @@ public class CanonicalTypes { public static Type createTypeWrapper(@NotNull PsiType type) { return type.accept(Creator.INSTANCE); } -} +} \ No newline at end of file