當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。