Package org.eclipse.ltk.core.refactoring
Class TextEditBasedChange
java.lang.Object
org.eclipse.ltk.core.refactoring.Change
org.eclipse.ltk.core.refactoring.TextEditBasedChange
- All Implemented Interfaces:
IAdaptable
- Direct Known Subclasses:
MultiStateTextFileChange
,TextChange
An abstract base implementation of a change which is based on text edits.
- Since:
- 3.2
-
Constructor Summary
ModifierConstructorDescriptionprotected
TextEditBasedChange
(String name) Creates a new abstract text edit change with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds atext edit change group
.void
addTextEditGroup
(TextEditGroup group) Adds atext edit group
.final TextEditBasedChangeGroup[]
Returns thetext edit change groups
managed by this buffer change.abstract String
Returns the current content of the document this text change is associated with.abstract String
getCurrentContent
(IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) Returns the current content of the text edit change clipped to a specific region.boolean
Returns whether preview edits are remembered for further region tracking or not.getName()
Returns the human readable name of this change.abstract String
Returns the preview content as a string.abstract String
getPreviewContent
(TextEditBasedChangeGroup[] changeGroups, IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) Returns a preview of the text edit change clipped to a specific region.Returns the text edit change's text type.boolean
hasOneGroupCategory
(List<GroupCategory> groupCategories) Returnstrue
if the change has one of the given group categories.void
setEnabled
(boolean enabled) Sets whether this change is enabled or not.void
setKeepPreviewEdits
(boolean keep) Controls whether the text edit change should keep executed edits during preview generation.void
setTextType
(String type) Sets the text type.Methods inherited from class org.eclipse.ltk.core.refactoring.Change
dispose, getAdapter, getAffectedObjects, getDescriptor, getModifiedElement, getParent, initializeValidationData, isEnabled, isValid, perform, setEnabledShallow
-
Constructor Details
-
TextEditBasedChange
Creates a new abstract text edit change with the specified name. The name is a human-readable value that is displayed to users. The name does not need to be unique, but it must not benull
.The text type of this text edit change is set to
txt
.- Parameters:
name
- the name of the text edit change- See Also:
-
-
Method Details
-
addChangeGroup
Adds atext edit change group
. The edits managed by the given text edit change group must be part of the change's root edit.- Parameters:
group
- the text edit change group to add
-
addTextEditGroup
Adds atext edit group
. This method is a convenience method for callingchange.addChangeGroup(new TextEditBasedChangeGroup(change, group));
.- Parameters:
group
- the text edit group to add
-
hasOneGroupCategory
Returnstrue
if the change has one of the given group categories. Otherwisefalse
is returned.- Parameters:
groupCategories
- the group categories to check- Returns:
- whether the change has one of the given group categories
- Since:
- 3.2
-
getChangeGroups
Returns thetext edit change groups
managed by this buffer change.- Returns:
- the text edit change groups
-
getCurrentContent
Returns the current content of the document this text change is associated with.- Parameters:
pm
- a progress monitor to report progress ornull
if no progress reporting is desired- Returns:
- the current content of the text edit change
- Throws:
CoreException
- if the content can't be accessed
-
getCurrentContent
public abstract String getCurrentContent(IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) throws CoreException Returns the current content of the text edit change clipped to a specific region. The region is determined as follows:- if
expandRegionToFullLine
isfalse
then the parameterregion
determines the clipping. - if
expandRegionToFullLine
istrue
then the region determined by the parameterregion
is extended to cover full lines. - if
surroundingLines
> 0 then the given number of surrounding lines is added. The value ofsurroundingLines
is only considered ifexpandRegionToFullLine
istrue
- Parameters:
region
- the starting region for the text to be returnedexpandRegionToFullLine
- iftrue
is passed the region is extended to cover full linessurroundingLines
- the number of surrounding lines to be added to the clipping region. Is only considered ifexpandRegionToFullLine
istrue
pm
- a progress monitor to report progress ornull
if no progress reporting is desired- Returns:
- the current content of the text edit change clipped to a region determined by the given parameters.
- Throws:
CoreException
- if an exception occurs while accessing the current content
- if
-
getKeepPreviewEdits
public boolean getKeepPreviewEdits()Returns whether preview edits are remembered for further region tracking or not.- Returns:
true
if executed text edits are remembered during preview generation; otherwisefalse
-
getName
Description copied from class:Change
Returns the human readable name of this change. The name MUST not benull
. -
getPreviewContent
public abstract String getPreviewContent(TextEditBasedChangeGroup[] changeGroups, IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) throws CoreException Returns a preview of the text edit change clipped to a specific region. The preview is created by applying the text edits managed by the given array oftext edit change groups
. The region is determined as follows:- if
expandRegionToFullLine
isfalse
then the parameterregion
determines the clipping. - if
expandRegionToFullLine
istrue
then the region determined by the parameterregion
is extended to cover full lines. - if
surroundingLines
> 0 then the given number of surrounding lines is added. The value ofsurroundingLines
is only considered ifexpandRegionToFullLine
istrue
- Parameters:
changeGroups
- a set of change groups for which a preview is to be generatedregion
- the starting region for the clippingexpandRegionToFullLine
- iftrue
is passed the region is extended to cover full linessurroundingLines
- the number of surrounding lines to be added to the clipping region. Is only considered ifexpandRegionToFullLine
istrue
pm
- a progress monitor to report progress ornull
if no progress reporting is desired- Returns:
- the current content of the text change clipped to a region determined by the given parameters.
- Throws:
CoreException
- if an exception occurs while generating the preview- See Also:
- if
-
getPreviewContent
Returns the preview content as a string.- Parameters:
pm
- a progress monitor to report progress ornull
if no progress reporting is desired- Returns:
- the preview
- Throws:
CoreException
- if the preview can't be created
-
getTextType
Returns the text edit change's text type.- Returns:
- the text edit change's text type
-
setEnabled
public void setEnabled(boolean enabled) Description copied from class:Change
Sets whether this change is enabled or not.- Overrides:
setEnabled
in classChange
- Parameters:
enabled
-true
to enable this change;false
otherwise
-
setKeepPreviewEdits
public void setKeepPreviewEdits(boolean keep) Controls whether the text edit change should keep executed edits during preview generation.- Parameters:
keep
- iftrue
executed preview edits are kept
-
setTextType
Sets the text type. The text type is used to determine the content merge viewer used to present the difference between the original and the preview content in the user interface. Content merge viewers are defined via the extension pointorg.eclipse.compare.contentMergeViewers
.The default text type is
txt
.- Parameters:
type
- the text type. Ifnull
is passed the text type is reseted to the default text typetxt
.
-