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


Java Token.text方法代码示例

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


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

示例1: tokenText

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
private static String tokenText(Token<?> token) {
    CharSequence text = token.text();
    StringBuilder sb = new StringBuilder(text.length());
    
    for(int i = 0; i < text.length(); i++) {
        char ch = text.charAt(i);
        if (Character.isISOControl(ch)) {
            switch (ch) {
            case '\n' : sb.append("\\n"); break; //NOI18N
            case '\t' : sb.append("\\t"); break; //NOI18N
            case '\r' : sb.append("\\r"); break; //NOI18N
            default : sb.append("\\").append(Integer.toOctalString(ch)); break; //NOI18N
            }
        } else {
            sb.append(ch);
        }
    }
    
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SyntaxHighlighting.java

示例2: isLineBreak

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
/**
 * Tests if the token part before {@code pos} is a javadoc line break.
 * @param token a token to test
 * @param pos position in the token
 * @return {@code true} in case the token is something like {@code "\n\t* |\n\t*"}
 */
public static boolean isLineBreak(Token<JavadocTokenId> token, int pos) {
    if (token == null || token.id() != JavadocTokenId.OTHER_TEXT) {
        return false;
    }
    try {
        CharSequence text = token.text();
        if (pos < token.length())
            text = text.subSequence(0, pos);
        boolean result = pos > 0
                && JAVADOC_LINE_BREAK.matcher(text).find()
                && (pos == token.length() || !isInsideIndent(token, pos));
        return result;
    } catch (IndexOutOfBoundsException e) {
        throw (IndexOutOfBoundsException) new IndexOutOfBoundsException("pos: " + pos + ", token.length: " + token.length() + ", token text: " + token.text()).initCause(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JavadocCompletionUtils.java

示例3: skipWhitespacesBackwards

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
private int skipWhitespacesBackwards(final JavadocContext jdctx, final int offset) {
    jdctx.jdts.move(offset);
    
    while (jdctx.jdts.movePrevious()) {
        Token t = jdctx.jdts.token();
        
        if (t.id() != JavadocTokenId.OTHER_TEXT) return jdctx.jdts.offset();
        
        CharSequence text = t.text();
        
        for (int i = 0; i < text.length(); i++) {
            if (!Character.isWhitespace(text.charAt(i))) {
                //XXX: does not handle the leading '*' correctly
                 return jdctx.jdts.offset();
            }
        }
    }
    
    return jdctx.jdts.moveNext() ? jdctx.jdts.offset() : offset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavadocCompletionQuery.java

示例4: getInstantRenamerVisitor

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
@Override
public <T extends Set<OffsetRange>> NodeVisitor<T> getInstantRenamerVisitor(EditorFeatureContext context, T result) {
    TokenSequence<CssTokenId> tokenSequence = context.getTokenSequence();
    int diff = tokenSequence.move(context.getCaretOffset());
    if (diff > 0 && tokenSequence.moveNext() || diff == 0 && tokenSequence.movePrevious()) {
        Token<CssTokenId> token = tokenSequence.token();
        final CharSequence elementName = token.text();
        return new NodeVisitor<T>(result) {
            @Override
            public boolean visit(Node node) {
                switch (node.type()) {
                    case cp_mixin_name:
                    case cp_variable:
                        if (LexerUtils.equals(elementName, node.image(), false, false)) {
                        OffsetRange range = new OffsetRange(node.from(), node.to());
                        getResult().add(range);
                        break;
                    }
                }
                return false;
            }
        };

    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:CPCssEditorModule.java

示例5: isTag

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
private static boolean isTag(Token<? extends TokenId> tag) {
    CharSequence s = tag.text();
    int l = s.length();
    
    boolean b = tag.id() == JavadocTokenId.HTML_TAG &&
        l >= 3 &&
        s.charAt(0) == '<' && //NOI18N
        s.charAt(l - 1) == '>'; //NOI18N
    
    if (b) {
        if (s.charAt(1) == '/') { //NOI18N
            b = l >= 4 && Character.isLetterOrDigit(s.charAt(2));
        } else {
            b = Character.isLetterOrDigit(s.charAt(1));
        }
    }
    
    return b;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JavadocBracesMatcher.java

示例6: getFirstChildLocked

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
private Node getFirstChildLocked(TokenSequence ts) {
    while (ts.moveNext()) {
        Token<XMLTokenId> t = ts.token();
        if (t.id() == XMLTokenId.VALUE) {
            // fuzziness to relax minor tokenization changes
            CharSequence image = t.text();
            if (image.length() == 1) {
                char test = image.charAt(0);
                if (test == '"' || test == '\'') {
                    if (ts.moveNext()) {
                        t = ts.token();
                    } else {
                        return null;
                    }
                }
            }
            
            if (t.id() == XMLTokenId.VALUE) {
                return new TextImpl(syntax, t, ts.offset(), ts.offset() + t.length(), this);
            } else {
                return null;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AttrImpl.java

示例7: numberOfNL

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
private int numberOfNL(Token<JavaTokenId> t) {
    int count = 0;
    CharSequence charSequence = t.text();
    for (int i = 0; i < charSequence.length(); i++) {
        char a = charSequence.charAt(i);
        if ('\n' == a) {
            count++;
        }
    }
    return count;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:PositionEstimator.java

示例8: numberOfNL

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
private int numberOfNL(Token<JavaTokenId> t, int offset) {
    int count = 0;
    CharSequence charSequence = t.text();
    for (int i = 0; i < charSequence.length(); i++) {
        char a = charSequence.charAt(i);
        if ('\n' == a) {
            lastWhiteNewline = offset + i;
            count++;
        }
    }
    if (offset == -1) {
        lastWhiteNewline = -1;
    }
    return count;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:AssignComments.java

示例9: isInsideIndent

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
static boolean isInsideIndent(Token<JavadocTokenId> token, int offset) {
    int indent = -1;
    if (token.id() == JavadocTokenId.OTHER_TEXT) {
        CharSequence text = token.text();
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            if (c == '\n') {
                if (i <= offset) {
                    // new line; reset status
                    indent = -1;
                    if (i < offset) {
                        continue;
                    }
                }
                // stop, line inspection is ready
                break;
            } else if (i == 0) {
                // token must start with \n otherwise it is not indentation
                break;
            }

            if (c == '*' && indent < 0) {
                indent = i;
                if (offset <= i) {
                    // stop, offset is inside indentation
                    break;
                }
            }
        }
    }
    return indent >= offset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:JavadocCompletionUtils.java

示例10: isWhiteSpace

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
public static boolean isWhiteSpace(Token<JavadocTokenId> token) {
    if (token == null || token.id() != JavadocTokenId.OTHER_TEXT) {
        return false;
    }

    CharSequence text = token.text();
    boolean result = !JAVADOC_WHITE_SPACE.matcher(text).find();
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:JavadocCompletionUtils.java

示例11: isFirstWhiteSpaceAtFirstLine

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
/**
 * enhanced {@link #isWhiteSpace(org.netbeans.api.lexer.Token) isWhiteSpace}
 * @param token "\t" or "\t**\t"
 * @return same value as isWhiteSpace
 * @see <a href="http://www.netbeans.org/issues/show_bug.cgi?id=131826">#131826</a>
 */
public static boolean isFirstWhiteSpaceAtFirstLine(Token<JavadocTokenId> token) {
    if (token == null || token.id() != JavadocTokenId.OTHER_TEXT) {
        return false;
    }

    CharSequence text = token.text();
    boolean result = JAVADOC_FIRST_WHITE_SPACE.matcher(text).matches();
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:JavadocCompletionUtils.java

示例12: isWhiteSpaceFirst

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
public static boolean isWhiteSpaceFirst(Token<JavadocTokenId> token) {
    if (token == null || token.id() != JavadocTokenId.OTHER_TEXT || token.length() < 1) {
        return false;
    }

    CharSequence text = token.text();
    char c = text.charAt(0);
    return c == ' ' || c == '\t';
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:JavadocCompletionUtils.java

示例13: isWhiteSpaceLast

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
public static boolean isWhiteSpaceLast(Token<JavadocTokenId> token) {
    if (token == null || token.id() != JavadocTokenId.OTHER_TEXT || token.length() < 1) {
        return false;
    }

    CharSequence text = token.text();
    char c = text.charAt(text.length() - 1);
    return c == ' ' || c == '\t';
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:JavadocCompletionUtils.java

示例14: isInlineTagStart

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
public static boolean isInlineTagStart(Token<JavadocTokenId> token) {
    if (token == null || token.id() != JavadocTokenId.OTHER_TEXT) {
        return false;
    }

    CharSequence text = token.text();
    boolean result = text.charAt(text.length() - 1) == '{';
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:JavadocCompletionUtils.java

示例15: isEmptyJavadoc

import org.netbeans.api.lexer.Token; //导入方法依赖的package包/类
/**
 * Checks special case of empty javadoc <code>/**|&#42;/</code>. 
 * @param token javadoc token
 * @param offset offset <B>INSIDE</B> jvadoc token
 * @return <code>true</code> in case of empty javadoc and the proper position
 */
private static boolean isEmptyJavadoc(Token<JavaTokenId> token, int offset) {
    if (token != null && token.id() == JavaTokenId.JAVADOC_COMMENT) {
        CharSequence text = token.text();
        // check special case /**|*/
        return offset == 3 && "/***/".contentEquals(text); //NOI18N
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JavadocCompletionUtils.java


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