本文整理汇总了Java中org.netbeans.api.lexer.Language类的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于org.netbeans.api.lexer包,在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ColoringMap
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
private ColoringMap(
List<String> legacyNonTokenColoringNames,
Language<?> lexerLanguage,
List<? extends TokenContext> syntaxLanguages,
Lookup.Result<FontColorSettings> lookupResult
) {
this.legacyNonTokenColoringNames = legacyNonTokenColoringNames;
this.lexerLanguage = lexerLanguage;
this.syntaxLanguages = syntaxLanguages;
this.lookupResult = lookupResult;
this.map = loadTheMap(
legacyNonTokenColoringNames,
lexerLanguage,
syntaxLanguages,
lookupResult.allInstances()
);
this.lookupResult.addLookupListener(WeakListeners.create(LookupListener.class, lookupListener, this.lookupResult));
}
示例2: testShortDoc
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
public void testShortDoc() throws Exception {
// 000000000011111111112222222222
// 012345678901234567890123456789
String text = "a<b>c";
ModificationTextDocument doc = new ModificationTextDocument();
doc.insertString(0, text, null);
doc.putProperty(Language.class, TestJoinTopTokenId.language());
TokenHierarchy<?> hi = TokenHierarchy.get(doc);
((AbstractDocument)doc).readLock();
try {
TokenSequence<?> ts = hi.tokenSequence();
assertTrue(ts.moveNext());
ts.embedded(); // Creates JTL
} finally {
((AbstractDocument)doc).readUnlock();
}
}
示例3: languagePaths
import org.netbeans.api.lexer.Language; //导入依赖的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;
}
示例4: findFCSInfo
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
private <T extends TokenId> FCSInfo<T> findFCSInfo(String mimePath, Language<T> language) {
@SuppressWarnings("unchecked")
FCSInfo<T> fcsInfo = (FCSInfo<T>) fcsCache.get(mimePath); // Search local cache
if (fcsInfo == null) { // Search in global cache
synchronized (globalFCSCache) {
@SuppressWarnings("unchecked")
FCSInfo<T> fcsI = (FCSInfo<T>) globalFCSCache.get(mimePath);
fcsInfo = fcsI;
if (fcsInfo == null) {
fcsInfo = new FCSInfo<T>(mimePath, language);
if (mimeTypeForOptions == null) { // Only cache non-test ones globally
globalFCSCache.put(mimePath, fcsInfo);
}
}
}
fcsInfo.addChangeListener(WeakListeners.change(this, fcsInfo));
fcsCache.put(mimePath, fcsInfo);
}
return fcsInfo;
}
示例5: getEmbeddedTokenSequences
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
public static List<TokenSequence<?>> getEmbeddedTokenSequences(
TokenHierarchy<?> th, int offset, boolean backwardBias, Language<?> language
) {
List<TokenSequence<?>> sequences = th.embeddedTokenSequences(offset, backwardBias);
for(int i = sequences.size() - 1; i >= 0; i--) {
TokenSequence<?> seq = sequences.get(i);
if (seq.language() == language) {
break;
} else {
sequences.remove(i);
}
}
return sequences;
}
示例6: getDocument
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
@Override
protected BaseDocument getDocument(FileObject fo, String mimeType, Language language) {
// for some reason GsfTestBase is not using DataObjects for BaseDocument construction
// which means that for example Java formatter which does call EditorCookie to retrieve
// document will get difference instance of BaseDocument for indentation
try {
DataObject dobj = DataObject.find(fo);
assertNotNull(dobj);
EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class);
assertNotNull(ec);
return (BaseDocument) ec.openDocument();
} catch (Exception ex) {
fail(ex.toString());
return null;
}
}
示例7: testNestedEmbeddingOffsetsRetaining
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
public void testNestedEmbeddingOffsetsRetaining() throws Exception {
// 000000000011111111112222222222
// 012345678901234567890123456789
String text = "a%";
ModificationTextDocument doc = new ModificationTextDocument();
doc.insertString(0, text, null);
doc.putProperty(Language.class, TestJoinTopTokenId.language());
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
// Logger.getLogger("org.netbeans.lib.lexer.inc.TokenHierarchyUpdate").setLevel(Level.FINEST); // Extra logging
// Logger.getLogger("org.netbeans.lib.lexer.inc.TokenListUpdater").setLevel(Level.FINE); // Extra logging
// Logger.getLogger("org.netbeans.lib.lexer.inc.TokenListListUpdate").setLevel(Level.FINE); // Extra logging
doc.insertString(2, "x", null);
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
doc.insertString(3, "y", null);
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
doc.remove(3, 1);
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
doc.remove(2, 1);
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
doc.insertString(2, "x", null);
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
doc.insertString(3, "y", null);
LexerTestUtilities.incCheck(doc, true); // Ensure the whole embedded hierarchy gets created
}
示例8: initializeRegistry
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
protected void initializeRegistry() {
DefaultLanguageConfig defaultLanguage = getPreferredLanguage();
if (defaultLanguage == null) {
fail("If you don't implement getPreferredLanguage(), you must override initializeRegistry!");
return;
}
if (!LanguageRegistry.getInstance().isSupported(getPreferredMimeType())) {
List<Action> actions = Collections.emptyList();
org.netbeans.modules.csl.core.Language dl = new org.netbeans.modules.csl.core.Language(
"unknown", getPreferredMimeType(), actions,
defaultLanguage, getCodeCompleter(),
getRenameHandler(), defaultLanguage.getDeclarationFinder(),
defaultLanguage.getFormatter(), getKeystrokeHandler(),
getIndexerFactory(), getStructureScanner(), null,
defaultLanguage.isUsingCustomEditorKit());
List<org.netbeans.modules.csl.core.Language> languages = new ArrayList<org.netbeans.modules.csl.core.Language>();
languages.add(dl);
CslCorePackageAccessor.get().languageRegistryAddLanguages(languages);
}
}
示例9: 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"));
}
示例10: ensureRegistered
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected final void ensureRegistered(AstRule hint) throws Exception {
org.netbeans.modules.csl.core.Language language = LanguageRegistry.getInstance().getLanguageByMimeType(getPreferredMimeType());
assertNotNull(language.getHintsProvider());
GsfHintsManager hintsManager = language.getHintsManager();
Map<?, List<? extends AstRule>> hints = (Map<?, List<? extends AstRule>>)hintsManager.getHints();
Set<?> kinds = hint.getKinds();
for (Object nodeType : kinds) {
List<? extends AstRule> rules = hints.get(nodeType);
assertNotNull(rules);
boolean found = false;
for (AstRule rule : rules) {
if (rule.getClass() == hint.getClass()) {
found = true;
break;
}
}
assertTrue(found);
}
}
示例11: getDocument
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
@Override
protected BaseDocument getDocument(FileObject fo, String mimeType, Language language) {
// for some reason GsfTestBase is not using DataObjects for BaseDocument construction
// which means that for example Java formatter which does call EditorCookie to retrieve
// document will get difference instance of BaseDocument for indentation
try {
DataObject dobj = DataObject.find(fo);
assertNotNull(dobj);
EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class);
assertNotNull(ec);
return (BaseDocument)ec.openDocument();
}
catch (Exception ex){
fail(ex.toString());
return null;
}
}
示例12: performTest
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
private void performTest(String name, boolean specialMacTreatment) throws Exception {
prepareTest(name);
DataObject testData = DataObject.find(testSource);
EditorCookie ec = testData.getLookup().lookup(EditorCookie.class);
Document doc = ec.openDocument();
doc.putProperty(Language.class, JavaTokenId.language());
for (ErrorDescription ed : new ErrorHintsProvider().computeErrors(info, doc, Utilities.JAVA_MIME_TYPE))
ref(ed.toString().replaceAll("\\p{Space}*:\\p{Space}*", ":"));
if (!org.openide.util.Utilities.isMac() && specialMacTreatment) {
compareReferenceFiles(this.getName()+".ref",this.getName()+"-nonmac.pass",this.getName()+".diff");
} else {
compareReferenceFiles();
}
}
示例13: 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);
}
示例14: testRandomModsJavaSeed1
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
public void testRandomModsJavaSeed1() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty(Language.class, JavaTokenId.language());
doc.putProperty("mimeType", "text/x-java");
ViewHierarchyRandomTesting.initRandomText(container);
ViewHierarchyRandomTesting.addRound(container).setOpCount(OP_COUNT);
ViewHierarchyRandomTesting.testFixedScenarios(container);
container.run(1286796912276L);
// Exclude caret row highlighting
excludeHighlights(pane);
container.run(1286796912276L);
}
示例15: loadTheMap
import org.netbeans.api.lexer.Language; //导入依赖的package包/类
private static Map<String, Coloring> loadTheMap(
List<String> legacyNonTokenColoringNames,
Language<?> lexerLanguage,
List<? extends TokenContext> syntaxLanguages,
Collection<? extends FontColorSettings> fontsColors
) {
HashMap<String, Coloring> coloringMap = new HashMap<String, Coloring>();
if (!fontsColors.isEmpty()) {
FontColorSettings fcs = fontsColors.iterator().next();
if (legacyNonTokenColoringNames != null) {
collectLegacyNonTokenColorings(coloringMap, legacyNonTokenColoringNames, fcs);
}
collectNonTokenColorings(coloringMap, fcs);
if (syntaxLanguages != null) {
collectLegacyTokenColorings(coloringMap, syntaxLanguages, fcs);
}
if (lexerLanguage != null) {
collectTokenColorings(coloringMap, lexerLanguage, fcs);
}
}
return Collections.unmodifiableMap(coloringMap);
}