当前位置: 首页>>代码示例>>Java>>正文


Java Region.getOffset方法代码示例

本文整理汇总了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;
}
 
开发者ID:brocade,项目名称:vTM-eclipse,代码行数:27,代码来源:CodeLine.java

示例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);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:11,代码来源:ProposalConflictHelper.java

示例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;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:6,代码来源:DwprofileOccurrence.java

示例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 ;
    }
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:59,代码来源:GotoMatchingParenHandler.java

示例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();
}
 
开发者ID:umlet,项目名称:umlet,代码行数:4,代码来源:ImageRefHyperlinkDetector.java


注:本文中的org.eclipse.jface.text.Region.getOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。