Search in sources :

Example 16 with Language

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

the class StudyUtils method showNoSdkNotification.

public static void showNoSdkNotification(@NotNull final Task currentTask, @NotNull final Project project) {
    final Lesson lesson = currentTask.getLesson();
    if (lesson == null)
        return;
    final Course course = lesson.getCourse();
    if (course == null)
        return;
    final Language language = course.getLanguageById();
    StudyExecutor.INSTANCE.forLanguage(language).showNoSdkNotification(project);
}
Also used : Language(com.intellij.lang.Language)

Example 17 with Language

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

the class XmlDocumentationProvider method generateHtmlAdditionalDocTemplate.

static String generateHtmlAdditionalDocTemplate(@NotNull PsiElement element) {
    StringBuilder buf = new StringBuilder();
    final PsiFile containingFile = element.getContainingFile();
    if (containingFile != null) {
        final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
        boolean append;
        if (tag instanceof HtmlTag) {
            append = true;
        } else {
            final FileViewProvider provider = containingFile.getViewProvider();
            Language language;
            if (provider instanceof TemplateLanguageFileViewProvider) {
                language = ((TemplateLanguageFileViewProvider) provider).getTemplateDataLanguage();
            } else {
                language = provider.getBaseLanguage();
            }
            append = language == XHTMLLanguage.INSTANCE;
        }
        if (tag != null) {
            EntityDescriptor descriptor = HtmlDescriptorsTable.getTagDescriptor(tag.getName());
            if (descriptor != null && append) {
                buf.append("<br>");
                buf.append(XmlBundle.message("html.quickdoc.additional.template", descriptor.getHelpRef(), BASE_SITEPOINT_URL + tag.getName()));
            }
        }
    }
    return buf.toString();
}
Also used : TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) Language(com.intellij.lang.Language) XHTMLLanguage(com.intellij.lang.xhtml.XHTMLLanguage) HtmlTag(com.intellij.psi.html.HtmlTag) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider)

Example 18 with Language

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

the class XmlTagRenameHandler method getElement.

@Nullable
private static PsiElement getElement(@Nullable final DataContext context) {
    if (context != null) {
        final Editor editor = getEditor(context);
        if (editor != null) {
            final int offset = editor.getCaretModel().getOffset();
            final PsiFile file = CommonDataKeys.PSI_FILE.getData(context);
            if (file instanceof XmlFile) {
                return file.getViewProvider().findElementAt(offset);
            }
            if (file != null) {
                final Language language = PsiUtilCore.getLanguageAtOffset(file, offset);
                if (language != file.getLanguage()) {
                    final PsiFile psiAtOffset = file.getViewProvider().getPsi(language);
                    if (psiAtOffset instanceof XmlFile) {
                        return psiAtOffset.findElementAt(offset);
                    }
                }
            }
        }
    }
    return null;
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) Language(com.intellij.lang.Language) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with Language

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

the class XsltConfigImpl method initComponent.

@Override
@SuppressWarnings({ "StringEquality" })
public void initComponent() {
    final Language xmlLang = StdFileTypes.XML.getLanguage();
    //            intentionManager.addAction(new DeleteUnusedParameterFix());
    //            intentionManager.addAction(new DeleteUnusedVariableFix());
    final XsltFormattingModelBuilder builder = new XsltFormattingModelBuilder(LanguageFormatting.INSTANCE.forLanguage(xmlLang));
    LanguageFormatting.INSTANCE.addExplicitExtension(xmlLang, builder);
    try {
        // TODO: put this into com.intellij.refactoring.actions.IntroduceParameterAction, just like IntroduceVariableAction
        final AnAction introduceParameter = ActionManager.getInstance().getAction("IntroduceParameter");
        if (introduceParameter != null) {
            introduceParameter.setInjectedContext(true);
        }
    } catch (Exception e) {
        Logger.getInstance(XsltConfigImpl.class.getName()).error(e);
    }
}
Also used : Language(com.intellij.lang.Language) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 20 with Language

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

the class PyInjectorBase method registerInjection.

protected PyInjectionUtil.InjectionResult registerInjection(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
    final Language language = getInjectedLanguage(context);
    if (language != null) {
        final PsiElement element = PyInjectionUtil.getLargestStringLiteral(context);
        if (element != null) {
            registrar.startInjecting(language);
            final PyInjectionUtil.InjectionResult result = PyInjectionUtil.registerStringLiteralInjection(element, registrar);
            if (result.isInjected()) {
                registrar.doneInjecting();
            }
            return result;
        }
    }
    return PyInjectionUtil.InjectionResult.EMPTY;
}
Also used : Language(com.intellij.lang.Language) PsiElement(com.intellij.psi.PsiElement)

Aggregations

Language (com.intellij.lang.Language)292 NotNull (org.jetbrains.annotations.NotNull)58 Nullable (org.jetbrains.annotations.Nullable)49 PsiElement (com.intellij.psi.PsiElement)46 PsiFile (com.intellij.psi.PsiFile)45 FileType (com.intellij.openapi.fileTypes.FileType)31 Project (com.intellij.openapi.project.Project)31 TextRange (com.intellij.openapi.util.TextRange)25 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 FileViewProvider (com.intellij.psi.FileViewProvider)21 HbLanguage (com.dmarcotte.handlebars.HbLanguage)20 JavaLanguage (com.intellij.lang.java.JavaLanguage)16 Editor (com.intellij.openapi.editor.Editor)14 XMLLanguage (com.intellij.lang.xml.XMLLanguage)12 TemplateLanguageFileViewProvider (com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider)11 List (java.util.List)11 HTMLLanguage (com.intellij.lang.html.HTMLLanguage)9 JavascriptLanguage (com.intellij.lang.javascript.JavascriptLanguage)9 Document (com.intellij.openapi.editor.Document)9