From 73e52e462d1fbf7239ad33821fdce3b1daf6dcb6 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 26 Sep 2012 20:30:36 +0400 Subject: [PATCH] IDEA-92100 NPE at QuickEditHandler.commitToOriginal(): ensure host manipulator is available --- RegExpSupport/src/META-INF/RegExpPlugin.xml | 1 - .../lang/regexp/RegExpRangeProvider.java | 30 ------------------- .../intention/CheckRegExpIntentionAction.java | 17 ----------- .../intention/impl/QuickEditAction.java | 7 ++--- 4 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 RegExpSupport/src/org/intellij/lang/regexp/RegExpRangeProvider.java diff --git a/RegExpSupport/src/META-INF/RegExpPlugin.xml b/RegExpSupport/src/META-INF/RegExpPlugin.xml index 75a1c0b3af25..ae16a2118329 100644 --- a/RegExpSupport/src/META-INF/RegExpPlugin.xml +++ b/RegExpSupport/src/META-INF/RegExpPlugin.xml @@ -1,7 +1,6 @@ - diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpRangeProvider.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpRangeProvider.java deleted file mode 100644 index 9407752e3e63..000000000000 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpRangeProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2000-2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.intellij.lang.regexp; - -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; - -/** - * @author Anna Bulenkova - */ -public interface RegExpRangeProvider { - ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.regExpRangeProvider"); - - Pair getRangePair(PsiElement element); -} diff --git a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java index da762fd5a68d..e9586776531d 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java @@ -28,9 +28,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiUtilBase; import org.intellij.lang.regexp.RegExpLanguage; -import org.intellij.lang.regexp.RegExpRangeProvider; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -41,21 +39,6 @@ import javax.swing.*; */ public class CheckRegExpIntentionAction extends QuickEditAction implements Iconable { - @Override - protected Pair getRangePair(PsiFile file, Editor editor) { - Pair pair = super.getRangePair(file, editor); - - if (pair == null) { - RegExpRangeProvider[] rangeProviders = RegExpRangeProvider.EP_NAME.getExtensions(); - PsiElement element = PsiUtilBase.getElementAtCaret(editor); - for (RegExpRangeProvider provider : rangeProviders) { - pair = provider.getRangePair(element); - if (pair != null) break; - } - } - return pair; - } - @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { final Pair pair = getRangePair(file, editor); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java index e41175409de9..2ef1ad962d95 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java @@ -25,10 +25,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiLanguageInjectionHost; +import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; @@ -62,7 +59,7 @@ public class QuickEditAction implements IntentionAction, LowPriorityAction { final int offset = editor.getCaretModel().getOffset(); final PsiLanguageInjectionHost host = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false); - if (host == null) return null; + if (host == null || ElementManipulators.getManipulator(host) == null) return null; final List> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host); if (injections == null || injections.isEmpty()) return null; final int offsetInElement = offset - host.getTextRange().getStartOffset();