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


Java TokenSequence.embeddedJoined方法代码示例

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


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

示例1: getTokenSequence

import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
/**
 * Gets instance of {@link TokenSequence} for the given
 * {@link TokenHierarchy} and offset.
 *
 * @since 1.55
 * @param th
 * @param offset
 * @param language
 * @param joined
 * @return
 */
public static TokenSequence getTokenSequence(TokenHierarchy th, int offset, Language language, boolean joined) {
    TokenSequence ts = th.tokenSequence();
    if (ts == null) {
        return null;
    }
    ts.move(offset);

    while (ts.moveNext() || ts.movePrevious()) {
        if (ts.language() == language) {
            return ts;
        }

        ts = ts.embeddedJoined();

        if (ts == null) {
            break;
        }

        //position the embedded ts so we can search deeper
        ts.move(offset);
    }

    return null;

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:LexerUtils.java

示例2: getJoinedHtmlSequence

import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
/** returns top most joined html token seuence for the document at the specified offset. */
public static TokenSequence<HTMLTokenId> getJoinedHtmlSequence(TokenHierarchy th, int offset) {
    TokenSequence ts = th.tokenSequence();
    if(ts == null) {
        return null;
    }
    ts.move(offset);

    while(ts.moveNext() || ts.movePrevious()) {
        if(ts.language() == HTMLTokenId.language()) {
            return ts;
        }
        
        ts = ts.embeddedJoined();
        
        if(ts == null) {
            break;
        }

        //position the embedded ts so we can search deeper
        //XXX this seems to be wrong, the return code should be checked
        ts.move(offset);
    }

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

示例3: testTSMove

import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testTSMove() throws Exception {
    ModificationTextDocument doc = initDocument();
    TokenHierarchy<?> hi = TokenHierarchy.get(doc);
    ((AbstractDocument)doc).readLock();
    try {
        TokenSequence<?> ts = hi.tokenSequence();
        assertEquals(1, ts.move(8));
        ts.moveStart();
        assertTrue(ts.moveNext());

        // Test TS.move() on embeddedJoin()
        TokenSequence<?> tsej = ts.embeddedJoined();
        assertEquals(-3, tsej.move(-3)); // Token starts at offset == 1
        assertEquals(0, tsej.index());

        assertEquals(7, tsej.move(8)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(6, tsej.move(7)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(5, tsej.move(6)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(2, tsej.move(3)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(1, tsej.move(2)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(1, tsej.move(2)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(1, tsej.move(2)); // Token starts at offset == 1
        assertEquals(1, tsej.index());

        assertEquals(1, tsej.move(16)); // Token starts at offset == 15
        assertEquals(3, tsej.index());

        assertEquals(0, tsej.move(15)); // Token starts at offset == 15
        assertEquals(3, tsej.index());

        assertEquals(0, tsej.move(17)); // Token starts at offset == 15
        assertEquals(4, tsej.index());
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:JoinSectionsPositioningTest.java


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