Class ImportRewrite

java.lang.Object
org.aspectj.org.eclipse.jdt.core.dom.rewrite.ImportRewrite

public final class ImportRewrite extends Object
The ImportRewrite helps updating imports following a import order and on-demand imports threshold as configured by a project.

The import rewrite is created on a compilation unit and collects references to types that are added or removed. When adding imports, e.g. using addImport(String), the import rewrite evaluates if the type can be imported and returns the a reference to the type that can be used in code. This reference is either unqualified if the import could be added, or fully qualified if the import failed due to a conflict with another element of the same name.

On rewriteImports(IProgressMonitor) the rewrite translates these descriptions into text edits that can then be applied to the original source. The rewrite infrastructure tries to generate minimal text changes and only works on the import statements. It is possible to combine the result of an import rewrite with the result of a ASTRewrite as long as no import statements are modified by the AST rewrite.

The options controlling the import order and on-demand thresholds are:

This class is not intended to be subclassed.

Since:
3.2