From 5293cc527f83a302dcb9e54583b7ec0c701ac809 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 2 Apr 2007 18:24:58 +0400 Subject: [PATCH] IDEADEV-11226 ? --- .../intellij/codeInspection/ex/QuickFixWrapper.java | 6 +++--- source/com/intellij/psi/impl/source/DummyHolder.java | 1 + .../source/tree/injected/InjectedLanguageUtil.java | 10 +++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/inspections/impl/com/intellij/codeInspection/ex/QuickFixWrapper.java b/inspections/impl/com/intellij/codeInspection/ex/QuickFixWrapper.java index 28c64c453ee9..23c6e92fe1d5 100644 --- a/inspections/impl/com/intellij/codeInspection/ex/QuickFixWrapper.java +++ b/inspections/impl/com/intellij/codeInspection/ex/QuickFixWrapper.java @@ -23,7 +23,7 @@ public class QuickFixWrapper implements IntentionAction { private int myFixNumber; private static final Logger LOG = Logger.getInstance("com.intellij.codeInspection.ex.QuickFixWrapper"); - public QuickFixWrapper(ProblemDescriptor descriptor, int fixNumber) { + public QuickFixWrapper(@NotNull ProblemDescriptor descriptor, int fixNumber) { myDescriptor = descriptor; myFixNumber = fixNumber; LOG.assertTrue(fixNumber > -1); @@ -40,12 +40,12 @@ public class QuickFixWrapper implements IntentionAction { return myDescriptor.getFixes()[myFixNumber].getName(); } - public boolean isAvailable(Project project, Editor editor, PsiFile file) { + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { PsiElement psiElement = myDescriptor.getPsiElement(); return psiElement != null && psiElement.isValid(); } - public void invoke(Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { if (!CodeInsightUtil.prepareFileForWrite(file)) return; LocalQuickFix fix = (LocalQuickFix)myDescriptor.getFixes()[myFixNumber]; fix.applyFix(project, myDescriptor); diff --git a/source/com/intellij/psi/impl/source/DummyHolder.java b/source/com/intellij/psi/impl/source/DummyHolder.java index 4b5ff52bd8e5..873dc312670d 100644 --- a/source/com/intellij/psi/impl/source/DummyHolder.java +++ b/source/com/intellij/psi/impl/source/DummyHolder.java @@ -225,6 +225,7 @@ public class DummyHolder extends PsiFileImpl implements PsiImportHolder { private FileViewProvider myViewProvider = null; + @NotNull public FileViewProvider getViewProvider() { if(myViewProvider != null) return myViewProvider; return super.getViewProvider(); diff --git a/source/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java b/source/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java index 55f81cce1470..22fcd0618af5 100644 --- a/source/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java +++ b/source/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java @@ -19,10 +19,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -63,7 +60,7 @@ public class InjectedLanguageUtil { CachedValueProvider.Result>> result = provider.compute(); if (result == null) return null; cachedPsi = host.getManager().getCachedValuesManager().createCachedValue(provider, false); - host.putUserData(INJECTED_PSI, cachedPsi); + ((UserDataHolderEx)host).putUserDataIfAbsent(INJECTED_PSI, cachedPsi); return result.getValue(); } return cachedPsi.getValue(); @@ -408,8 +405,7 @@ public class InjectedLanguageUtil { List injected = hostDocument.getUserData(INJECTED_DOCS_KEY); if (injected == null) { - injected = new ArrayList(); - hostDocument.putUserData(INJECTED_DOCS_KEY, injected); + injected = ((UserDataHolderEx)hostDocument).putUserDataIfAbsent(INJECTED_DOCS_KEY, new ArrayList()); } RangeMarker rangeMarker = documentRange.getTextRange();