本文整理汇总了Java中org.netbeans.api.lexer.TokenSequence.moveStart方法的典型用法代码示例。如果您正苦于以下问题:Java TokenSequence.moveStart方法的具体用法?Java TokenSequence.moveStart怎么用?Java TokenSequence.moveStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.lexer.TokenSequence
的用法示例。
在下文中一共展示了TokenSequence.moveStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGCedE
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testGCedE() {
TokenHierarchy th = TokenHierarchy.create("abc", TestPlainTokenId.language());
TokenSequence tokens = th.tokenSequence();
tokens.moveStart();
assertEquals(true, tokens.moveNext());
TokenSequence embedded = tokens.embedded();
assertNotNull("There should be an embedded language", embedded);
WeakReference<Language> refLang = new WeakReference<Language>(embedded.language());
embedded = null;
WeakReference<Token> refToken = new WeakReference<Token>(tokens.token());
tokens = null;
th = null;
// This no longer works after the language is statically held in the xxTokenId by the new convention
//assertGC("The embedded language has not been GCed", refLang);
assertGC("The token with embedded language has not been GCed", refToken);
}
示例2: dumpSequence
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
private static void dumpSequence(TokenSequence<?> seq, StringBuilder sb) {
if (seq == null) {
sb.append("Inactive TokenHierarchy"); //NOI18N
} else {
for(seq.moveStart(); seq.moveNext(); ) {
TokenSequence<?> emSeq = seq.embedded();
if (emSeq != null) {
dumpSequence(emSeq, sb);
} else {
Token<?> token = seq.token();
sb.append("<"); //NOI18N
sb.append(String.format("%3s", seq.offset())).append(", "); //NOI18N
sb.append(String.format("%3s", seq.offset() + token.length())).append(", "); //NOI18N
sb.append(String.format("%+3d", token.length())).append("> : "); //NOI18N
sb.append(tokenId(token.id(), true)).append(" : '"); //NOI18N
sb.append(tokenText(token));
sb.append("'\n"); //NOI18N
}
}
}
}
示例3: testCacheRefreshedE
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testCacheRefreshedE() {
TokenHierarchy th = TokenHierarchy.create("abc", TestPlainTokenId.language());
TokenSequence tokens = th.tokenSequence();
tokens.moveStart();
assertEquals(true, tokens.moveNext());
TokenSequence embeddedA = tokens.embedded();
assertNotNull("There should be an embedded language", embeddedA);
SimpleLanguageProvider.fireTokenLanguageChange();
TokenSequence embeddedB = tokens.embedded();
assertNotNull("There should be an embedded language", embeddedB);
assertNotSame("The token language cache has not been refreshed", embeddedA, embeddedB);
}
示例4: getMarkList
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
private List<FoldMarkInfo> getMarkList(TokenSequence seq) {
List<FoldMarkInfo> markList = null;
for(seq.moveStart(); seq.moveNext(); ) {
Token token = seq.token();
FoldMarkInfo info;
try {
info = scanToken(token);
} catch (BadLocationException e) {
LOG.log(Level.WARNING, null, e);
info = null;
}
if (info != null) {
if (markList == null) {
markList = new ArrayList<FoldMarkInfo>();
}
markList.add(info);
}
}
return markList;
}
示例5: test146930
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void test146930() {
TokenHierarchy th = TokenHierarchy.create("<<body>", HTMLTokenId.language());
TokenSequence ts = th.tokenSequence();
ts.moveStart();
assertTrue(ts.moveNext());
assertEquals("<", ts.token().text().toString());
assertEquals(HTMLTokenId.TEXT, ts.token().id());
assertTrue(ts.moveNext());
assertEquals("<", ts.token().text().toString());
assertEquals(HTMLTokenId.TAG_OPEN_SYMBOL, ts.token().id());
assertTrue(ts.moveNext());
assertEquals("body", ts.token().text().toString());
assertEquals(HTMLTokenId.TAG_OPEN, ts.token().id());
assertTrue(ts.moveNext());
assertEquals(">", ts.token().text().toString());
assertEquals(HTMLTokenId.TAG_CLOSE_SYMBOL, ts.token().id());
assertFalse(ts.moveNext());
}
示例6: testIssue218629
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testIssue218629() {
String text = "<div>שלום עולם</div>";
// 01234567890123456789
TokenHierarchy<String> th = TokenHierarchy.create(text, HTMLTokenId.language());
TokenSequence<HTMLTokenId> ts = th.tokenSequence(HTMLTokenId.language());
StringBuilder b = new StringBuilder();
ts.moveStart();
while(ts.moveNext()) {
Token<HTMLTokenId> t = ts.token();
b.append('"');
b.append(t.text());
b.append('"');
b.append("\t\t");
b.append(t.id().name());
b.append("\t\t");
b.append(ts.offset());
b.append('-');
b.append(ts.offset() + t.length());
b.append('\n');
}
// System.out.println(b);
}
示例7: testScriptType_value
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testScriptType_value() {
TokenHierarchy th = TokenHierarchy.create("<script type=\"text/plain\">plain</script>", HTMLTokenId.language());
TokenSequence ts = th.tokenSequence();
ts.moveStart();
while(ts.moveNext()) {
Token t = ts.token();
if(t.id() == HTMLTokenId.SCRIPT) {
String scriptType = (String)t.getProperty(HTMLTokenId.SCRIPT_TYPE_TOKEN_PROPERTY);
assertNotNull(scriptType);
assertEquals("text/plain", scriptType);
return ;
}
}
assertTrue("Couldn't find any SCRIPT token!", false);
}
示例8: dumpTokens
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
private static CharSequence dumpTokens(TokenSequence<?> seq) {
seq.moveStart();
StringBuilder builder = new StringBuilder();
Token<?> token = null;
while (seq.moveNext()) {
if (token != null) {
builder.append('\n');
}
token = seq.token();
builder.append(token.id());
PartType part = token.partType();
if (part != PartType.COMPLETE) {
builder.append(' ');
builder.append(token.partType());
}
builder.append(' ');
builder.append('\'');
builder.append(token.text());
builder.append('\'');
}
return builder;
}
示例9: incCheckNested
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public static void incCheckNested(String message, Document doc,
TokenSequence<?> batch, TokenHierarchy<?> batchTH,
TokenSequence<?> inc, TokenHierarchy<?> incTH
) {
int i = 0;
while (inc.moveNext()) {
TestCase.assertTrue("No more tokens in batch token sequence", batch.moveNext());
TokenSequence<?> batchE = batch.embedded();
TokenSequence<?> incE = inc.embedded();
String messageE = message + "->[" + i + "]";
if (incE != null) {
TestCase.assertNotNull("Batch embedded sequence is null", batchE);
assertTokenSequencesEqual(messageE, batchE, batchTH, incE, incTH, true, true);
incE.moveStart();
batchE.moveStart();
incCheckNested(messageE, doc, batchE, batchTH, incE, incTH);
} else { // Inc embedded is null
TestCase.assertNull("Batch embedded sequence non-null", batchE);
}
i++;
}
}
示例10: analyze
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public static InsertStatement analyze (TokenSequence<SQLTokenId> seq, Quoter quoter) {
seq.moveStart();
if (!seq.moveNext()) {
return null;
}
InsertStatementAnalyzer sa = new InsertStatementAnalyzer(seq, quoter);
sa.parse();
TableIdent ti = new TableIdent(sa.table, null);
TablesClause tablesClause = sa.context.isAfter(Context.FROM) ? sa.createTablesClause(Collections.singletonList(ti)) : null;
return new InsertStatement(
sa.startOffset, seq.offset() + seq.token().length(),
sa.getTable(),
Collections.unmodifiableList(sa.columns),
Collections.unmodifiableList(sa.values),
sa.offset2Context,
tablesClause,
Collections.unmodifiableList(sa.subqueries)
);
}
示例11: testLexingOfMissingTokens
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testLexingOfMissingTokens() throws Exception {
String code = "a {\n"
+ " @ color: red; \n"
+ " background: red; \n"
+ "}";
TokenHierarchy th = TokenHierarchy.create(code, CssTokenId.language());
TokenSequence ts = th.tokenSequence();
ts.moveStart();
while (ts.moveNext()) {
// System.out.println(ts.offset() + "-" + (ts.token().length() + ts.offset()) + ": " + ts.token().text() + "(" + ts.token().id() + ")");
}
}
示例12: calculateCodeBlock
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
private static <T1 extends TokenId> List<JoinedTokenSequence.CodeBlock<T1>> calculateCodeBlock(List<TokenSequence<T1>> tss,
VirtualSource virtualSource
) throws BadLocationException {
List<JoinedTokenSequence.CodeBlock<T1>> blocks = new ArrayList<JoinedTokenSequence.CodeBlock<T1>>();
for (int i=0; i<tss.size(); i++) {
TokenSequence<T1> ts =tss.get(i);
List<TokenSequenceWrapper<T1>> tss2 = new ArrayList<TokenSequenceWrapper<T1>>();
tss2.add(new TokenSequenceWrapper<T1>(ts, false));
// try to find additional token sequences which comprise this language block:
for (int j=i+1; j<tss.size(); j++) {
TokenSequence<T1> prev = tss.get(j-1);
prev.moveEnd();
prev.movePrevious();
TokenSequence<T1> next = tss.get(j);
next.moveStart();
next.moveNext();
// check whether current token sequence is continuation of previous one:
TokenSequence<T1> tsVirtual = LexUtilities.getVirtualTokens(virtualSource, prev.offset()+prev.token().length(), next.offset(), ts.language());
if (tsVirtual != null) {
tss2.add(new TokenSequenceWrapper<T1>(tsVirtual, true));
tss2.add(new TokenSequenceWrapper<T1>(next, false));
i++;
} else {
break;
}
}
blocks.add(new JoinedTokenSequence.CodeBlock<T1>(tss2));
}
return blocks;
}
示例13: isInvalidDocInstance
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
/**
* Checks whether Doc instance matches to its token sequence representation.
* @param javadoc Doc instance of javadoc
* @param ts javadoc token sequence
* @return true if it is valid javadoc
*
* @see <a href="http://www.netbeans.org/issues/show_bug.cgi?id=139147">139147</a>
*/
public static boolean isInvalidDocInstance(DocCommentTree javadoc, TokenSequence<JavadocTokenId> ts) {
if (javadoc == null || javadoc.getFullBody().isEmpty()) {
if (!ts.isEmpty()) {
ts.moveStart();
return !(ts.moveNext() && isTokenOfEmptyJavadoc(ts.token()) && ts.moveNext() == false);
}
}
return false;
}
示例14: doIsTokenOfEmptyJavadoc
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
private void doIsTokenOfEmptyJavadoc(int fieldIndex, boolean isEmpty) {
Element fieldEl = info.getTopLevelElements().get(0).getEnclosedElements().get(fieldIndex);
assertNotNull(fieldEl);
TokenSequence<JavadocTokenId> jdts = JavadocCompletionUtils.findJavadocTokenSequence(info, null, fieldEl);
assertNotNull(jdts);
jdts.moveStart();
if (jdts.moveNext()) {
assertEquals(fieldEl.getSimpleName().toString(), isEmpty, JavadocCompletionUtils.isTokenOfEmptyJavadoc(jdts.token()));
}
}
示例15: testCounterStyle
import org.netbeans.api.lexer.TokenSequence; //导入方法依赖的package包/类
public void testCounterStyle() throws Exception {
String source = "@counter-style x { }";
TokenHierarchy th = TokenHierarchy.create(source, CssTokenId.language());
TokenSequence ts = th.tokenSequence();
ts.moveStart();
assertToken("@counter-style", CssTokenId.COUNTER_STYLE_SYM, ts);
assertToken(" ", CssTokenId.WS, ts);
}