Java Code Examples for com.intellij.lang.Language#getUserData()
The following examples show how to use
com.intellij.lang.Language#getUserData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LanguageFolding.java From consulo with Apache License 2.0 | 6 votes |
@Override public FoldingBuilder forLanguage(@Nonnull Language l) { FoldingBuilder cached = l.getUserData(getLanguageCache()); if (cached != null) return cached; List<FoldingBuilder> extensions = forKey(l); FoldingBuilder result; if (extensions.isEmpty()) { Language base = l.getBaseLanguage(); if (base != null) { result = forLanguage(base); } else { result = getDefaultImplementation(); } } else { return extensions.size() == 1 ? extensions.get(0) : new CompositeFoldingBuilder(extensions); } l.putUserData(getLanguageCache(), result); return result; }
Example 2
Source File: QuickEditAction.java From consulo with Apache License 2.0 | 6 votes |
@Nullable protected Pair<PsiElement, TextRange> getRangePair(final PsiFile file, final Editor editor) { final int offset = editor.getCaretModel().getOffset(); final PsiLanguageInjectionHost host = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false); if (host == null || ElementManipulators.getManipulator(host) == null) return null; final List<Pair<PsiElement, TextRange>> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host); if (injections == null || injections.isEmpty()) return null; final int offsetInElement = offset - host.getTextRange().getStartOffset(); final Pair<PsiElement, TextRange> rangePair = ContainerUtil.find(injections, new Condition<Pair<PsiElement, TextRange>>() { @Override public boolean value(final Pair<PsiElement, TextRange> pair) { return pair.second.containsRange(offsetInElement, offsetInElement); } }); if (rangePair != null) { final Language language = rangePair.first.getContainingFile().getLanguage(); final Object action = language.getUserData(EDIT_ACTION_AVAILABLE); if (action != null && action.equals(false)) return null; myLastLanguageName = language.getDisplayName(); } return rangePair; }