本文整理汇总了Java中com.intellij.psi.ElementManipulators.getManipulator方法的典型用法代码示例。如果您正苦于以下问题:Java ElementManipulators.getManipulator方法的具体用法?Java ElementManipulators.getManipulator怎么用?Java ElementManipulators.getManipulator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.ElementManipulators
的用法示例。
在下文中一共展示了ElementManipulators.getManipulator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRangePair
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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;
}
示例2: getRangePair
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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;
}
示例3: testManipulatorRegistered
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
public void testManipulatorRegistered() {
LanguageExtensionPoint[] extensions =
Extensions.getExtensions(new ExtensionPointName<LanguageExtensionPoint>("com.intellij.lang.parserDefinition"));
Set<String> classes = new HashSet<String>();
List<String> failures = new ArrayList<String>();
int total = 0;
for (LanguageExtensionPoint e : extensions) {
ParserDefinition definition = (ParserDefinition)e.getInstance();
for (IElementType type : IElementType.enumerate(IElementType.TRUE)) {
if (type instanceof ILeafElementType) continue;
try {
CompositeElement treeElement = ASTFactory.composite(type);
total++;
PsiElement element = treeElement instanceof PsiElement? (PsiElement)treeElement : definition.createElement(treeElement);
if (element instanceof PsiLanguageInjectionHost && classes.add(element.getClass().getName())) {
boolean ok = ElementManipulators.getManipulator(element) != null;
System.out.println((ok ? "OK " : "FAIL") + " " + element.getClass().getSimpleName() + " [" + definition.getClass().getSimpleName() + "]");
if (!ok) failures.add(element.getClass().getName());
}
}
catch (Throwable ignored) {
}
}
}
System.out.println("count: " + classes.size() + ", total: " + total);
assertEmpty("PsiLanguageInjectionHost requires " + ElementManipulators.EP_NAME, failures);
}
示例4: getManipulator
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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;
}
示例5: bindToElement
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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);
}
示例6: getManipulator
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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;
}
示例7: handleElementRename
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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;
}
示例8: handleElementRename
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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;
}
示例9: bindToElement
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@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);
}
示例10: replaceContent
import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
protected void replaceContent(final String str) throws IncorrectOperationException {
final ElementManipulator<XmlTag> manipulator = ElementManipulators.getManipulator(myTag);
manipulator.handleContentChange(myTag, myRange, str);
myRange = manipulator.getRangeInElement(myTag);
}