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
  • 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 unit
      astRoot - the compilation unit AST node
      ignoreLowerCaseNames - when true, type names starting with a lower case are ignored
      save - If set, the result will be saved
      allowSyntaxErrors - If set, the operation will only proceed when the compilation unit has no syntax errors
      chooseImportQuery - Query element to be used for UI interaction or null 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 unit
      astRoot - the compilation unit AST node
      ignoreLowerCaseNames - when true, type names starting with a lower case are ignored
      save - If set, the result will be saved
      allowSyntaxErrors - If set, the operation will only proceed when the compilation unit has no syntax errors
      chooseImportQuery - Query element to be used for UI interaction or null to not select anything
      restoreExistingImports - 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 interface org.eclipse.core.runtime.ICoreRunnable
      Specified by:
      run in interface org.eclipse.core.resources.IWorkspaceRunnable
      Parameters:
      monitor - the progress monitor
      Throws:
      org.eclipse.core.runtime.CoreException - thrown when the operation failed
      org.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

      public IProblem getParseError()
      After executing the operation, returns null 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