本文整理汇总了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;
}
}
}
}
示例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));
}
}
}