Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 itemis AG ( and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at /
 package org.eclipse.xtext.ui.editor.doubleClicking;
import  org.eclipse.jface.text.BadLocationException;
import  org.eclipse.jface.text.IDocument;
import  org.eclipse.jface.text.IRegion;
import  org.eclipse.jface.text.ITypedRegion;
import  org.eclipse.jface.text.Region;

Custom partition selector that allows to strip a fixed set of characters from the beginning and the end of a partition.

The implementation was heavily adapted from


Sebastian Zarnekow - Initial contribution and API
 * @see
	private int fLeftBorder;
	private int fRightBorder;

Creates a new partition double click selector for the given document partitioning.

partitioning the document partitioning
leftBorder number of characters to ignore from the left border of the partition
rightBorder number of characters to ignore from the right border of the partition
	public FixedCharCountPartitionDoubleClickSelector(String partitioningint leftBorderint rightBorder) {
		 = leftBorder;
		 = rightBorder;
	protected IRegion getSelectedRegion(IDocument document, ITypedRegion completePartitionthrows BadLocationException {
		if ( == 0 &&  == 0)
			return completePartition;
		if ( == -1) {
			String delimiter = document.getLineDelimiter(document.getLineOfOffset(completePartition.getOffset()
completePartition.getLength() - 1));
			if (delimiter == null)
				 = delimiter.length();
		return new Region(completePartition.getOffset() + completePartition.getLength() - 
New to GrepCode? Check out our FAQ X