本文整理汇总了Java中org.eclipse.jface.text.Region.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Region.getOffset方法的具体用法?Java Region.getOffset怎么用?Java Region.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.Region
的用法示例。
在下文中一共展示了Region.getOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: existsConflict
import org.eclipse.jface.text.Region; //导入方法依赖的package包/类
public boolean existsConflict(String proposal, ContentAssistContext context) {
// hidden node between lastCompleteNode and currentNode?
INode lastCompleteNode = context.getLastCompleteNode();
Region replaceRegion = context.getReplaceRegion();
int nodeEnd = lastCompleteNode.getOffset() + lastCompleteNode.getLength();
if (nodeEnd < replaceRegion.getOffset())
return false;
return existsConflict(lastCompleteNode, replaceRegion.getOffset(), proposal, context);
}
示例3: 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;
}
示例4: 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 ;
}
示例5: 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();
}