org.eclipse.xtext.ui.editor.syntaxcoloring.AttributedPosition Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.syntaxcoloring.AttributedPosition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FixedHighlightingReconciler.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Update the presentation.
 *
 * @param textPresentation
 *          the text presentation
 * @param addedPositions
 *          the added positions
 * @param removedPositions
 *          the removed positions
 * @param resource
 *          the resource for which the positions have been computed
 */
private void updatePresentation(final TextPresentation textPresentation, final List<AttributedPosition> addedPositions, final List<AttributedPosition> removedPositions, final XtextResource resource) {
  final Runnable runnable = presenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
  if (runnable == null) {
    return;
  }
  final XtextResourceSet resourceSet = (XtextResourceSet) resource.getResourceSet();
  final int modificationStamp = resourceSet.getModificationStamp();
  Display display = getDisplay();
  display.asyncExec(new Runnable() {
    @Override
    public void run() {
      // never apply outdated highlighting
      if (sourceViewer != null && modificationStamp == resourceSet.getModificationStamp()) {
        runnable.run();
      }
    }
  });
}
 
Example #2
Source File: XtextStyledTextHighlightingReconciler.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Reconcile positions based on the AST subtrees
 * 
 * @param subtrees
 *            the AST subtrees
 */
private void reconcilePositions(XtextResource resource) {
	// for (int i= 0, n= subtrees.length; i < n; i++)
	// subtrees[i].accept(fCollector);
	MergingHighlightedPositionAcceptor acceptor = new MergingHighlightedPositionAcceptor(
			calculator);
	acceptor.provideHighlightingFor(resource, this);
	// calculator.provideHighlightingFor(resource, this);
	List<AttributedPosition> oldPositions = removedPositions;
	List<AttributedPosition> newPositions = new ArrayList<AttributedPosition>(
			removedPositionCount);
	for (int i = 0, n = oldPositions.size(); i < n; i++) {
		AttributedPosition current = oldPositions.get(i);
		if (current != null)
			newPositions.add(current);
	}
	removedPositions = newPositions;
}
 
Example #3
Source File: FixedHighlightingReconciler.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Start reconciling positions.
 */
private void startReconcilingPositions() {
  presenter.addAllPositions(removedPositions);
  removedPositionCount = removedPositions.size();
  for (int i = 0; i < removedPositionCount; i++) {
    AttributedPosition position = removedPositions.get(i);
    handleToListIndex.put(new PositionHandle(position.getOffset(), position.getLength(), position.getHighlighting()), i);
  }
}
 
Example #4
Source File: XtextStyledTextHighlightingReconciler.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Update the presentation.
 * 
 * @param textPresentation
 *            the text presentation
 * @param addedPositions
 *            the added positions
 * @param removedPositions
 *            the removed positions
 */
private void updatePresentation(TextPresentation textPresentation,
		List<AttributedPosition> addedPositions,
		List<AttributedPosition> removedPositions) {
	Runnable runnable = presenter.createUpdateRunnable(textPresentation,
			addedPositions, removedPositions);
	if (runnable == null)
		return;

	Display display = Display.getDefault();
	display.asyncExec(runnable);
}
 
Example #5
Source File: HighlightingPresenterPositionIndexTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	positions = Arrays.asList(new AttributedPosition(0, 2, null, null), new AttributedPosition(2, 2, null, null));
}