當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。