Search in sources :

Example 36 with Language

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

the class CodeErrorReport method getErrorsForText.

@NotNull
private Collection<PsiErrorElement> getErrorsForText(@NotNull LanguageCodeStyleSettingsProvider provider, @NotNull String sample) {
    PsiFile file = provider.createFileFromText(getProject(), sample);
    if (file == null) {
        Language language = provider.getLanguage();
        LanguageFileType type = language.getAssociatedFileType();
        if (type == null)
            return ContainerUtil.newArrayList();
        file = myFixture.configureByText(type, sample);
    }
    return PsiTreeUtil.collectElementsOfType(file, PsiErrorElement.class);
}
Also used : LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) Language(com.intellij.lang.Language) PsiFile(com.intellij.psi.PsiFile) NotNull(org.jetbrains.annotations.NotNull)

Example 37 with Language

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

the class XDebuggerEvaluateActionHandler method showDialog.

private static void showDialog(@NotNull XDebugSession session, VirtualFile file, XDebuggerEditorsProvider editorsProvider, XStackFrame stackFrame, XDebuggerEvaluator evaluator, @NotNull XExpression expression) {
    if (expression.getLanguage() == null) {
        Language language = null;
        if (stackFrame != null) {
            XSourcePosition position = stackFrame.getSourcePosition();
            if (position != null) {
                language = LanguageUtil.getFileLanguage(position.getFile());
            }
        }
        if (language == null && file != null) {
            language = LanguageUtil.getFileTypeLanguage(file.getFileType());
        }
        expression = new XExpressionImpl(expression.getExpression(), language, expression.getCustomInfo(), expression.getMode());
    }
    new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show();
}
Also used : Language(com.intellij.lang.Language) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XDebuggerEvaluationDialog(com.intellij.xdebugger.impl.evaluate.XDebuggerEvaluationDialog)

Example 38 with Language

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

the class JsonCodeStyleSettingsProvider method createSettingsPage.

@NotNull
@Override
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
    return new CodeStyleAbstractConfigurable(settings, originalSettings, "JSON") {

        @Override
        protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
            final Language language = JsonLanguage.INSTANCE;
            final CodeStyleSettings currentSettings = getCurrentSettings();
            return new TabbedLanguageCodeStylePanel(language, currentSettings, settings) {

                @Override
                protected void initTabs(CodeStyleSettings settings) {
                    addIndentOptionsTab(settings);
                    addSpacesTab(settings);
                    addBlankLinesTab(settings);
                    addWrappingAndBracesTab(settings);
                    addTab(new JsonCodeStylePanel(settings));
                }
            };
        }

        @Nullable
        @Override
        public String getHelpTopic() {
            return "reference.settingsdialog.codestyle.json";
        }
    };
}
Also used : CustomCodeStyleSettings(com.intellij.psi.codeStyle.CustomCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) Language(com.intellij.lang.Language) JsonLanguage(com.intellij.json.JsonLanguage) CodeStyleAbstractConfigurable(com.intellij.application.options.CodeStyleAbstractConfigurable) TabbedLanguageCodeStylePanel(com.intellij.application.options.TabbedLanguageCodeStylePanel) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with Language

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

the class DummyHolder method language.

protected static Language language(PsiElement context, Language defaultLanguage) {
    if (context == null)
        return defaultLanguage;
    PsiFile file = context.getContainingFile();
    if (file == null)
        return defaultLanguage;
    Language contextLanguage = context.getLanguage();
    Language language = file.getLanguage();
    if (language.isKindOf(contextLanguage))
        return language;
    return contextLanguage;
}
Also used : Language(com.intellij.lang.Language) PlainTextLanguage(com.intellij.openapi.fileTypes.PlainTextLanguage)

Example 40 with Language

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

the class MultiplePsiFilesPerDocumentFileViewProvider method getAllFiles.

@Override
@NotNull
public List<PsiFile> getAllFiles() {
    final List<PsiFile> roots = new ArrayList<>();
    for (Language language : getLanguages()) {
        PsiFile psi = getPsi(language);
        if (psi != null)
            roots.add(psi);
    }
    final PsiFile base = getPsi(getBaseLanguage());
    if (!roots.isEmpty() && roots.get(0) != base) {
        roots.remove(base);
        roots.add(0, base);
    }
    return roots;
}
Also used : Language(com.intellij.lang.Language) NotNull(org.jetbrains.annotations.NotNull)

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