Search in sources :

Example 1 with ProjectionAnnotationModel

use of org.eclipse.jface.text.source.projection.ProjectionAnnotationModel in project dbeaver by serge-rider.

the class SQLReconcilingStrategy method calculatePositions.

protected void calculatePositions() {
    ProjectionAnnotationModel annotationModel = editor.getAnnotationModel();
    if (annotationModel == null) {
        return;
    }
    Set<SQLScriptPosition> removedPositions = editor.getRuleManager().getRemovedPositions(true);
    Set<SQLScriptPosition> addedPositions = editor.getRuleManager().getAddedPositions(true);
    Annotation[] removedAnnotations = null;
    if (!removedPositions.isEmpty()) {
        removedAnnotations = new Annotation[removedPositions.size()];
        int index = 0;
        for (SQLScriptPosition pos : removedPositions) {
            removedAnnotations[index++] = pos.getFoldingAnnotation();
        }
    }
    Map<Annotation, Position> addedAnnotations = null;
    if (!addedPositions.isEmpty()) {
        addedAnnotations = new HashMap<>();
        for (SQLScriptPosition pos : addedPositions) {
            addedAnnotations.put(pos.getFoldingAnnotation(), pos);
        }
    }
    if (removedAnnotations != null || addedAnnotations != null) {
        annotationModel.modifyAnnotations(removedAnnotations, addedAnnotations, null);
    }
/*
        final List<Position> positions;

        try {
            positions = parseRegion();
        } catch (BadLocationException e) {
            e.printStackTrace();
            return;
        }
*/
/*
        Display.getDefault().asyncExec(new Runnable()
        {
            public void run()
            {
                editor.updateFoldingStructure(regionOffset, regionLength, positions);
            }

        });
*/
}
Also used : ProjectionAnnotationModel(org.eclipse.jface.text.source.projection.ProjectionAnnotationModel) Position(org.eclipse.jface.text.Position) Annotation(org.eclipse.jface.text.source.Annotation)

Aggregations

Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 ProjectionAnnotationModel (org.eclipse.jface.text.source.projection.ProjectionAnnotationModel)1