[groovy] @Contract and @Nullable

This commit is contained in:
Daniil Ovchinnikov
2016-05-25 16:01:17 +03:00
parent fd4aa5e3b5
commit 20600f85dc
3 changed files with 9 additions and 1 deletions
@@ -47,6 +47,7 @@ import com.intellij.util.containers.EmptyIterable;
import com.intellij.util.containers.HashMap;
import gnu.trove.THashSet;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1069,12 +1070,14 @@ public final class PsiUtil extends PsiUtilCore {
return false;
}
@Contract("null, _ -> null")
@Nullable
public static PsiType extractIterableTypeParameter(@Nullable PsiType psiType, final boolean eraseTypeParameter) {
final PsiType type = substituteTypeParameter(psiType, CommonClassNames.JAVA_LANG_ITERABLE, 0, eraseTypeParameter);
return type != null ? type : substituteTypeParameter(psiType, CommonClassNames.JAVA_UTIL_COLLECTION, 0, eraseTypeParameter);
}
@Contract("null, _, _, _ -> null")
@Nullable
public static PsiType substituteTypeParameter(@Nullable final PsiType psiType, @NotNull final String superClass, final int typeParamIndex,
final boolean eraseTypeParameter) {