本文整理汇总了Java中org.netbeans.api.lexer.LanguagePath类的典型用法代码示例。如果您正苦于以下问题:Java LanguagePath类的具体用法?Java LanguagePath怎么用?Java LanguagePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguagePath类属于org.netbeans.api.lexer包,在下文中一共展示了LanguagePath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: TSInfo
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
/**
* @param ts
*/
public TSInfo(TokenSequence<T> ts) {
this.ts = ts;
LanguagePath languagePath = ts.languagePath();
@SuppressWarnings("unchecked")
Language<T> innerLanguage = (Language<T>)languagePath.innerLanguage();
String mimePathExt;
if (mimeTypeForOptions != null) {
// First mime-type in mimePath starts with "test"
mimePathExt = languagePathToMimePathOptions(languagePath);
} else {
mimePathExt = languagePath.mimePath();
}
fcsInfo = findFCSInfo(mimePathExt, innerLanguage);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SyntaxHighlighting.java
示例2: findLanguageEmbedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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
示例3: getPreprocessorImport
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
private static Language<STokenId> getPreprocessorImport (LanguagePath languagePath, Token token) {
String tokenType = token.id ().name ();
if (!tokenType.equals (SLexer.EMBEDDING_TOKEN_TYPE_NAME)) return null;
String mimeType = languagePath.topLanguage ().mimeType ();
if (!preprocessorImport.containsKey (mimeType)) {
try {
org.netbeans.modules.languages.Language language =
LanguagesManager.getDefault ().getLanguage (mimeType);
Feature properties = language.getPreprocessorImport ();
if (properties != null) {
String innerMT = (String) properties.getValue ("mimeType");
preprocessorImport.put (
mimeType,
(Language<STokenId>)Language.find (innerMT)
);
}
} catch (ParseException ex) {
}
}
return preprocessorImport.get (mimeType);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SLanguageProvider.java
示例4: HtmlLexer
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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: getActiveEmbeddedPaths
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
/**
* Collect language paths used within the given token sequence
*
* @param ts non-null token sequence (or subsequence). <code>ts.moveNext()</code>
* is called first on it.
* @return collection of language paths present in the given token sequence.
*/
private Collection<LanguagePath> getActiveEmbeddedPaths(TokenSequence ts) {
Collection<LanguagePath> lps = new HashSet<LanguagePath>();
lps.add(ts.languagePath());
List<TokenSequence<?>> tsStack = null;
while (true) {
while (ts.moveNext()) {
TokenSequence<?> eTS = ts.embedded();
if (eTS != null) {
tsStack.add(ts);
ts = eTS;
lps.add(ts.languagePath());
}
}
if (tsStack != null && tsStack.size() > 0) {
ts = tsStack.get(tsStack.size() - 1);
tsStack.remove(tsStack.size() - 1);
} else {
break;
}
}
return lps;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:TaskHandler.java
示例6: reindent
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
public void reindent() throws BadLocationException {
if(context == null)
return;
MimePath mimePath = MimePath.parse (context.mimePath ());
if(mimePath == null)
return;
Language language = Language.find (mimePath.getMimeType (0));
if(language == null)
return;
LanguagePath languagePath = LanguagePath.get (language);
if(languagePath == null)
return;
for (int i = 1; i < mimePath.size(); i++) {
languagePath = languagePath.embedded(Language.find(mimePath.getMimeType(i)));
}
XMLLexerFormatter formatter = new XMLLexerFormatter(languagePath);
formatter.reformat(context);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:XMLIndentTask.java
示例7: findLanguageEmbedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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
示例8: languagePaths
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
/**
* Get static language paths for this language.
*/
public Set<LanguagePath> languagePaths() {
Set<LanguagePath> lps;
synchronized (this) {
lps = languagePaths;
}
if (lps == null) {
lps = new HashSet<LanguagePath>();
Set<LanguagePath> existingLps = Collections.emptySet();
Set<Language<?>> exploredLangs = new HashSet<Language<?>>();
findLanguagePaths(existingLps, lps, exploredLangs, LanguagePath.get(language));
synchronized (this) {
languagePaths = lps;
exploredLanguages = exploredLangs;
}
}
return lps;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:LanguageOperation.java
示例9: languagePaths
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
public Set<LanguagePath> languagePaths() {
ensureReadLocked();
Set<LanguagePath> lps;
synchronized (rootTokenList) {
lps = languagePaths;
if (lps == null) {
if (!isActiveImpl())
return Collections.emptySet();
Language<?> lang = rootTokenList.language();
LanguageOperation<?> langOp = LexerApiPackageAccessor.get().languageOperation(lang);
@SuppressWarnings("unchecked")
Set<LanguagePath> clps = (Set<LanguagePath>)
((HashSet<LanguagePath>)langOp.languagePaths()).clone();
lps = clps;
@SuppressWarnings("unchecked")
Set<Language<?>> cel = (Set<Language<?>>)
((HashSet<Language<?>>)langOp.exploredLanguages()).clone();
exploredLanguages = cel;
languagePaths = lps;
}
}
return lps;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TokenHierarchyOperation.java
示例10: findLanguageEmbedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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
示例11: findEmbedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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
示例12: updateCreateOrRemoveEmbedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
public <T extends TokenId> void updateCreateOrRemoveEmbedding(EmbeddedTokenList<?,T> addedOrRemovedTokenList, boolean add) {
LanguagePath languagePath = addedOrRemovedTokenList.languagePath();
int level = languagePath.size() - 1;
itemLevels = new ArrayList<List<UpdateItem<?>>>(level + 2); // One extra level for growth
UpdateItem<T> item = tokenListListItem(languagePath);
if (item != null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("THU.updateCreateOrRemoveEmbedding() add=" + add + ": " +
addedOrRemovedTokenList.dumpInfo(new StringBuilder(256)));
}
if (add) {
item.tokenListListUpdate.markAddedMember(addedOrRemovedTokenList);
} else {
item.tokenListListUpdate.markRemovedMember(addedOrRemovedTokenList, eventInfo);
}
processLevelInfos();
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TokenHierarchyUpdate.java
示例13: embedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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
示例14: testBatchLexerRelease
import org.netbeans.api.lexer.LanguagePath; //导入依赖的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
示例15: languagePathToMimePathOptions
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
private String languagePathToMimePathOptions(LanguagePath languagePath) {
if (languagePath.size() == 1) {
return mimeTypeForOptions;
} else if (languagePath.size() > 1) {
return mimeTypeForOptions + "/" + languagePath.subPath(1).mimePath(); //NOI18N
} else {
throw new IllegalStateException("LanguagePath should not be empty."); //NOI18N
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:SyntaxHighlighting.java
示例16: addItem
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
private boolean addItem(MimePath mimePath, LanguagePath languagePath) {
MimeItem item = new MimeItem(this, mimePath, languagePath);
if (item.createTask(existingFactories)) {
if (items == null) {
items = new ArrayList<MimeItem>();
}
items.add(item);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Adding MimeItem: " + item); //NOI18N
}
return true;
} else {
return false;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:TaskHandler.java
示例17: tearDown
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
protected @Override void tearDown() throws Exception {
MockMimeLookup.setLookup(MimePath.parse(TestLineTokenId.MIME_TYPE));
MockMimeLookup.setLookup(
MimePath.parse(LanguagePath.get(TestLineTokenId.language()).embedded(TestPlainTokenId.language()).mimePath())
);
super.tearDown();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:EmbeddedIndentTest.java
示例18: findLanguageEmbedding
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
@Override
public LanguageEmbedding<?> findLanguageEmbedding (
Token arg0,
LanguagePath arg1,
InputAttributes arg2
) {
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DiffLanguageProvider.java
示例19: findTokenList
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
public TokenList findTokenList(Document doc) {
if (!(doc instanceof BaseDocument)) {
Logger.getLogger(HtmlXmlTokenListProvider.class.getName()).log(Level.INFO, null,
new IllegalStateException("The given document is not an instance of the BaseDocument, is just " + //NOI18N
doc.getClass().getName()));
return null;
}
//html
final BaseDocument bdoc = (BaseDocument) doc;
final String docMimetype = NbEditorUtilities.getMimeType(doc);
final AtomicReference<TokenList> ret = new AtomicReference<TokenList>();
doc.render(new Runnable() {
public void run() {
TokenHierarchy<?> th = TokenHierarchy.get(bdoc);
Set<LanguagePath> paths = th.languagePaths();
for(LanguagePath path : paths) {
if(path.innerLanguage() == HTMLTokenId.language()) {
String settingName = MIME_TO_SETTING_NAME.get(docMimetype);
ret.set(new HtmlTokenList(bdoc, settingName));
break;
}
}
}
});
if(ret.get() != null) {
return ret.get();
}
//xml
if ((docMimetype != null) && (docMimetype.contains("xml"))) { //NOI18N
return new XmlTokenList(bdoc);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:HtmlXmlTokenListProvider.java
示例20: LexerRestartInfo
import org.netbeans.api.lexer.LanguagePath; //导入依赖的package包/类
LexerRestartInfo(LexerInput input,
TokenFactory<T> tokenFactory, Object state,
LanguagePath languagePath, InputAttributes inputAttributes) {
this.input = input;
this.tokenFactory = tokenFactory;
this.state = state;
this.languagePath = languagePath;
this.inputAttributes = inputAttributes;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:LexerRestartInfo.java
注:本文中的org.netbeans.api.lexer.LanguagePath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论