# Class CompilationUnitChange

java.lang.Object
org.eclipse.ltk.core.refactoring.Change
org.eclipse.ltk.core.refactoring.TextEditBasedChange
org.eclipse.ltk.core.refactoring.TextChange
org.eclipse.ltk.core.refactoring.TextFileChange
org.eclipse.jdt.core.refactoring.CompilationUnitChange

All Implemented Interfaces:
  `org.eclipse.core.runtime.IAdaptable`

public class CompilationUnitChange extends org.eclipse.ltk.core.refactoring.TextFileChange
A `TextFileChange` that operates on an `ICompilationUnit` in the workspace.

Since:
  1.3

## Field Summary

### Fields inherited from class org.eclipse.ltk.core.refactoring.TextFileChange

`FORCE_SAVE, KEEP_SAVE_STATE, LEAVE_DIRTY`

## Constructor Summary

Constructors
Constructor
Description
`CompilationUnitChange(String name, ICompilationUnit cunit)`
Creates a new `CompilationUnitChange`.

## Method Summary

Modifier and Type
Method
Description
`protected org.eclipse.jface.text.IDocument`
`acquireDocument(org.eclipse.core.runtime.IProgressMonitor pm)`
`protected org.eclipse.ltk.core.refactoring.Change`
`createUndoChange(org.eclipse.text.edits.UndoEdit edit, org.eclipse.ltk.core.refactoring.ContentStamp stampToRestore)`
`<T> T`
`getAdapter(Class<T> adapter)`
`ICompilationUnit`
`getCompilationUnit()`
Returns the compilation unit this change works on.
`org.eclipse.ltk.core.refactoring.ChangeDescriptor`
`getDescriptor()`
`Object`
`getModifiedElement()`
`protected void`
`releaseDocument(org.eclipse.jface.text.IDocument document, org.eclipse.core.runtime.IProgressMonitor pm)`
`void`
`setDescriptor(org.eclipse.ltk.core.refactoring.ChangeDescriptor descriptor)`
Sets the refactoring descriptor for this change.

### Methods inherited from class org.eclipse.ltk.core.refactoring.TextFileChange

`commit, createUndoChange, dispose, getAffectedObjects, getFile, getSaveMode, initializeValidationData, isDocumentAcquired, isDocumentModified, isValid, needsSaving, performEdits, setSaveMode`

### Methods inherited from class org.eclipse.ltk.core.refactoring.TextChange

`addEdit, addTextEditChangeGroup, addTextEditGroup, getCurrentContent, getCurrentContent, getCurrentDocument, getEdit, getPreviewContent, getPreviewContent, getPreviewContent, getPreviewDocument, getPreviewEdit, getPreviewEdits, getTextEditChangeGroups, perform, setEdit, setKeepPreviewEdits`

### Methods inherited from class org.eclipse.ltk.core.refactoring.TextEditBasedChange

`addChangeGroup, getChangeGroups, getKeepPreviewEdits, getName, getTextType, hasOneGroupCategory, setEnabled, setTextType`

### Methods inherited from class org.eclipse.ltk.core.refactoring.Change

`getParent, isEnabled, setEnabledShallow`

### Methods inherited from class Object

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

## Constructor Details

### CompilationUnitChange

public CompilationUnitChange(String name, ICompilationUnit cunit)
Creates a new `CompilationUnitChange`.

Parameters:
  `name` - the change's name, mainly used to render the change in the UI
  `cunit` - the compilation unit this change works on

## Method Details

### getModifiedElement

public Object getModifiedElement()

Overrides:
  `getModifiedElement` in class `org.eclipse.ltk.core.refactoring.TextFileChange`

### getCompilationUnit

public ICompilationUnit getCompilationUnit()
Returns the compilation unit this change works on.

Returns:
  the compilation unit this change works on

### acquireDocument

protected org.eclipse.jface.text.IDocument acquireDocument(org.eclipse.core.runtime.IProgressMonitor pm) throws org.eclipse.core.runtime.CoreException

Overrides:
  `acquireDocument` in class `org.eclipse.ltk.core.refactoring.TextFileChange`
Throws:
  `org.eclipse.core.runtime.CoreException`

### releaseDocument

protected void releaseDocument(org.eclipse.jface.text.IDocument document, org.eclipse.core.runtime.IProgressMonitor pm) throws org.eclipse.core.runtime.CoreException

Overrides:
  `releaseDocument` in class `org.eclipse.ltk.core.refactoring.TextFileChange`
Throws:
  `org.eclipse.core.runtime.CoreException`

### createUndoChange

protected org.eclipse.ltk.core.refactoring.Change createUndoChange(org.eclipse.text.edits.UndoEdit edit, org.eclipse.ltk.core.refactoring.ContentStamp stampToRestore)

Overrides:
  `createUndoChange` in class `org.eclipse.ltk.core.refactoring.TextFileChange`

### getAdapter

public <T> T getAdapter(Class<T> adapter)

Specified by:
  `getAdapter` in interface `org.eclipse.core.runtime.IAdaptable`
Overrides:
  `getAdapter` in class `org.eclipse.ltk.core.refactoring.Change`

### setDescriptor

public void setDescriptor(org.eclipse.ltk.core.refactoring.ChangeDescriptor descriptor)
Sets the refactoring descriptor for this change.

Parameters:
  `descriptor` - the descriptor to set, or `null` to set no descriptor

### getDescriptor

public org.eclipse.ltk.core.refactoring.ChangeDescriptor getDescriptor()

Overrides:
  `getDescriptor` in class `org.eclipse.ltk.core.refactoring.Change`