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


Java TextEdit.removeChildren方法代码示例

本文整理汇总了Java中org.eclipse.text.edits.TextEdit.removeChildren方法的典型用法代码示例。如果您正苦于以下问题:Java TextEdit.removeChildren方法的具体用法?Java TextEdit.removeChildren怎么用?Java TextEdit.removeChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.text.edits.TextEdit的用法示例。


在下文中一共展示了TextEdit.removeChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceTextEdit

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
private static boolean replaceTextEdit(TextEdit parentEdit, TextEdit oldEdit,
    TextEdit newEdit) {
  // The text edit API does not allow replacing an edit, so remove all and add
  // them all back (with the replaced edit)
  TextEdit[] children = parentEdit.removeChildren();
  replaceTextEdit(oldEdit, newEdit, children);
  parentEdit.addChildren(children);

  return true;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:11,代码来源:TextEditUtilities.java

示例2: perform

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
public void perform(IProgressMonitor pm, ICompilationUnit cu,
    TextEdit rootEdit) throws CoreException {

  // Remove the original edits we generated, since their offsets may have
  // been shifted by JDT edits that occurred "higher" in the source file
  TextEdit[] oldEdits = rootEdit.removeChildren();

  // Generate a new AST for this compilation unit
  RefactoringASTParser parser = new RefactoringASTParser(AST.JLS4);
  CompilationUnit astNode = parser.parse(cu, false);

  // Now re-validate the compilation unit's AST to get the JSNI Java
  // references' updated positions into the index
  JavaCompilationParticipant.validateCompilationUnit(astNode);

  // Get the index entries matching the old element by name only (we can't
  // resolve the references anymore because the old element no longer exists).
  IJavaElement oldElement = jsniReferenceChange.getRefactoringSupport().getOldElement();
  Set<IIndexedJavaRef> refs = JavaQueryParticipant.findWorkspaceReferences(
      oldElement, false);

  for (Iterator<IIndexedJavaRef> iterator = refs.iterator(); iterator.hasNext();) {
    IIndexedJavaRef ref = iterator.next();

    // Remove any matches that did not come from this compilation unit or
    // which don't resolve to the refactored Java Element
    if (!(ref.getSource().equals(cu.getPath()))
        || (!resolvesToRefactoredElement(cu, ref))) {
      iterator.remove();
    }
  }

  // Get the new edits for the references within this compilation unit (the
  // offsets may have changed if the JDT created edits above us in the
  // compilation unit).
  Set<TextEdit> newEdits = jsniReferenceChange.getRefactoringSupport().createEdits(
      refs).get(cu.getPath());
  assert (newEdits != null);
  assert (oldEdits.length == newEdits.size());

  // Add all those edits back onto this change's root edit
  rootEdit.addChildren(newEdits.toArray(new TextEdit[0]));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:44,代码来源:JsniReferenceChangeHelper.java


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