Class OrganizeImportsOperation
java.lang.Object
org.eclipse.jdt.core.manipulation.OrganizeImportsOperation
- All Implemented Interfaces:
org.eclipse.core.resources.IWorkspaceRunnable
,org.eclipse.core.runtime.ICoreRunnable
public class OrganizeImportsOperation
extends Object
implements org.eclipse.core.resources.IWorkspaceRunnable
- Since:
- 1.10
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionOrganizeImportsOperation
(ICompilationUnit cu, CompilationUnit astRoot, boolean ignoreLowerCaseNames, boolean save, boolean allowSyntaxErrors, OrganizeImportsOperation.IChooseImportQuery chooseImportQuery) Creates a new OrganizeImportsOperation operation.OrganizeImportsOperation
(ICompilationUnit cu, CompilationUnit astRoot, boolean ignoreLowerCaseNames, boolean save, boolean allowSyntaxErrors, OrganizeImportsOperation.IChooseImportQuery chooseImportQuery, boolean restoreExistingImports) Creates a new OrganizeImportsOperation operation. -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.text.edits.TextEdit
createTextEdit
(org.eclipse.core.runtime.IProgressMonitor m) int
int
After executing the operation, returnsnull
if the operation has been executed successfully or the range where parsing failed.org.eclipse.core.runtime.jobs.ISchedulingRule
void
run
(org.eclipse.core.runtime.IProgressMonitor monitor) Runs the operation.
-
Constructor Details
-
OrganizeImportsOperation
public OrganizeImportsOperation(ICompilationUnit cu, CompilationUnit astRoot, boolean ignoreLowerCaseNames, boolean save, boolean allowSyntaxErrors, OrganizeImportsOperation.IChooseImportQuery chooseImportQuery) Creates a new OrganizeImportsOperation operation.- Parameters:
cu
- The compilation unitastRoot
- the compilation unit AST nodeignoreLowerCaseNames
- when true, type names starting with a lower case are ignoredsave
- If set, the result will be savedallowSyntaxErrors
- If set, the operation will only proceed when the compilation unit has no syntax errorschooseImportQuery
- Query element to be used for UI interaction ornull
to not select anything
-
OrganizeImportsOperation
public OrganizeImportsOperation(ICompilationUnit cu, CompilationUnit astRoot, boolean ignoreLowerCaseNames, boolean save, boolean allowSyntaxErrors, OrganizeImportsOperation.IChooseImportQuery chooseImportQuery, boolean restoreExistingImports) Creates a new OrganizeImportsOperation operation.- Parameters:
cu
- The compilation unitastRoot
- the compilation unit AST nodeignoreLowerCaseNames
- when true, type names starting with a lower case are ignoredsave
- If set, the result will be savedallowSyntaxErrors
- If set, the operation will only proceed when the compilation unit has no syntax errorschooseImportQuery
- Query element to be used for UI interaction ornull
to not select anythingrestoreExistingImports
- when true, the operation will restore existing imports- Since:
- 1.17
-
-
Method Details
-
run
public void run(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, org.eclipse.core.runtime.OperationCanceledException Runs the operation.- Specified by:
run
in interfaceorg.eclipse.core.runtime.ICoreRunnable
- Specified by:
run
in interfaceorg.eclipse.core.resources.IWorkspaceRunnable
- Parameters:
monitor
- the progress monitor- Throws:
org.eclipse.core.runtime.CoreException
- thrown when the operation failedorg.eclipse.core.runtime.OperationCanceledException
- Runtime error thrown when operation is canceled.
-
createTextEdit
public org.eclipse.text.edits.TextEdit createTextEdit(org.eclipse.core.runtime.IProgressMonitor m) throws org.eclipse.core.runtime.CoreException, org.eclipse.core.runtime.OperationCanceledException - Throws:
org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.OperationCanceledException
-
getParseError
After executing the operation, returnsnull
if the operation has been executed successfully or the range where parsing failed.- Returns:
- returns the parse error
-
getNumberOfImportsAdded
public int getNumberOfImportsAdded()- Returns:
- Returns the number of import statements added for this operation
-
getNumberOfImportsRemoved
public int getNumberOfImportsRemoved()- Returns:
- Returns the number of import statements removed for this operation
-
getScheduleRule
public org.eclipse.core.runtime.jobs.ISchedulingRule getScheduleRule()- Returns:
- Returns the scheduling rule for this operation
-