当前位置: 首页>>代码示例>>Java>>正文


Java Language.find方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:XMLIndentTask.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:OQLLanguageProvider.java

示例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"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:LanguageTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:FoldOptionsPanel.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ScriptEmbeddingProvider.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:HintTest.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:Snapshot.java

示例8: JsEmbeddingProvider

import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
public JsEmbeddingProvider() {
    JS_LANGUAGE = Language.find(JS_MIMETYPE); //NOI18N
    PLUGINS = JsEPPluginQuery.getDefault();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:JsEmbeddingProvider.java


注:本文中的org.netbeans.api.lexer.Language.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。