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


Java Utilities.getFirstNonWhiteFwd方法代码示例

本文整理汇总了Java中org.netbeans.editor.Utilities.getFirstNonWhiteFwd方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.getFirstNonWhiteFwd方法的具体用法?Java Utilities.getFirstNonWhiteFwd怎么用?Java Utilities.getFirstNonWhiteFwd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.editor.Utilities的用法示例。


在下文中一共展示了Utilities.getFirstNonWhiteFwd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: markCurrentLanguageLines

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private void markCurrentLanguageLines(BaseDocument doc, TextBounds languageBounds, EmbeddingType[] embeddingType) throws BadLocationException {
    if (languageBounds.getStartPos() == -1){
        return; // only white spaces
    }
    
    int firstLineOfTheLanguageBlock = languageBounds.getStartLine();

    int lineStart = Utilities.getRowStartFromLineOffset(doc, firstLineOfTheLanguageBlock);

    if (Utilities.getFirstNonWhiteFwd(doc, lineStart) < languageBounds.getStartPos()) {
        firstLineOfTheLanguageBlock++;
    }

    for (int i = firstLineOfTheLanguageBlock; i <= languageBounds.getEndLine(); i++) {
        embeddingType[i] = EmbeddingType.CURRENT_LANG;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TagBasedLexerFormatter.java

示例2: getFunctionBlock

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Is the identifier at the position a function call?
* It first checks whether there is a identifier under
* the cursor and then it searches for the function call
* character - usually '('. Note: Java 1.5 annotations are not
* taken as function calls.
* @param identifierBlock int[2] block delimiting the identifier
* @return int[2] block or null if there's no function call
*/
public int[] getFunctionBlock(int[] identifierBlock) throws BadLocationException {
    if (identifierBlock != null) {
        int nwPos = Utilities.getFirstNonWhiteFwd(getDocument(), identifierBlock[1]);
        if ((nwPos >= 0) && (getDocument().getChars(nwPos, 1)[0] == '(')) {
            return new int[] { identifierBlock[0], nwPos + 1 };
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ExtSyntaxSupport.java

示例3: findCommentStart

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private int findCommentStart(BaseDocument doc, CommentHandler handler, int offsetFrom, int offsetTo) throws BadLocationException {
    int from = Utilities.getFirstNonWhiteFwd(doc, offsetFrom, offsetTo);
    if (from == -1) {
        return offsetFrom;
    }
    String startDelim = handler.getCommentStartDelimiter();
    if (CharSequenceUtilities.equals(
        DocumentUtilities.getText(doc).subSequence(
            from, Math.min(offsetTo, from + startDelim.length())),
        startDelim)) {
        return from;
    }
    
    return offsetFrom;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ToggleBlockCommentAction.java

示例4: getInitialIndentFromNextLine

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private int getInitialIndentFromNextLine(final BaseDocument doc, final int line) throws BadLocationException {
    
    // get initial indent from the next line
    int initialIndent = 0;
    
    int lineStart = Utilities.getRowStartFromLineOffset(doc, line);
    int lineEnd = Utilities.getRowEnd(doc, lineStart);
    int nextNonWhiteLineStart = Utilities.getFirstNonWhiteFwd(doc, lineEnd);
    
    if (nextNonWhiteLineStart > 0){
        initialIndent = Utilities.getRowIndent(doc, nextNonWhiteLineStart, true);
    }
    
    return initialIndent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:TagBasedFormatter.java

示例5: insert

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
public void insert(MutableContext context) throws BadLocationException {
    if (!(context.getDocument() instanceof BaseDocument)) {
        return;
    }
    BaseDocument doc = (BaseDocument)context.getDocument();

    int insertPos = context.getCaretOffset();
    int caretPos = context.getComponent().getCaretPosition();
    int lineStartPos = Utilities.getRowStart(doc, insertPos);

    TokenHierarchy h = TokenHierarchy.get(doc);
    TokenSequence seq = h.tokenSequence();
    // check the actual tokens
    seq.move(context.getCaretOffset());
    int openOffset = followsOpeningTag(seq);
    
    int nonWhiteBefore = Utilities.getFirstNonWhiteBwd(doc, insertPos, lineStartPos);

    int lineEndPos = Utilities.getRowEnd(doc, caretPos);
    int nonWhiteAfter = Utilities.getFirstNonWhiteFwd(doc, caretPos, lineEndPos);

    // there is a opening tag preceding on the line && something following the insertion point
    if (nonWhiteBefore != -1 && nonWhiteAfter != -1 && openOffset >= 0) {
        // check that the following token (after whitespace(s)) is a 
        // opening tag
        seq.move(nonWhiteAfter);
        // now we need to position the caret at the END of the line immediately 
        // preceding the closing tag. Assuming it's already indented
        if (precedesClosingTag(seq)) {
            int startClosingLine = Utilities.getRowStart(doc, nonWhiteAfter);
            int nextLineStart = Utilities.getRowStart(doc, insertPos, 1);
            if (nextLineStart >= startClosingLine - 1) {
                insertBlankBetweenTabs(context, openOffset);
            }
            return;
        }
    }
    // if the rest of the line is blank, we must insert newline + indent, so the cursor
    // appears at the correct place
    if (nonWhiteAfter != -1) {
        // will be handled by the formatter automatically
        return;
    }

    int desiredIndent;

    if (openOffset != Integer.MIN_VALUE) {
        desiredIndent = IndentUtils.lineIndent(doc, Utilities.getRowStart(doc, Math.abs(openOffset)));
        if (openOffset >= 0) {
            desiredIndent += IndentUtils.indentLevelSize(doc);
        }
    } else {
        // align with the current line
        desiredIndent = IndentUtils.lineIndent(doc, lineStartPos);
    }
    String blankLine = "\n" + 
        IndentUtils.createIndentString(doc, desiredIndent);
    context.setText(blankLine, -1, blankLine.length(), 1, blankLine.length());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:LineBreakHook.java


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