A parameter is actually nullable

This commit is contained in:
Roman Shevchenko
2013-03-15 22:27:57 +01:00
parent 96da9a0bd2
commit 00dc5866e6
3 changed files with 39 additions and 26 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -43,7 +43,7 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor
return ServiceManager.getService(project, PsiElementFactory.class);
}
}
/**
* Creates an empty class with the specified name.
*
@@ -164,12 +164,21 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor
*/
@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 PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @Nullable LanguageLevel languageLevel);
@NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @NotNull LanguageLevel languageLevel, @NotNull PsiAnnotation[] annotations);
@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.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -89,24 +89,22 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
@NotNull
@Override
public PsiClassType createType(@NotNull final PsiClass resolve, @NotNull final PsiSubstitutor substitutor) {
public PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor) {
return new PsiImmediateClassType(resolve, substitutor);
}
@NotNull
@Override
public PsiClassType createType(@NotNull final PsiClass resolve,
@NotNull final PsiSubstitutor substitutor,
@NotNull final LanguageLevel languageLevel) {
public PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @Nullable LanguageLevel languageLevel) {
return new PsiImmediateClassType(resolve, substitutor, languageLevel);
}
@NotNull
@Override
public PsiClassType createType(@NotNull final PsiClass resolve,
@NotNull final PsiSubstitutor substitutor,
@NotNull final LanguageLevel languageLevel,
@NotNull final PsiAnnotation[] annotations) {
public PsiClassType createType(@NotNull PsiClass resolve,
@NotNull PsiSubstitutor substitutor,
@Nullable LanguageLevel languageLevel,
@NotNull PsiAnnotation[] annotations) {
return new PsiImmediateClassType(resolve, substitutor, languageLevel, annotations);
}
@@ -21,6 +21,7 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -74,15 +75,18 @@ public class PsiImmediateClassType extends PsiClassType {
};
public PsiImmediateClassType(@NotNull PsiClass aClass, @NotNull PsiSubstitutor substitutor) {
this (aClass, substitutor, null);
this(aClass, substitutor, null, PsiAnnotation.EMPTY_ARRAY);
}
public PsiImmediateClassType(@NotNull PsiClass aClass, @NotNull PsiSubstitutor substitutor, final LanguageLevel languageLevel) {
this(aClass, substitutor,languageLevel, PsiAnnotation.EMPTY_ARRAY);
public PsiImmediateClassType(@NotNull PsiClass aClass, @NotNull PsiSubstitutor substitutor, @Nullable LanguageLevel languageLevel) {
this(aClass, substitutor, languageLevel, PsiAnnotation.EMPTY_ARRAY);
}
public PsiImmediateClassType(@NotNull PsiClass aClass, @NotNull PsiSubstitutor substitutor, LanguageLevel languageLevel, @NotNull PsiAnnotation[] annotations) {
super(languageLevel,annotations);
public PsiImmediateClassType(@NotNull PsiClass aClass,
@NotNull PsiSubstitutor substitutor,
@Nullable LanguageLevel languageLevel,
@NotNull PsiAnnotation[] annotations) {
super(languageLevel, annotations);
myClass = aClass;
myManager = aClass.getManager();
mySubstitutor = substitutor;
@@ -131,7 +135,7 @@ public class PsiImmediateClassType extends PsiClassType {
@Override
public String getPresentableText() {
if (myPresentableText == null) {
final StringBuilder buffer = new StringBuilder();
StringBuilder buffer = new StringBuilder();
buildText(myClass, mySubstitutor, buffer, false, false);
myPresentableText = buffer.toString();
}
@@ -142,7 +146,7 @@ public class PsiImmediateClassType extends PsiClassType {
public String getCanonicalText() {
if (myCanonicalText == null) {
assert mySubstitutor.isValid();
final StringBuilder buffer = new StringBuilder();
StringBuilder buffer = new StringBuilder();
buildText(myClass, mySubstitutor, buffer, true, false);
myCanonicalText = buffer.toString();
}
@@ -152,7 +156,7 @@ public class PsiImmediateClassType extends PsiClassType {
@Override
public String getInternalCanonicalText() {
if (myInternalCanonicalText == null) {
final StringBuilder buffer = new StringBuilder();
StringBuilder buffer = new StringBuilder();
buildText(myClass, mySubstitutor, buffer, true, true);
myInternalCanonicalText = buffer.toString();
}
@@ -173,6 +177,11 @@ public class PsiImmediateClassType extends PsiClassType {
}
return;
}
if (canonical == internal) {
buffer.append(getAnnotationsTextPrefix());
}
PsiClass enclosingClass = null;
if (!aClass.hasModifierProperty(PsiModifier.STATIC)) {
final PsiElement parent = aClass.getParent();
@@ -180,9 +189,6 @@ public class PsiImmediateClassType extends PsiClassType {
enclosingClass = (PsiClass)parent;
}
}
if (canonical == internal) {
buffer.append(getAnnotationsTextPrefix());
}
if (enclosingClass != null) {
buildText(enclosingClass, substitutor, buffer, canonical, false);
buffer.append('.');