handle null containing files gracefully

This commit is contained in:
Gregory.Shrago
2014-07-23 14:19:32 +04:00
parent 61c577df69
commit 8ce7f4e0eb
@@ -226,7 +226,7 @@ public class InjectorUtils {
}
@Nullable
public static BaseInjection findCommentInjection(PsiElement context, final String supportId, final Ref<PsiElement> causeRef) {
public static BaseInjection findCommentInjection(@NotNull PsiElement context, @NotNull String supportId, @Nullable Ref<PsiElement> causeRef) {
PsiElement target = CompletionUtil.getOriginalOrSelf(context);
PsiFile file = target.getContainingFile();
TreeMap<TextRange, BaseInjection> map = getInjectionMap(file);
@@ -273,7 +273,9 @@ public class InjectorUtils {
e instanceof PsiLanguageInjectionHost && StringUtil.isEmptyOrSpaces(e.getText());
}
protected static TreeMap<TextRange, BaseInjection> getInjectionMap(final PsiFile file) {
@Nullable
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@Nullable final PsiFile file) {
if (file == null) return null; // e.g. null for synthetic groovy variables
return CachedValuesManager.getCachedValue(file, new CachedValueProvider<TreeMap<TextRange, BaseInjection>>() {
@Nullable
@Override