Search in sources :

Example 71 with Language

use of com.intellij.lang.Language 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)

Example 72 with Language

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

the class LocalInspectionsPass method appendDialects.

static void appendDialects(PsiElement element, Set<Language> outProcessedLanguages, Set<String> outDialectIds) {
    Language language = element.getLanguage();
    outDialectIds.add(language.getID());
    if (outProcessedLanguages.add(language)) {
        for (Language dialect : language.getDialects()) {
            outDialectIds.add(dialect.getID());
        }
    }
}
Also used : Language(com.intellij.lang.Language)

Example 73 with Language

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

the class ParameterNameHintsConfigurable method initLanguageCombo.

private void initLanguageCombo(Language selected, List<Language> languages) {
    ListComboBoxModel<Language> model = new ListComboBoxModel<>(languages);
    myCurrentLanguageCombo = new ComboBox<>(model);
    myCurrentLanguageCombo.setSelectedItem(selected);
    myCurrentLanguageCombo.setRenderer(new ListCellRendererWrapper<Language>() {

        @Override
        public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
            setText(value.getDisplayName());
        }
    });
    myCurrentLanguageCombo.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            Language language = (Language) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                showLanguagePanel(language);
            }
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) Language(com.intellij.lang.Language) ListComboBoxModel(org.jdesktop.swingx.combobox.ListComboBoxModel) ItemListener(java.awt.event.ItemListener)

Example 74 with Language

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

the class ParameterNameHintsConfigurable method storeBlackListDiff.

private static void storeBlackListDiff(@NotNull Language language, @NotNull String text) {
    Set<String> updatedBlackList = StringUtil.split(text, "\n").stream().filter((e) -> !e.trim().isEmpty()).collect(Collectors.toCollection(LinkedHashSet::new));
    InlayParameterHintsProvider provider = InlayParameterHintsExtension.INSTANCE.forLanguage(language);
    Set<String> defaultBlackList = provider.getDefaultBlackList();
    Diff diff = Diff.Builder.build(defaultBlackList, updatedBlackList);
    ParameterNameHintsSettings.getInstance().setBlackListDiff(language, diff);
}
Also used : Language(com.intellij.lang.Language) java.util(java.util) SelectionModel(com.intellij.openapi.editor.SelectionModel) Document(com.intellij.openapi.editor.Document) Option(com.intellij.codeInsight.hints.Option) ItemListener(java.awt.event.ItemListener) ERRORS_ATTRIBUTES(com.intellij.openapi.editor.colors.CodeInsightColors.ERRORS_ATTRIBUTES) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBLabel(com.intellij.ui.components.JBLabel) CodeInsightBundle(com.intellij.codeInsight.CodeInsightBundle) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) HighlighterLayer(com.intellij.openapi.editor.markup.HighlighterLayer) InlayParameterHintsProvider(com.intellij.codeInsight.hints.InlayParameterHintsProvider) DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) FileTypes(com.intellij.openapi.fileTypes.FileTypes) HintUtilsKt(com.intellij.codeInsight.hints.HintUtilsKt) ComboBox(com.intellij.openapi.ui.ComboBox) EditorTextField(com.intellij.ui.EditorTextField) ItemEvent(java.awt.event.ItemEvent) JBCheckBox(com.intellij.ui.components.JBCheckBox) StringUtil(com.intellij.openapi.util.text.StringUtil) InlayParameterHintsExtension(com.intellij.codeInsight.hints.InlayParameterHintsExtension) ListCellRendererWrapper(com.intellij.ui.ListCellRendererWrapper) Editor(com.intellij.openapi.editor.Editor) Collectors(java.util.stream.Collectors) ListComboBoxModel(org.jdesktop.swingx.combobox.ListComboBoxModel) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) EditorFactory(com.intellij.openapi.editor.EditorFactory) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) InlayParameterHintsProvider(com.intellij.codeInsight.hints.InlayParameterHintsProvider)

Example 75 with Language

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

the class QuickEditAction method getRangePair.

@Nullable
protected Pair<PsiElement, TextRange> getRangePair(final PsiFile file, final Editor editor) {
    final int offset = editor.getCaretModel().getOffset();
    final PsiLanguageInjectionHost host = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false);
    if (host == null || ElementManipulators.getManipulator(host) == null)
        return null;
    final List<Pair<PsiElement, TextRange>> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host);
    if (injections == null || injections.isEmpty())
        return null;
    final int offsetInElement = offset - host.getTextRange().getStartOffset();
    final Pair<PsiElement, TextRange> rangePair = ContainerUtil.find(injections, pair -> pair.second.containsRange(offsetInElement, offsetInElement));
    if (rangePair != null) {
        final Language language = rangePair.first.getContainingFile().getLanguage();
        final Object action = language.getUserData(EDIT_ACTION_AVAILABLE);
        if (action != null && action.equals(false))
            return null;
        myLastLanguageName = language.getDisplayName();
    }
    return rangePair;
}
Also used : Language(com.intellij.lang.Language) PsiLanguageInjectionHost(com.intellij.psi.PsiLanguageInjectionHost) TextRange(com.intellij.openapi.util.TextRange) PsiElement(com.intellij.psi.PsiElement) Pair(com.intellij.openapi.util.Pair) Nullable(org.jetbrains.annotations.Nullable)

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