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


Java TextEdit.hasChildren方法代码示例

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


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

示例1: flatten

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
private static void flatten(TextEdit edit, MultiTextEdit result) {
  if (!edit.hasChildren()) {
    result.addChild(edit);
  } else {
    TextEdit[] children = edit.getChildren();
    for (int i = 0; i < children.length; i++) {
      TextEdit child = children[i];
      child.getParent().removeChild(0);
      flatten(child, result);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:TextEditUtil.java

示例2: formatUnitSourceCode

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
/**
    * Formats the specified compilation unit.
    * 
    * @param unit the compilation unit to format
    * @param monitor the monitor for the operation
    * @throws JavaModelException
    */
public static void formatUnitSourceCode(ICompilationUnit unit,
		IProgressMonitor monitor) throws JavaModelException {
	CodeFormatter formatter = ToolFactory.createCodeFormatter(null);
	ISourceRange range = unit.getSourceRange();
	TextEdit formatEdit = formatter.format(
			CodeFormatter.K_COMPILATION_UNIT, unit.getSource(),
			range.getOffset(), range.getLength(), 0, null);
	if (formatEdit != null && formatEdit.hasChildren()) {
		unit.applyTextEdit(formatEdit, monitor);
	} else {
		monitor.done();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:21,代码来源:JDTUtils.java

示例3: isEmptyEdit

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
private static boolean isEmptyEdit(TextEdit edit) {
	return edit.getClass() == MultiTextEdit.class && ! edit.hasChildren();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:4,代码来源:CompilationUnitRewrite.java

示例4: isEmptyEdit

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
private static boolean isEmptyEdit(TextEdit edit) {
	return edit.getClass() == MultiTextEdit.class && !edit.hasChildren();
}
 
开发者ID:ponder-lab,项目名称:Constants-to-Enum-Eclipse-Plugin,代码行数:4,代码来源:ConvertConstantsToEnumRefactoring.java

示例5: isEmptyEdit

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
private static boolean isEmptyEdit(TextEdit edit) {
  return edit.getClass() == MultiTextEdit.class && !edit.hasChildren();
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:CompilationUnitRewrite.java

示例6: isPacked

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
/**
 * Returns true if the given <code>edit</code> is minimal.
 *
 * <p>That is if:
 *
 * <ul>
 *   <li><b>true</b> if <code>edit</code> is a leaf
 *   <li>if <code>edit</code> is a inner node then <b>true</b> if
 *       <ul>
 *         <li><code>edit</code> has same size as all its children
 *         <li><code>isPacked</code> is <b>true</b> for all children
 *       </ul>
 * </ul>
 *
 * @param edit the edit to verify
 * @return true if edit is minimal
 * @since 3.4
 */
public static boolean isPacked(TextEdit edit) {
  if (!(edit instanceof MultiTextEdit)) return true;

  if (!edit.hasChildren()) return true;

  TextEdit[] children = edit.getChildren();
  if (edit.getOffset() != children[0].getOffset()) return false;

  if (edit.getExclusiveEnd() != children[children.length - 1].getExclusiveEnd()) return false;

  for (int i = 0; i < children.length; i++) {
    if (!isPacked(children[i])) return false;
  }

  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:35,代码来源:TextEditUtil.java

示例7: removeTextEdit

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
/**
 * Removes a text edit from a group, optionally updating its owner change. If
 * the edit is the root edit of the owner change, the change will be removed
 * from its parent.
 * 
 * @param edit the text edit
 * @param group the text edit group to update, optional
 * @param change the change to update, optional
 * @return true if the text edit was removed
 */
public static boolean removeTextEdit(TextEdit edit, TextEditGroup group,
    TextEditBasedChange change) {
  boolean removed = false;
  boolean removeChange = false;

  // First remove this edit from its parent, if it has one
  TextEdit parentEdit = edit.getParent();
  if (parentEdit != null) {
    removed |= parentEdit.removeChild(edit);
    if (!parentEdit.hasChildren()) {
      // This parent edit is now empty, so remove it from the change and group
      edit = parentEdit;
    }
  }

  // Remove the edit from the group
  if (group != null) {
    removed |= group.removeTextEdit(edit);
    if (group.getTextEdits().length == 0) {
      // The group has no more edits. We'd like to remove it from the change,
      // but there is no API. Instead, see if this group is the only group in
      // the change and trigger removing the change altogether.
      if (change != null) {
        TextEditBasedChangeGroup[] changeGroups = change.getChangeGroups();
        if (changeGroups.length == 1
            && changeGroups[0].getTextEditGroup().equals(group)) {
          // This is the only group in the change, remove the change
          removeChange = true;
        }
      }
    }
  }

  // Remove the change if this was its root edit
  if (!removeChange && change != null && change instanceof TextFileChange) {
    TextFileChange textFileChange = (TextFileChange) change;
    if (edit.equals(textFileChange.getEdit())) {
      removeChange = true;
    }
  }

  // Execute change removal
  if (removeChange && change != null) {
    Change parentChange = change.getParent();
    if (parentChange instanceof CompositeChange) {
      removed |= ((CompositeChange) parentChange).remove(change);
    }
  }

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

示例8: merge

import org.eclipse.text.edits.TextEdit; //导入方法依赖的package包/类
/**
 * Create an edit which contains <code>edit1</code> and <code>edit2</code>
 *
 * <p>If <code>edit1</code> overlaps <code>edit2</code> this method fails with a {@link
 * MalformedTreeException}
 *
 * <p><strong>The given edits are modified and they can no longer be used.</strong>
 *
 * @param edit1 the edit to merge with edit2
 * @param edit2 the edit to merge with edit1
 * @return the merged tree
 * @throws MalformedTreeException if {@link #overlaps(TextEdit, TextEdit)} returns <b>true</b>
 * @see #overlaps(TextEdit, TextEdit)
 * @since 3.4
 */
public static TextEdit merge(TextEdit edit1, TextEdit edit2) {
  if (edit1 instanceof MultiTextEdit && !edit1.hasChildren()) {
    return edit2;
  }

  if (edit2 instanceof MultiTextEdit && !edit2.hasChildren()) {
    return edit1;
  }

  MultiTextEdit result = new MultiTextEdit();
  merge(edit1, edit2, result);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:TextEditUtil.java


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