use of org.eclipse.jface.text.link.LinkedPositionGroup in project ow by vtst.
the class AbstractCompletionProposal method setUpLinkedMode.
/**
* Set up the linked mode for the replacement text.
* @param document The document in which the replacement is made.
* @param replacementOffset The offset at which the replacement is made.
* @param fragments The fragments to insert.
* @param closingChar The closing character (used for the exit mode).
* @throws BadLocationException
*/
private void setUpLinkedMode(IDocument document, int replacementOffset, Iterable<Fragment> fragments) throws BadLocationException {
int currentOffset = replacementOffset;
boolean hasLinkedFragment = false;
LinkedModeModel model = new LinkedModeModel();
for (Fragment fragment : fragments) {
int length = fragment.getText().length();
if (fragment instanceof LinkedFragment) {
LinkedPositionGroup group = new LinkedPositionGroup();
group.addPosition(new LinkedPosition(document, currentOffset, length, LinkedPositionGroup.NO_STOP));
model.addGroup(group);
hasLinkedFragment = true;
}
currentOffset += length;
}
if (!hasLinkedFragment)
return;
model.forceInstall();
LinkedModeUI ui = new EditorLinkedModeUI(model, context.getViewer());
ui.setExitPosition(context.getViewer(), currentOffset, 0, Integer.MAX_VALUE);
ui.setExitPolicy(new ExitPolicy(makeExitCharactersForLinkedMode(), document));
ui.setDoContextInfo(true);
ui.setCyclingMode(LinkedModeUI.CYCLE_WHEN_NO_PARENT);
ui.enter();
IRegion region = ui.getSelectedRegion();
regionToSelect = new Point(region.getOffset(), region.getLength());
}
Aggregations