当前位置: 首页>>代码示例>>Java>>正文


Java ElementManipulators.getManipulator方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:QuickEditAction.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:QuickEditAction.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:IElementTypeTest.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:CachingReference.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-haxe,代码行数:14,代码来源:HaxePsiPackageReference.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:CachingReference.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:10,代码来源:JSDocTagImpl.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:GenericReference.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:PsiPackageReference.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:XmlValueReference.java


注:本文中的com.intellij.psi.ElementManipulators.getManipulator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。