Search in sources :

Example 1 with ConfigurableTemplateLanguageFileViewProvider

use of com.intellij.psi.templateLanguages.ConfigurableTemplateLanguageFileViewProvider 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)

Aggregations

LocalQuickFixOnPsiElement (com.intellij.codeInspection.LocalQuickFixOnPsiElement)1 Project (com.intellij.openapi.project.Project)1 FileViewProvider (com.intellij.psi.FileViewProvider)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 ConfigurableTemplateLanguageFileViewProvider (com.intellij.psi.templateLanguages.ConfigurableTemplateLanguageFileViewProvider)1 TemplateLanguageFileViewProvider (com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1