IDEADEV-41702 NPE - InjectLanguageAction.findInjectionHost

This commit is contained in:
Gregory Shrago
2009-11-30 18:44:14 +03:00
parent e15781190b
commit fc5e52367e
@@ -77,7 +77,9 @@ public class InjectLanguageAction implements IntentionAction {
final int offset = editor.getCaretModel().getOffset();
final PsiLanguageInjectionHost host = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false);
if (host == null) return null;
final TextRange textRange = ElementManipulators.getManipulator(host).getRangeInElement(host);
final ElementManipulator<PsiLanguageInjectionHost> manipulator = ElementManipulators.getManipulator(host);
if (manipulator == null) return null;
final TextRange textRange = manipulator.getRangeInElement(host);
if (textRange.getStartOffset() == 0) return null;
return host;
}