下面列出了怎么用org.eclipse.jface.text.reconciler.DirtyRegion的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* <p>
* Searches the given {@link DirtyRegion} for annotations that now have a
* length of 0. This is caused when something that was being folded has been
* deleted. These {@link FoldingAnnotation}s are then added to the
* {@link List} of {@link FoldingAnnotation}s to be deleted
* </p>
*
* @param dirtyRegion
* find the now invalid {@link FoldingAnnotation}s in this
* {@link DirtyRegion}
* @param deletions
* the current list of {@link FoldingAnnotation}s marked for
* deletion that the newly found invalid
* {@link FoldingAnnotation}s will be added to
*/
protected void markInvalidAnnotationsForDeletion(DirtyRegion dirtyRegion, List<FoldingAnnotation> deletions,
List<FoldingAnnotation> existing) {
Iterator iter = getAnnotationIterator(dirtyRegion);
if (iter != null) {
while (iter.hasNext()) {
Annotation anno = (Annotation) iter.next();
if (anno instanceof FoldingAnnotation) {
FoldingAnnotation folding = (FoldingAnnotation) anno;
Position pos = projectionAnnotationModel.getPosition(anno);
if (pos.length == 0) {
deletions.add(folding);
} else {
existing.add(folding);
}
}
}
}
}
/**
* Override process method to call folding strategy BEFORE validation which
* can take time.
*/
@Override
protected void process(DirtyRegion dirtyRegion) {
if (!isInstalled() /* || isInRewriteSession() */ || dirtyRegion == null || getDocument() == null)
return;
/*
* if there is a folding strategy then reconcile it for the entire dirty
* region. NOTE: the folding strategy does not care about the sub
* regions.
*/
if (getTypeScriptFoldingStrategy() != null) {
getTypeScriptFoldingStrategy().reconcile(dirtyRegion, null);
}
super.process(dirtyRegion);
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
try {
IProblemRequestorExtension e= getProblemRequestorExtension();
if (e != null) {
try {
e.beginReportingSequence();
super.reconcile(dirtyRegion, subRegion);
} finally {
e.endReportingSequence();
}
} else {
super.reconcile(dirtyRegion, subRegion);
}
} finally {
reconciled();
}
}
/**
* {@inheritDoc}
*/
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
if (strategies == null)
return;
for (IReconcilingStrategy strategy : strategies) {
strategy.reconcile(dirtyRegion, subRegion);
}
}
/**
* {@inheritDoc}
*/
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
if (isSpellingEnabled()) {
super.reconcile(dirtyRegion, subRegion);
}
}
/**
* {@inheritDoc}
*/
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
try {
super.reconcile(dirtyRegion, subRegion);
} finally {
reconciled();
}
}
/**
* Given a {@link DirtyRegion} returns an {@link Iterator} of the already
* existing annotations in that region.
*
* @param dirtyRegion
* the {@link DirtyRegion} to check for existing annotations in
*
* @return an {@link Iterator} over the annotations in the given
* {@link DirtyRegion}. The iterator could have no annotations in
* it. Or <code>null</code> if projection has been disabled.
*/
private Iterator getAnnotationIterator(DirtyRegion dirtyRegion) {
Iterator annoIter = null;
// be sure project has not been disabled
if (projectionAnnotationModel != null) {
// workaround for Platform Bug 299416
int offset = dirtyRegion.getOffset();
if (offset > 0) {
offset--;
}
annoIter = projectionAnnotationModel.getAnnotationIterator(0, document.getLength(), false, false);
}
return annoIter;
}
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion)
{
for (IReconcilingStrategy strategy : fStrategies)
{
strategy.reconcile(dirtyRegion, subRegion);
}
}
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
if (fStrategies == null)
return;
for (int i= 0; i < fStrategies.length; i++)
fStrategies[i].reconcile(dirtyRegion, subRegion);
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
if (fStrategies == null)
return;
for (int i= 0; i < fStrategies.length; i++)
fStrategies[i].reconcile(dirtyRegion, subRegion);
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
reconcile(subRegion);
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
// Do nothing
}
/**
* {@inheritDoc}
*/
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
reconcileInternal();
}
/**
* {@inheritDoc}
*/
@Override
public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) {
reconcile(null, dirtyRegion, subRegion);
}
private void reconcile(final IRegion partition, final DirtyRegion dirtyRegion, final IRegion subRegion) {
if (editor != null) {
final HashMap<TLCProjectionAnnotation, Position> regionMap
= determineFoldingRegions(partition, dirtyRegion, subRegion);
final Annotation[] deletions;
final HashMap<TLCProjectionAnnotation, Position> regionsToAdd = new HashMap<>();
synchronized (currentAnnotations) {
for (final Map.Entry<TLCProjectionAnnotation, Position> me : regionMap.entrySet()) {
if (!currentAnnotations.remove(me.getKey())) {
regionsToAdd.put(me.getKey(), me.getValue());
}
}
deletions = currentAnnotations.toArray(new Annotation[currentAnnotations.size()]);
currentAnnotations.clear();
currentAnnotations.addAll(regionMap.keySet());
}
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
editor.modifyProjectionAnnotations(deletions, regionsToAdd);
if (projectionViewer != null) {
final ProjectionAnnotationModel model = projectionViewer.getProjectionAnnotationModel();
final boolean block = foldBlockComments.get();
final boolean pcal = foldPlusCalAlgorithm.get();
final boolean translated = foldTranslatedPlusCalBlock.get();
// We could do even more optimization than this, but this is better than none.
if (block || pcal || translated) {
for (final TLCProjectionAnnotation annotation : currentAnnotations) {
final boolean collapse;
switch (annotation.getTLCType()) {
case BLOCK_COMMENT:
collapse = block;
break;
case PCAL_BLOCK:
collapse = pcal;
break;
default:
collapse = translated;
}
if (collapse) {
model.collapse(annotation);
}
}
}
}
}
});
}
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
initialReconcile();
}
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
reconcile(subRegion);
}
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion)
{
// we can't do incremental yet
}
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
reconcile(false);
}
public void reconcile( DirtyRegion dirtyRegion, IRegion subRegion )
{
reconcile( subRegion );
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
reconcile(subRegion);
}