Refine search
public TokenList lookupTokenList(Document doc) { Object mimeTypeObj = doc.getProperty("mimeType"); String mimeType = "text/plain"; if (mimeTypeObj instanceof String) { mimeType = (String) mimeTypeObj; } for (TokenListProvider p : MimeLookup.getLookup(MimePath.get(mimeType)).lookupAll(TokenListProvider.class)) { TokenList l = p.findTokenList(doc); if (l != null) return l; } return null; } };
private static Iterable<? extends JavaIndexerPlugin> createPlugins( @NonNull final URL root, @NonNull final FileObject cacheFolder) { final List<JavaIndexerPlugin> plugins = new ArrayList<JavaIndexerPlugin>(); for (JavaIndexerPlugin.Factory factory : MimeLookup.getLookup( MimePath.parse(JavacParser.MIME_TYPE)).lookupAll(JavaIndexerPlugin.Factory.class)) { final JavaIndexerPlugin plugin = factory.create(root, cacheFolder); if (plugin != null) { plugins.add(plugin); } } return plugins; }
private synchronized Formatter getFormatter() { if (formatter == null) { // XXX: Carefull here, generally context.mimePath() != mimeType. This // task's factory was created for a top level language (mimeType), but the task // itself can be used for an embedded language. // If the task is used for the document itself (not an embedded // section) Context.mimePath() == mimeType. // However, if it is used for an embedded section the Context.mimePath() gives // the mime path (languege path) of that section. Which is generally // something like 'application/x-httpd-eruby/text/x-ruby'. While the // task was registered for 'text/x-ruby'. // Therefore with the __current__ implementation of MimeLookupInitializerImpl // we can simply take the last component of Context.mimePath(). MimePath mimePath = MimePath.parse(context.mimePath()); String mimeType = mimePath.size() > 1 ? mimePath.getMimeType(mimePath.size() - 1) : mimePath.getPath(); Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType); formatter = language.getFormatter(); } return formatter; }
private static boolean isCorrectMimeType(String mt) { if (JsTokenId.JAVASCRIPT_MIME_TYPE.equals(mt) || JsTokenId.JSON_MIME_TYPE.equals(mt)) { return true; } MimePath mp = MimePath.get(mt); String inhType = mp.getInheritedType(); return JsTokenId.JAVASCRIPT_MIME_TYPE.equals(inhType) || JsTokenId.JSON_MIME_TYPE.equals(inhType); }
private List<Object []> scan(MimePath mimePath, String profile, boolean scanModules, boolean scanUsers) { Map<String, List<Object []>> files = new HashMap<String, List<Object []>>(); SettingsType.getLocator(storageDescription).scan(baseFolder, mimePath.getPath(), profile, true, scanModules, scanUsers, mimePath.size() > 1, files); assert files.size() <= 1 : "Too many results in the scan"; //NOI18N return files.get(profile); }
Preferences prefs(String mime) { MemoryPreferences cached = preferences.get(mime); if (cached != null) { return cached.getPreferences(); } MimePath path = MimePath.parse(mime); Preferences result = MimeLookup.getLookup(mime).lookup(Preferences.class); if (!mime.equals("")) { // NOI18N String parentMime = path.getInheritedType(); /* result = new InheritedPreferences( prefs(parentMime), result); */ cached = MemoryPreferences.getWithInherited(this, prefs(parentMime), result); } else { cached = MemoryPreferences.get(this, result); } cached.getPreferences().addPreferenceChangeListener(weakChangeL); preferences.put(mime, cached); return cached.getPreferences(); }
Language<?> language, String mimeType, boolean addPre) { MimePath mimePath = MimePath.parse(mimeType); Lookup lookup = MimeLookup.getLookup(mimePath); FontColorSettings fcs = lookup.lookup(FontColorSettings.class); if (embedded != null) { String embeddedMimeType = MimePath.parse(embedded.languagePath().mimePath()).getPath(); Color bg = null; Color fg = null;
public FontColorProviderImpl(String mimeType) { this.mimeType = mimeType; Lookup lookup = MimeLookup.getLookup(MimePath.get(mimeType)); result = lookup.lookupResult(FontColorSettings.class); fcs = result.allInstances().iterator().next(); result.addLookupListener(this); }
private Preferences getInherited() { if (inherited == null && mimePath.length() > 0) { String type = MimePath.parse(mimePath).getInheritedType(); if (type != null) { inherited = factory.createPreferences(MimePath.parse(type)); } else { inherited = factory.createPreferences(MimePath.EMPTY); } inherited.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, inherited)); } return inherited; }
MimePath linkedMimePath = MimePath.parse(linkTarget.getPath().substring(baseFolder.getPath().length() + 1)); assert linkedMimePath != mimePath : "linkedMimePath should not be the same as the original one"; //NOI18N if (linkedMimePath.size() == 1) { Map<K, V> linkedMap = load(linkedMimePath, profile, defaults); map.putAll(linkedMap); LOG.fine("Adding linked '" + storageDescription.getId() + "' from: '" + linkedMimePath.getPath() + "'"); //NOI18N } else { if (LOG.isLoggable(Level.WARNING)) { LOG.warning("Linking to other than top level mime types is prohibited. " //NOI18N + "Ignoring editor settings link from '" + mimePath.getPath() //NOI18N + "' to '" + linkedMimePath.getPath() + "'"); //NOI18N StorageReader<? extends K, ? extends V> reader = storageDescription.createReader(settingFile, mimePath.getPath());
protected @Override void flushSpi() throws BackingStoreException { // This should normally be true when invoked from flushTask, but // clients can generally get this node and call flush() on it without // changing anything. if (local != null) { try { storage.save(MimePath.parse(mimePath), null, false, local); } catch (IOException ioe) { LOG.log(Level.WARNING, "Can't save editor preferences for '" + mimePath + "'", ioe); //NOI18N } } }
MimePath mimePath = MimePath.parse (context.mimePath ()); String mimeType = mimePath.getMimeType (mimePath.size () - 1); Language l = LanguagesManager.getDefault ().getLanguage (mimeType); Object indentValue = getIndentProperties (l); LanguagePath languagePath = LanguagePath.get (org.netbeans.api.lexer.Language.find (mimePath.getMimeType (0))); for (int i = 1; i < mimePath.size(); i++) languagePath = languagePath.embedded (org.netbeans.api.lexer.Language.find (mimePath.getMimeType (i))); List<TokenSequence> tokenSequences = tokenHierarchy.tokenSequenceList (languagePath, context.startOffset (), context.endOffset ());
/** * Converts an array of mime types to a <code>MimePath</code> instance. */ public static MimePath mimeTypes2mimePath(String[] mimeTypes) { MimePath mimePath = MimePath.EMPTY; for (int i = 0; i < mimeTypes.length; i++) { mimePath = MimePath.get(mimePath, mimeTypes[i]); } return mimePath; }
@Override public Preferences createPreferences(MimePath mimePath) { synchronized (INSTANCES) { PreferencesImpl prefs = INSTANCES.get(mimePath); if (prefs == null) { prefs = new PreferencesImpl(this, mimePath.getPath()); INSTANCES.put(mimePath, prefs); } return prefs; } } };
public static String getHtml(String text) { StringBuffer buf = new StringBuffer(); // TODO - check whether we need Js highlighting or rhtml highlighting TokenHierarchy tokenH = TokenHierarchy.create(text, JsTokenId.language()); Lookup lookup = MimeLookup.getLookup(MimePath.get(JsTokenId.JAVASCRIPT_MIME_TYPE)); FontColorSettings settings = lookup.lookup(FontColorSettings.class); @SuppressWarnings("unchecked") TokenSequence<? extends TokenId> tok = tokenH.tokenSequence(); while (tok.moveNext()) { Token<? extends TokenId> token = tok.token(); String category = token.id().name(); AttributeSet set = settings.getTokenFontColors(category); if (set == null) { category = token.id().primaryCategory(); if (category == null) { category = "whitespace"; //NOI18N } set = settings.getTokenFontColors(category); } String tokenText = htmlize(token.text().toString()); buf.append(color(tokenText, set)); } return buf.toString(); }
/** * Creates new form DefaultFoldingOptions */ public DefaultFoldingOptions(String mime, Preferences preferences) { initComponents(); VerticalFlowLayout vfl = new VerticalFlowLayout(); localSwitchboard.setLayout(vfl); vfl = new VerticalFlowLayout(); localSwitchboard.setLayout(vfl); this.mimeType = mime; this.preferences = preferences; String parentMime = MimePath.parse(mime).getInheritedType(); if (parentMime != null) { parentFoldTypes = new HashSet<String>(13); for (FoldType ft : FoldUtilities.getFoldTypes(parentMime).values()) { parentFoldTypes.add(ft.code()); } } else { parentFoldTypes = Collections.emptyList(); } }
private Map<String, TypedValue> getLocal() { if (local == null) { try { local = new HashMap<String, TypedValue>(storage.load(MimePath.parse(mimePath), null, false)); } catch (IOException ioe) { LOG.log(Level.WARNING, "Can't load editor preferences for '" + mimePath + "'", ioe); //NOI18N local = new HashMap<String, TypedValue>(); } } return local; }