本文整理汇总了Java中org.netbeans.api.lexer.Language.find方法的典型用法代码示例。如果您正苦于以下问题:Java Language.find方法的具体用法?Java Language.find怎么用?Java Language.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.lexer.Language
的用法示例。
在下文中一共展示了Language.find方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reindent
import org.netbeans.api.lexer.Language; //导入方法依赖的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);
}
示例2: findLanguageEmbedding
import org.netbeans.api.lexer.Language; //导入方法依赖的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;
}
示例3: testTokenIdsChange
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
public void testTokenIdsChange() {
Language<?> lang = Language.find(TestChangingTokenId.MIME_TYPE);
assertNotNull(lang);
Set<?> ids = lang.tokenIds();
assertEquals(1, ids.size());
assertTrue(ids.contains(TestChangingTokenId.TEXT));
Set<String> cats = lang.tokenCategories();
assertTrue(cats.isEmpty());
// Refresh
TestChangingTokenId.change(); // Calls lang.refresh()
SimpleLanguageProvider.fireLanguageChange();
lang = Language.find(TestChangingTokenId.MIME_TYPE);
assertNotNull(lang);
Set<?> changedIds = lang.tokenIds();
assertEquals(2, changedIds.size());
assertTrue(changedIds.contains(TestChangingTokenId.TEXT));
assertTrue(changedIds.contains(TestChangingTokenId.A));
Set<String> changedCats = lang.tokenCategories();
assertTrue(changedCats.contains("test"));
}
示例4: initialize
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
@NbBundle.Messages({
"ITEM_AllLanguages=All Languages"
})
private void initialize() {
Collection<String> mimeTypes = ctrl.getUpdatedLanguages();
List<String[]> langMimes = new ArrayList<String[]>(mimeTypes.size());
langMimes.add(new String[] { "", ITEM_AllLanguages() }); // NOI18N
for (String s : mimeTypes) {
Language l = Language.find(s);
if (l == null) {
continue;
}
// filter out languages, whose author didn't name it - probably
// unimportant && should not be displayed.
String name = EditorSettings.getDefault().getLanguageName(s);
if (name.equals(s)) {
continue;
}
// last, discard everything that does not have any FoldTypes:
if (FoldUtilities.getFoldTypes(s).values().isEmpty()) {
continue;
}
langMimes.add(new String[] {
s, EditorSettings.getDefault().getLanguageName(s)
});
}
Collections.sort(langMimes, LANG_COMPARATOR);
languageMimeTypes = langMimes;
int idx = langSelect.getSelectedIndex();
langSelect.setModel(new DefaultComboBoxModel(languageMimeTypes.toArray(new Object[languageMimeTypes.size()])));
langSelect.setSelectedIndex(idx >= 0 && idx < langSelect.getItemCount() ? idx : 0);
}
示例5: create
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
@Override
public Collection<SchedulerTask> create(final Snapshot snapshot) {
if (Language.find(JAVASCRIPT_MIME) == null) {
return Collections.emptyList();
}
return Collections.<SchedulerTask>singleton(new ScriptEmbeddingProvider());
}
示例6: assertSameOutput
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
/**
* Compares the result with the golden string but ignores *all* whitespaces. In order to keep the nice IDE tools
* to work, if a inconsistency is found, the prefix of the golden file will be forged from the actual result, so the
* first reported inconsistency will occur at the right place.
* The lax comparison can be switched off by -Dorg.netbeans.test.hints.strictOutputCompare=true
* @param result
* @param golden
*/
private void assertSameOutput(String result, String golden) throws Exception {
Language lng = Language.find("text/x-java");
if (lng == null || Boolean.getBoolean("org.netbeans.test.hints.strictOutputCompare")) {
assertEquals("The output code does not match the expected code.", reduceWhitespaces(golden),
reduceWhitespaces(result));
return;
}
TokenHierarchy h1 = TokenHierarchy.create(result, lng);
TokenHierarchy h2 = TokenHierarchy.create(golden, lng);
TokenSequence s1 = h1.tokenSequence();
TokenSequence s2 = h2.tokenSequence();
while (s2.moveNext()) {
Token gt = s2.token();
boolean wh = gt.id() == JavaTokenId.WHITESPACE;
if (s1.moveNext()) {
Token rt;
do {
rt = s1.token();
if (!wh) {
if (!rt.text().toString().equals(gt.text().toString())) {
failNotSame(result, golden, s1.offset());
}
} else if (!isWH(rt)) {
s1.movePrevious();
break;
}
} while (isWH(rt) && s1.moveNext());
} else if (!wh) {
failNotSame(result, golden, s2.offset());
}
}
s1.movePrevious();
s2.movePrevious();
if (s1.moveNext() != s2.moveNext()) {
failNotSame(result, golden, s2.offset());
}
}
示例7: getTokenHierarchy
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
/**
* Get the <code>TokenHierarchy</code> lexed from this snapshot.
*
* @return <code>TokenHierarchy</code> created by a <code>Lexer</code> registered
* for this <code>Snapshot</code>'s mime type or <code>null</code> if there is
* no such <code>Lexer</code>.
* @since 1.1
*/
public TokenHierarchy<?> getTokenHierarchy() {
if (tokenHierarchy == null) {
Language<? extends TokenId> lang = Language.find(getMimeType());
if (lang != null) {
//copy the InputAttributes from the source document to the
//charsequence token hierarchy
Document sourceDocument = source.getDocument(false);
InputAttributes inputAttrs = sourceDocument != null ? (InputAttributes)sourceDocument.getProperty(InputAttributes.class) : null;
tokenHierarchy = TokenHierarchy.create(text, false, lang, null, inputAttrs);
}
}
return tokenHierarchy;
}
示例8: JsEmbeddingProvider
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
public JsEmbeddingProvider() {
JS_LANGUAGE = Language.find(JS_MIMETYPE); //NOI18N
PLUGINS = JsEPPluginQuery.getDefault();
}