Search in sources :

Example 1 with DependentLanguage

use of com.intellij.lang.DependentLanguage in project intellij-community by JetBrains.

the class ChooseByNameLanguageFilter method getAllFilterValues.

@NotNull
@Override
protected Collection<Language> getAllFilterValues() {
    final Collection<Language> registeredLanguages = Language.getRegisteredLanguages();
    List<Language> accepted = new ArrayList<>();
    for (Language language : registeredLanguages) {
        if (language != Language.ANY && !(language instanceof DependentLanguage)) {
            accepted.add(language);
        }
    }
    Collections.sort(accepted, LanguageUtil.LANGUAGE_COMPARATOR);
    return accepted;
}
Also used : DependentLanguage(com.intellij.lang.DependentLanguage) Language(com.intellij.lang.Language) DependentLanguage(com.intellij.lang.DependentLanguage) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DependentLanguage

use of com.intellij.lang.DependentLanguage in project intellij-community by JetBrains.

the class BaseMoveHandler method getRoot.

@Nullable
private static PsiFile getRoot(final PsiFile file, final Editor editor) {
    if (file == null)
        return null;
    int offset = editor.getCaretModel().getOffset();
    if (offset == editor.getDocument().getTextLength())
        offset--;
    if (offset < 0)
        return null;
    PsiElement leafElement = file.findElementAt(offset);
    if (leafElement == null)
        return null;
    if (leafElement.getLanguage() instanceof DependentLanguage) {
        leafElement = file.getViewProvider().findElementAt(offset, file.getViewProvider().getBaseLanguage());
        if (leafElement == null)
            return null;
    }
    ASTNode node = leafElement.getNode();
    if (node == null)
        return null;
    return (PsiFile) PsiUtilBase.getRoot(node).getPsi();
}
Also used : DependentLanguage(com.intellij.lang.DependentLanguage) ASTNode(com.intellij.lang.ASTNode) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DependentLanguage (com.intellij.lang.DependentLanguage)2 ASTNode (com.intellij.lang.ASTNode)1 Language (com.intellij.lang.Language)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1