本文整理匯總了Java中org.eclipse.jface.text.Region.getLength方法的典型用法代碼示例。如果您正苦於以下問題:Java Region.getLength方法的具體用法?Java Region.getLength怎麽用?Java Region.getLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.Region
的用法示例。
在下文中一共展示了Region.getLength方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRegionType
import org.eclipse.jface.text.Region; //導入方法依賴的package包/類
/**
* Get the partition type for the specified offset. The offset must be within
* this line.
* @param offset The offset relative to the beginning of the document.
* @return The partition that the offset is in, or null if it is outside the
* range of this line.
*/
public Partition getRegionType( int offset )
{
if( offset >= start && offset <= commentStart ) {
for( Region region : stringAreas ) {
if( offset > region.getOffset() &&
offset <= region.getOffset() + region.getLength() )
{
return Partition.STRING;
}
}
return Partition.CODE;
}
if( offset > commentStart ) {
return Partition.COMMENT;
}
ZDebug.dumpStackTrace( "Offset out of range? ", offset );
return null;
}
示例2: isContainedIn
import org.eclipse.jface.text.Region; //導入方法依賴的package包/類
protected boolean isContainedIn(Region region, int offset) {
int regionOffset = region.getOffset();
int regionEnd = regionOffset + region.getLength();
return offset >= regionOffset && offset <= regionEnd;
}
示例3: getSelectedParen
import org.eclipse.jface.text.Region; //導入方法依賴的package包/類
/**
* Sets currLoc, and returns the index of the selected paren in PARENS.
* If the region has zero length, then it selects the paren to its left and
* sets currLoc to the selection--or the 2-char paren it's in the
* middle of. Otherwise, the region has to select a paren,
* and currLoc is set to the position to the right of that paren.
*
* @param selectedRegion
*/
private int getSelectedParen(Region selectedRegion)
throws ParenErrorException {
currLoc = selectedRegion.getOffset();
int selectedParenIdx;
if (selectedRegion.getLength() == 0) {
selectedParenIdx = getParenToLeftOf(currLoc);
if (selectedParenIdx == -1) {
int tryNext = getParenToLeftOf(currLoc + 1);
if (tryNext == -1 || PARENS[tryNext].length() == 1) {
throw new ParenErrorException("Paren not selected", null, null);
}
currLoc++;
return tryNext;
}
} else {
String selection = null; // initialization to keep compiler happy.
try {
selection = document.get(selectedRegion.getOffset(),
selectedRegion.getLength());
} catch (BadLocationException e) {
// This should not happen
System.out.println(
"BadLocationException in GotoMatchingParenHandler.getSelectedParen");
}
selectedParenIdx = 0;
boolean notDone = true ;
while (notDone && (selectedParenIdx < PARENS.length)) {
if (selection.equals(PARENS[selectedParenIdx])) {
notDone = false;
}
else {
selectedParenIdx++;
}
}
if (notDone) {
throw new ParenErrorException("Selection is not a paren", null, null);
}
currLoc = currLoc + selectedRegion.getLength();
}
// Now test if we're between "(" and "*".
if ( selectedParenIdx == LEFT_ROUND_PAREN_IDX
&& getParenToLeftOf(currLoc + 1) == COMMENT_BEGIN_IDX) {
// throw new ParenErrorException("Selection between ( and *", null);
currLoc++;
return BEGIN_MULTILINE_COMMENT_IDX;
}
return selectedParenIdx ;
}
示例4: doIntersect
import org.eclipse.jface.text.Region; //導入方法依賴的package包/類
private boolean doIntersect(Region a, IRegion b) {
return a.getOffset() <= b.getOffset() + b.getLength() && b.getOffset() <= a.getOffset() + a.getLength();
}