org.electrocodeogram.cpc.core.api.provider.track
Interface IPositionUpdateStrategyProvider

All Superinterfaces:
IProvider

public interface IPositionUpdateStrategyProvider
extends IProvider

An IPositionUpdateStrategyProvider specifies how clone entries should be affected by modifications to a file. I.e. whether to consider text typed next to a clone to be part of the clone or not.

The CPC Track module uses the main IPositionUpdateStrategyProvider for all clone position modifications.

Author:
vw
See Also:
CPCPosition, CPCDocumentEvent

Method Summary
 void extractCloneData(org.eclipse.jface.text.Position[] positions, java.util.List<IClone> movedClones, java.util.List<IClone> modifiedClones, java.util.List<IClone> removedClones, org.eclipse.jface.text.IDocument document)
          Takes an array of CPCPositions and extracts any clone data modifications from it.
 boolean updatePositions(org.eclipse.jface.text.DocumentEvent event, org.eclipse.jface.text.Position[] positions)
          Updates the given positions in-place according to the given event.
 
Methods inherited from interface org.electrocodeogram.cpc.core.api.provider.IProvider
getProviderName, toString
 

Method Detail

updatePositions

boolean updatePositions(org.eclipse.jface.text.DocumentEvent event,
                        org.eclipse.jface.text.Position[] positions)
Updates the given positions in-place according to the given event.
The IClone elements inside of any affected CPCPosition object are not updated.

NOTE: The signature of this interface was dictated by performance considerations. To still allow reuse in other contexts an implementation must not make use of any other methods of the encapsulated document object than IDocument.get() and IDocument.get(int, int).
A caller may provide a custom IDocument implementation which supports only those two methods.

NOTE: An implementation is not allowed to access an IStoreProvider. See comments in CPCPositionUpdater for more details.

Parameters:
event - the event to process, never null. Make sure you understand the limitations of the underlying IDocument object if you implement this interface.
positions - an array with positions which should be updated, never null. Positions are updated in place. All positions are guaranteed to be CPCPosition objects.
Returns:
true if at least one position was modified, false otherwise.
See Also:
CPCPosition

extractCloneData

void extractCloneData(org.eclipse.jface.text.Position[] positions,
                      java.util.List<IClone> movedClones,
                      java.util.List<IClone> modifiedClones,
                      java.util.List<IClone> removedClones,
                      org.eclipse.jface.text.IDocument document)
Takes an array of CPCPositions and extracts any clone data modifications from it.
Detailed descriptions of each modification are added to each clone's ICloneModificationHistoryExtension.
Clones may be part of the movedClones and modifiedClones lists at the same time.
The removedClones list must always be disjunct from the movedClones and modifiedClones lists.

Parameters:
positions - an array of CPCPositions to extract data from, never null.
movedClones - an empty result list in which moved clones should be stored, never null.
modifiedClones - an empty result list in which modified clones should be stored, never null.
removedClones - an empty result list in which removed clones should be stored, never null.
document - optional parameter, if present any removed clone will also have its position removed from the document, may be NULL.