本文整理汇总了Java中org.netbeans.api.lexer.InputAttributes类的典型用法代码示例。如果您正苦于以下问题:Java InputAttributes类的具体用法?Java InputAttributes怎么用?Java InputAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputAttributes类属于org.netbeans.api.lexer包,在下文中一共展示了InputAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findLanguageEmbedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public LanguageEmbedding<?> findLanguageEmbedding (
Token token,
LanguagePath languagePath,
InputAttributes inputAttributes
) {
String mimeType = languagePath.innerLanguage ().mimeType ();
if (!LanguagesManager.getDefault ().isSupported (mimeType)) return null;
Language<STokenId> language = getTokenImport (mimeType, token);
if (language == null)
language = getPreprocessorImport (languagePath, token);
if (language == null) return null;
Integer i = (Integer) token.getProperty ("startSkipLength");
int startSkipLength = i == null ? 0 : i.intValue ();
i = (Integer) token.getProperty ("endSkipLength");
int endSkipLength = i == null ? 0 : i.intValue ();
return LanguageEmbedding.create (
language,
startSkipLength,
endSkipLength
);
}
示例2: testInterferenceBraceIdent
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testInterferenceBraceIdent() {
String text = "() -> {A::a();}";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LPAREN, "(");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.RPAREN, ")");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ARROW, "->");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LBRACE, "{");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "A");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.COLONCOLON, "::");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "a");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LPAREN, "(");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.RPAREN, ")");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.SEMICOLON, ";");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.RBRACE, "}");
assertFalse(ts.moveNext());
}
示例3: testNoBinaryLiterals
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testNoBinaryLiterals() {
String text = "0b101 0B101 0b101l 0b101L";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(5), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "b101");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "B101");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "b101l");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "b101L");
}
示例4: HtmlLexer
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public HtmlLexer(LexerRestartInfo<HTMLTokenId> info) {
this.input = info.input();
this.tokenFactory = info.tokenFactory();
if (info.state() == null) {
this.lexerSubState = INIT;
this.lexerState = INIT;
this.lexerEmbeddingState = INIT;
this.customELIndex = INIT;
this.quoteType = false;
} else {
CompoundState cs = (CompoundState) info.state();
lexerState = cs.lexerState;
lexerSubState = cs.lexerSubState;
lexerEmbeddingState = cs.lexerEmbeddingState;
attribute = cs.attribute;
tag = cs.tag;
customELIndex = cs.customELIndex;
quoteType = cs.quoteType;
}
InputAttributes inputAttributes = info.inputAttributes();
if (inputAttributes != null) {
cssClassTagAttrMap = (Map<String, Collection<String>>)inputAttributes.getValue(
LanguagePath.get(HTMLTokenId.language()), CSS_CLASS_MAP_PROPERTY_KEY); //NOI18N
}
}
示例5: findLanguageEmbedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
@Override
public LanguageEmbedding<?> findLanguageEmbedding (
Token token,
LanguagePath arg1,
InputAttributes arg2
) {
if (token.id() == OQLTokenId.JSBLOCK) {
Language lang = Language.find("text/javascript");
if(lang == null) {
return null; //no language found
} else {
return LanguageEmbedding.create(lang, 0, 0, true);
}
}
return null;
}
示例6: TokenHierarchyOperation
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
/**
* Constructor for character sequence as input.
*/
public TokenHierarchyOperation(CharSequence inputText, boolean copyInputText,
Language<T> language, Set<T> skipTokenIds, InputAttributes inputAttributes) {
if (inputText == null)
throw new IllegalArgumentException("inputText cannot be null"); // NOI18N
if (language == null)
throw new IllegalArgumentException("language cannot be null");
@SuppressWarnings("unchecked")
I input = (I)inputText;
this.inputSource = input;
if (copyInputText) {
// Instead of using an original CopyTextTokenList (that allowed to skip
// individual characters of all flyweight tokens) do just a copy of the full text
// and use regular BatchTokenList.
inputText = inputText.toString();
}
this.rootTokenList = new BatchTokenList<T>(this, inputText,
language, skipTokenIds, inputAttributes);
init();
activity = Activity.ACTIVE;
}
示例7: findLanguageEmbedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public LanguageEmbedding<?> findLanguageEmbedding(
Token<?> token, LanguagePath languagePath, InputAttributes inputAttributes) {
synchronized(LOCK) {
LanguageEmbedding<?> lang = tokenLangCache.get(token);
if (lang == null) {
for(LanguageProvider p : providers) {
if (null != (lang = p.findLanguageEmbedding(token, languagePath, inputAttributes))) {
break;
}
}
if (lang == null) {
lang = NO_LANG_EMBEDDING();
}
tokenLangCache.put(token, lang);
}
return lang == NO_LANG_EMBEDDING() ? null : lang;
}
}
示例8: findEmbedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
/**
* Find the language embedding for the given parameters.
* <br/>
* First the <code>LanguageHierarchy.embedding()</code> method is queried
* and if no embedding is found then the <code>LanguageProvider.findLanguageEmbedding()</code>.
*/
public static <T extends TokenId> LanguageEmbedding<?>
findEmbedding(LanguageHierarchy<T> languageHierarchy, AbstractToken<T> token,
LanguagePath languagePath, InputAttributes inputAttributes) {
LanguageEmbedding<?> embedding =
LexerSpiPackageAccessor.get().embedding(
languageHierarchy, token, languagePath, inputAttributes);
if (embedding == null) {
// try language embeddings registered in Lookup
embedding = LanguageManager.getInstance().findLanguageEmbedding(
token, languagePath, inputAttributes);
}
return embedding;
}
示例9: embedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
@Override
public LanguageEmbedding<?> embedding(
Token<TestJoinTextTokenId> token, LanguagePath languagePath, InputAttributes inputAttributes) {
// Test language embedding in the block comment
switch (token.id()) {
// case PARENS: - explicit custom embedding
// return LanguageEmbedding.create(TestPlainTokenId.inParensLanguage, 1, 1, true);
case BRACKETS:
return LanguageEmbedding.create(TestPlainTokenId.inBracketsLanguage, 1, 1, true);
case APOSTROPHES:
return LanguageEmbedding.create(TestPlainTokenId.inApostrophesLanguage, 1, 1, false);
// case TEXT:
// return LanguageEmbedding.create(TestStringTokenId.language(), 1, 1);
}
return null; // No embedding
}
示例10: testBatchLexerRelease
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testBatchLexerRelease() throws Exception {
String text = "ab";
InputAttributes attrs = new InputAttributes();
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, StateTokenId.language(),
null, attrs);
TokenSequence<?> ts = hi.tokenSequence();
assertTrue(ts.moveNext());
LexerTestUtilities.assertTokenEquals(ts, StateTokenId.A, "a", 0);
assertTrue(ts.moveNext());
LanguagePath lp = LanguagePath.get(StateTokenId.language());
assertFalse(Boolean.TRUE.equals(attrs.getValue(lp, "lexerRelease")));
LexerTestUtilities.assertTokenEquals(ts, StateTokenId.BMULTI, "b", 1);
assertFalse(ts.moveNext());
assertTrue(Boolean.TRUE.equals(attrs.getValue(lp, "lexerRelease")));
}
示例11: getTokenHierarchy
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
@NonNull
public final TokenHierarchy<?> getTokenHierarchy() throws IOException {
if (this.tokens == null) {
final CharBuffer charBuffer = getCharContent(true);
InputAttributes attrs = new InputAttributes();
attrs.setValue(JavaTokenId.language(), "fileName", (Supplier<String>) () -> getName(), true); //NOI18N
this.tokens = TokenHierarchy.create(charBuffer, false, JavaTokenId.language(), null, attrs); //TODO: .createSnapshot();
}
return this.tokens;
}
示例12: createStyledDocument
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
@Override
protected StyledDocument createStyledDocument (EditorKit kit) {
StyledDocument doc = super.createStyledDocument(kit);
// Enter the file object in to InputAtrributes. It can be used by lexer.
InputAttributes attributes = new InputAttributes();
FileObject fileObject = NbEditorUtilities.getFileObject(doc);
final GsfLanguage lng = language.getGsfLanguage();
if (lng != null) {
attributes.setValue(lng.getLexerLanguage(), FileObject.class, fileObject, false);
}
doc.putProperty(InputAttributes.class, attributes);
return doc;
}
示例13: xtestExoticIdentifiers
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void xtestExoticIdentifiers() {//Support for exotic identifiers has been removed 6999438
String text = "a #\" \" #\"\\\"\"";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "a");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "#\" \"");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "#\"\\\"\"");
}
示例14: testNoExoticIdentifiers
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testNoExoticIdentifiers() {
String text = "a #\" \"";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(5), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "a");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ERROR, "#");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.STRING_LITERAL, "\" \"");
}
示例15: testBinaryLiterals
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testBinaryLiterals() {
String text = "0b101 0B101 0b101l 0b101L";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.of(JavaTokenId.WHITESPACE), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0b101");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0B101");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LONG_LITERAL, "0b101l");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LONG_LITERAL, "0b101L");
}