# Class CleanUpContext

java.lang.Object
org.eclipse.jdt.core.manipulation.CleanUpContextCore
org.eclipse.jdt.ui.cleanup.CleanUpContext

public class CleanUpContext extends CleanUpContextCore
The context that contains all information required by a clean up to create a fix. Originally from org.eclipse.jdt.ui 3.5

Since:
  1.21

## Constructor Summary

Constructors
Constructor
Description
`CleanUpContext(ICompilationUnit unit, CompilationUnit ast)`
Creates a new clean up context.

## Method Summary

Modifier and Type
Method
Description
`CompilationUnit`
`getAST()`
An AST built from the compilation unit to fix.
`ICompilationUnit`
`getCompilationUnit()`
The compilation unit to clean up.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CleanUpContext

public CleanUpContext(ICompilationUnit unit, CompilationUnit ast)
Creates a new clean up context.

Parameters:
  `unit` - the compilation unit
  `ast` - the AST, can be `null` if `CleanUpRequirements.requiresAST()` returns `false`. The AST is guaranteed to contain changes made by previous clean ups only if `CleanUpRequirements.requiresFreshAST()` returns `true`.

## Method Details

### getCompilationUnit

public ICompilationUnit getCompilationUnit()
Description copied from class: `CleanUpContextCore`
The compilation unit to clean up.

Overrides:
  `getCompilationUnit` in class `CleanUpContextCore`
Returns:
  the compilation unit to clean up

### getAST

public CompilationUnit getAST()
Description copied from class: `CleanUpContextCore`
An AST built from the compilation unit to fix.

Can be `null` if `CleanUpRequirementsCore.requiresAST()` returns `false`. The AST is guaranteed to contain changes made by previous clean ups only if `CleanUpRequirementsCore.requiresFreshAST()` returns `true`.

Clients should check the AST API level and do nothing if they are given an AST they can't handle (see `AST.apiLevel()`).

Overrides:
  `getAST` in class `CleanUpContextCore`
Returns:
  an AST or `null` if none required