本文整理汇总了Java中org.netbeans.api.lexer.InputAttributes类的典型用法代码示例。如果您正苦于以下问题:Java InputAttributes类的具体用法?Java InputAttributes怎么用?Java InputAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputAttributes类属于org.netbeans.api.lexer包,在下文中一共展示了InputAttributes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SLanguageProvider.java
示例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());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavaLexerBatchTest.java
示例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");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JavaLexerBatchTest.java
示例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
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:HtmlLexer.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:OQLLanguageProvider.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TokenHierarchyOperation.java
示例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;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:LanguageManager.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:LexerUtilsConstants.java
示例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
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TestJoinTextTokenId.java
示例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")));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:InvalidLexerOperationTest.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AbstractSourceFileObject.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:GsfDataObject.java
示例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, "#\"\\\"\"");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JavaLexerBatchTest.java
示例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, "\" \"");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JavaLexerBatchTest.java
示例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");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JavaLexerBatchTest.java
示例16: testUnderscoresInLiterals
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testUnderscoresInLiterals() {
String text = "_12 1_2 12_ 0_12 01_2 0x1_2";
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, "_12");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "1_2");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "12");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "_");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0_12");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "01_2");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT_LITERAL, "0x1_2");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:JavaLexerBatchTest.java
示例17: testUnicode
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testUnicode() {
String text = "//\\u000Aint\\u0020\\u002E\\uuuuuu002E\\u000A";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.noneOf(JavaTokenId.class), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.LINE_COMMENT, "//\\u000A");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.INT, "int");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.WHITESPACE, "\\u0020");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.DOT, "\\u002E");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.DOT, "\\uuuuuu002E");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.WHITESPACE, "\\u000A");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JavaLexerBatchTest.java
示例18: testBrokenUnicode
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testBrokenUnicode() {
String text = "\\u000X\\u00";
InputAttributes attr = new InputAttributes();
attr.setValue(JavaTokenId.language(), "version", Integer.valueOf(7), true);
TokenHierarchy<?> hi = TokenHierarchy.create(text, false, JavaTokenId.language(), EnumSet.noneOf(JavaTokenId.class), attr);
TokenSequence<?> ts = hi.tokenSequence();
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ERROR, "\\");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "u000X");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.ERROR, "\\");
LexerTestUtilities.assertNextTokenEquals(ts, JavaTokenId.IDENTIFIER, "u00");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JavaLexerBatchTest.java
示例19: testGenericCssClassEmbedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
public void testGenericCssClassEmbedding() {
Map<String, Collection<String>> map = new HashMap<>();
map.put("c:button", Collections.singletonList("styleClass"));
InputAttributes inputAttributes = new InputAttributes();
inputAttributes.setValue(HTMLTokenId.language(), "cssClassTagAttrMap", map, false); //NOI18N
String text = "<c:button styleClass=\"myclass\"/>";
TokenHierarchy th = TokenHierarchy.create(text, true, HTMLTokenId.language(), Collections.<HTMLTokenId>emptySet(), inputAttributes);
TokenSequence ts = th.tokenSequence();
checkTokens(ts, "<|TAG_OPEN_SYMBOL", "c:button|TAG_OPEN", " |WS", "styleClass|ARGUMENT",
"=|OPERATOR", "\"myclass\"|VALUE_CSS", "/>|TAG_CLOSE_SYMBOL");
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HtmlLexerTest.java
示例20: findLanguageEmbedding
import org.netbeans.api.lexer.InputAttributes; //导入依赖的package包/类
@Override
public LanguageEmbedding<?> findLanguageEmbedding (
Token arg0,
LanguagePath arg1,
InputAttributes arg2
) {
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DiffLanguageProvider.java
注:本文中的org.netbeans.api.lexer.InputAttributes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论