Search in sources :

Example 6 with FileViewProvider

use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.

the class HtmlUnknownTagInspection method createChangeTemplateDataFix.

@Nullable
@Override
protected LocalQuickFix createChangeTemplateDataFix(PsiFile file) {
    if (file != TemplateLanguageUtil.getTemplateFile(file))
        return null;
    FileViewProvider vp = file.getViewProvider();
    if (vp instanceof ConfigurableTemplateLanguageFileViewProvider) {
        final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider) vp;
        final String text = LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName());
        return new LocalQuickFixOnPsiElement(file) {

            @NotNull
            @Override
            public String getText() {
                return text;
            }

            @Override
            public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
                ChangeTemplateDataLanguageAction.editSettings(project, file.getVirtualFile());
            }

            @Nls
            @NotNull
            @Override
            public String getFamilyName() {
                return "Change template data language";
            }
        };
    }
    return null;
}
Also used : LocalQuickFixOnPsiElement(com.intellij.codeInspection.LocalQuickFixOnPsiElement) Project(com.intellij.openapi.project.Project) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) ConfigurableTemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.ConfigurableTemplateLanguageFileViewProvider) FileViewProvider(com.intellij.psi.FileViewProvider) PsiFile(com.intellij.psi.PsiFile) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) ConfigurableTemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.ConfigurableTemplateLanguageFileViewProvider) ConfigurableTemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.ConfigurableTemplateLanguageFileViewProvider) NotNull(org.jetbrains.annotations.NotNull) PsiElement(com.intellij.psi.PsiElement) LocalQuickFixOnPsiElement(com.intellij.codeInspection.LocalQuickFixOnPsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with FileViewProvider

use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.

the class HtmlSelectioner method select.

@Override
public List<TextRange> select(PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) {
    List<TextRange> result;
    if (!(e instanceof XmlToken) || XmlTokenSelectioner.shouldSelectToken((XmlToken) e) || ((XmlToken) e).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
        result = super.select(e, editorText, cursorOffset, editor);
    } else {
        result = ContainerUtil.newArrayList();
    }
    final PsiElement parent = e.getParent();
    if (parent instanceof XmlComment) {
        result.addAll(expandToWholeLine(editorText, parent.getTextRange(), true));
    }
    PsiFile psiFile = e.getContainingFile();
    addAttributeSelection(result, editor, cursorOffset, editorText, e);
    final FileViewProvider fileViewProvider = psiFile.getViewProvider();
    for (Language lang : fileViewProvider.getLanguages()) {
        final PsiFile langFile = fileViewProvider.getPsi(lang);
        if (langFile != psiFile)
            addAttributeSelection(result, editor, cursorOffset, editorText, fileViewProvider.findElementAt(cursorOffset, lang));
    }
    EditorHighlighter highlighter = HighlighterFactory.createHighlighter(e.getProject(), psiFile.getVirtualFile());
    highlighter.setText(editorText);
    addTagSelection2(e, result);
    return result;
}
Also used : FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) TextRange(com.intellij.openapi.util.TextRange) UnfairTextRange(com.intellij.openapi.util.UnfairTextRange) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Example 8 with FileViewProvider

use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.

the class FileBasedUserDataCache method compute.

public T compute(PsiFile file) {
    final FileViewProvider fileViewProvider = file.getViewProvider();
    final PsiFile baseFile = fileViewProvider.getPsi(fileViewProvider.getBaseLanguage());
    // expand chameleon out of lock
    baseFile.getFirstChild();
    return get(getKey(), baseFile, null).getValue();
}
Also used : FileViewProvider(com.intellij.psi.FileViewProvider) PsiFile(com.intellij.psi.PsiFile)

Example 9 with FileViewProvider

use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.

the class HectorComponent method isModified.

private boolean isModified() {
    final FileViewProvider viewProvider = myFile.getViewProvider();
    for (Language language : mySliders.keySet()) {
        JSlider slider = mySliders.get(language);
        final PsiFile root = viewProvider.getPsi(language);
        HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(myFile.getProject());
        if (root != null && getValue(highlightingLevelManager.shouldHighlight(root), highlightingLevelManager.shouldInspect(root)) != slider.getValue()) {
            return true;
        }
    }
    for (HectorComponentPanel panel : myAdditionalPanels) {
        if (panel.isModified()) {
            return true;
        }
    }
    return false;
}
Also used : HighlightingLevelManager(com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager) FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) HectorComponentPanel(com.intellij.openapi.editor.HectorComponentPanel) PsiFile(com.intellij.psi.PsiFile)

Example 10 with FileViewProvider

use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.

the class HectorComponent method forceDaemonRestart.

private void forceDaemonRestart() {
    final FileViewProvider viewProvider = myFile.getViewProvider();
    for (Language language : mySliders.keySet()) {
        JSlider slider = mySliders.get(language);
        PsiElement root = viewProvider.getPsi(language);
        assert root != null : "No root in " + viewProvider + " for " + language;
        int value = slider.getValue();
        if (value == 1) {
            HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.SKIP_HIGHLIGHTING);
        } else if (value == 2) {
            HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.SKIP_INSPECTION);
        } else {
            HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.FORCE_HIGHLIGHTING);
        }
    }
    final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(myFile.getProject());
    analyzer.restart();
}
Also used : FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) PsiElement(com.intellij.psi.PsiElement) RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

FileViewProvider (com.intellij.psi.FileViewProvider)41 PsiFile (com.intellij.psi.PsiFile)22 Language (com.intellij.lang.Language)21 PsiElement (com.intellij.psi.PsiElement)15 NotNull (org.jetbrains.annotations.NotNull)12 TextRange (com.intellij.openapi.util.TextRange)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 TemplateLanguageFileViewProvider (com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider)5 Project (com.intellij.openapi.project.Project)4 ASTNode (com.intellij.lang.ASTNode)3 Document (com.intellij.openapi.editor.Document)3 Pair (com.intellij.openapi.util.Pair)3 Nullable (org.jetbrains.annotations.Nullable)3 HighlightingLevelManager (com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager)2 FileASTNode (com.intellij.lang.FileASTNode)2 ExternalAnnotator (com.intellij.lang.annotation.ExternalAnnotator)2 XMLLanguage (com.intellij.lang.xml.XMLLanguage)2 FileType (com.intellij.openapi.fileTypes.FileType)2 SingleRootFileViewProvider (com.intellij.psi.SingleRootFileViewProvider)2 IStubFileElementType (com.intellij.psi.tree.IStubFileElementType)2