@NotNull 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; }
@Override public PsiElement bindToElement(@NotNull final PsiElement element) throws IncorrectOperationException { if(!(element instanceof HaxePackage)) { throw new IncorrectOperationException("Cannot bind to " + element); } final String newName = ((HaxePackage) element).getQualifiedName(); final TextRange range = new TextRange(getReferenceSet().getReference(0).getRangeInElement().getStartOffset(), getRangeInElement().getEndOffset()); final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(getElement()); return manipulator.handleContentChange(getElement(), range, newName); }
@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; }
@Override public PsiElement handleElementRename(final String newElementName) throws IncorrectOperationException { JSDocTag jsDocTag = (JSDocTag) myJsDocTagValue.getParent(); final ElementManipulator<JSDocTag> manipulator = ElementManipulators.getManipulator(jsDocTag); jsDocTag = manipulator.handleContentChange(jsDocTag, myRange, newElementName); reset((JSDocTagImpl) jsDocTag); return myJsDocTagValue; }
@Override @Nullable public PsiElement handleElementRename(String string) throws IncorrectOperationException { final PsiElement element = getElement(); if(element != null) { ElementManipulator<PsiElement> man = ElementManipulators.getManipulator(element); if(man != null) { return man.handleContentChange(element, getRangeInElement(), string); } } return element; }
@Override public PsiElement bindToElement(@NotNull final PsiElement element) throws IncorrectOperationException { if(!(element instanceof PsiJavaPackage)) { throw new IncorrectOperationException("Cannot bind to " + element); } final String newName = ((PsiJavaPackage) element).getQualifiedName(); final TextRange range = new TextRange(getReferenceSet().getReference(0).getRangeInElement().getStartOffset(), getRangeInElement().getEndOffset()); final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(getElement()); return manipulator.handleContentChange(getElement(), range, newName); }
private ElementManipulator<PsiElement> getManipulator() { return new ImpexMacrosManipulator(); }
protected void replaceContent(final String str) throws IncorrectOperationException { final ElementManipulator<XmlTag> manipulator = ElementManipulators.getManipulator(myTag); manipulator.handleContentChange(myTag, myRange, str); myRange = manipulator.getRangeInElement(myTag); }