Java Code Examples for com.intellij.psi.ElementManipulators#getManipulator()
The following examples show how to use
com.intellij.psi.ElementManipulators#getManipulator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickEditAction.java From consulo with Apache License 2.0 | 6 votes |
@Nullable protected Pair<PsiElement, TextRange> getRangePair(final PsiFile file, final Editor editor) { final int offset = editor.getCaretModel().getOffset(); final PsiLanguageInjectionHost host = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false); if (host == null || ElementManipulators.getManipulator(host) == null) return null; final List<Pair<PsiElement, TextRange>> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host); if (injections == null || injections.isEmpty()) return null; final int offsetInElement = offset - host.getTextRange().getStartOffset(); final Pair<PsiElement, TextRange> rangePair = ContainerUtil.find(injections, new Condition<Pair<PsiElement, TextRange>>() { @Override public boolean value(final Pair<PsiElement, TextRange> pair) { return pair.second.containsRange(offsetInElement, offsetInElement); } }); if (rangePair != null) { final Language language = rangePair.first.getContainingFile().getLanguage(); final Object action = language.getUserData(EDIT_ACTION_AVAILABLE); if (action != null && action.equals(false)) return null; myLastLanguageName = language.getDisplayName(); } return rangePair; }
Example 2
Source File: AbstractBashFileReference.java From BashSupport with Apache License 2.0 | 5 votes |
@NotNull private ElementManipulator<AbstractBashCommand<?>> getManipulator() { ElementManipulator<AbstractBashCommand<?>> manipulator = ElementManipulators.<AbstractBashCommand<?>>getManipulator(cmd); if (manipulator == null) { throw new IncorrectOperationException("No element manipulator found for " + cmd); } return manipulator; }
Example 3
Source File: AbstractFunctionReference.java From BashSupport with Apache License 2.0 | 5 votes |
@NotNull private ElementManipulator<AbstractBashCommand<?>> getManipulator() { ElementManipulator<AbstractBashCommand<?>> manipulator = ElementManipulators.<AbstractBashCommand<?>>getManipulator(cmd); if (manipulator == null) { throw new IncorrectOperationException("No element manipulator found for " + cmd); } return manipulator; }
Example 4
Source File: CachingReference.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static <T extends PsiElement> ElementManipulator<T> getManipulator(T currentElement){ ElementManipulator<T> manipulator = ElementManipulators.getManipulator(currentElement); if (manipulator == null) { throw new IncorrectOperationException("Manipulator for this element is not defined: " + currentElement + "; " + currentElement.getClass()); } return manipulator; }
Example 5
Source File: BeanSelfReference.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override public PsiElement handleElementRename(@NotNull String newElementName) throws IncorrectOperationException { ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(myElement); return manipulator.handleContentChange(myElement, TextRange.from(1, id.length()), newElementName); }
Example 6
Source File: DirectEndpointReference.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override public PsiElement handleElementRename(@NotNull String newElementName) throws IncorrectOperationException { ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(myElement); return manipulator.handleContentChange(myElement, endpoint.getNameTextRange().shiftRight(1), newElementName); }
Example 7
Source File: DirectEndpointStartSelfReference.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
@Override public PsiElement handleElementRename(@NotNull String newElementName) throws IncorrectOperationException { ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(myElement); return manipulator.handleContentChange(myElement, endpoint.getNameTextRange().shiftRight(1), newElementName); }