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


Java ImportRewrite.hasRecordedChanges方法代码示例

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


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

示例1: rewriteImports

import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; //导入方法依赖的package包/类
public void rewriteImports(TextChangeManager changeManager, IProgressMonitor pm)
    throws CoreException {
  for (Iterator<Entry<ICompilationUnit, ImportChange>> iter =
          fImportChanges.entrySet().iterator();
      iter.hasNext(); ) {
    Entry<ICompilationUnit, ImportChange> entry = iter.next();
    ICompilationUnit cu = entry.getKey();
    ImportChange importChange = entry.getValue();

    ImportRewrite importRewrite = StubUtility.createImportRewrite(cu, true);
    importRewrite.setFilterImplicitImports(false);
    for (Iterator<String> iterator = importChange.fStaticToRemove.iterator();
        iterator.hasNext(); ) {
      importRewrite.removeStaticImport(iterator.next());
    }
    for (Iterator<String> iterator = importChange.fToRemove.iterator(); iterator.hasNext(); ) {
      importRewrite.removeImport(iterator.next());
    }
    for (Iterator<String[]> iterator = importChange.fStaticToAdd.iterator();
        iterator.hasNext(); ) {
      String[] toAdd = iterator.next();
      importRewrite.addStaticImport(toAdd[0], toAdd[1], true);
    }
    for (Iterator<String> iterator = importChange.fToAdd.iterator(); iterator.hasNext(); ) {
      importRewrite.addImport(iterator.next());
    }

    if (importRewrite.hasRecordedChanges()) {
      TextEdit importEdit = importRewrite.rewriteImports(pm);
      String name = RefactoringCoreMessages.RenamePackageRefactoring_update_imports;
      try {
        TextChangeCompatibility.addTextEdit(changeManager.get(cu), name, importEdit);
      } catch (MalformedTreeException e) {
        JavaPlugin.logErrorMessage(
            "MalformedTreeException while processing cu " + cu); // $NON-NLS-1$
        throw e;
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:41,代码来源:RenamePackageProcessor.java

示例2: addImportRewriteUpdates

import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; //导入方法依赖的package包/类
private void addImportRewriteUpdates(TextChangeManager changeManager) throws CoreException {
  for (Iterator<ICompilationUnit> iter = fImportRewrites.keySet().iterator(); iter.hasNext(); ) {
    ICompilationUnit cu = iter.next();
    ImportRewrite importRewrite = fImportRewrites.get(cu);
    if (importRewrite != null && importRewrite.hasRecordedChanges()) {
      TextChangeCompatibility.addTextEdit(
          changeManager.get(cu),
          RefactoringCoreMessages.MoveCuUpdateCreator_update_imports,
          importRewrite.rewriteImports(null));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:MoveCuUpdateCreator.java


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