Search in sources :

Example 1 with InlayParameterHintsProvider

use of com.intellij.codeInsight.hints.InlayParameterHintsProvider in project intellij-community by JetBrains.

the class ParameterNameHintsConfigurable method getLanguageBlackList.

@NotNull
private static String getLanguageBlackList(@NotNull Language language) {
    InlayParameterHintsProvider hintsProvider = InlayParameterHintsExtension.INSTANCE.forLanguage(language);
    if (hintsProvider == null) {
        return "";
    }
    Diff diff = ParameterNameHintsSettings.getInstance().getBlackListDiff(language);
    Set<String> blackList = diff.applyOn(hintsProvider.getDefaultBlackList());
    return StringUtil.join(blackList, "\n");
}
Also used : InlayParameterHintsProvider(com.intellij.codeInsight.hints.InlayParameterHintsProvider) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with InlayParameterHintsProvider

use of com.intellij.codeInsight.hints.InlayParameterHintsProvider 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 3 with InlayParameterHintsProvider

use of com.intellij.codeInsight.hints.InlayParameterHintsProvider in project intellij-community by JetBrains.

the class ParameterNameHintsConfigurable method createBlacklistPanel.

@Nullable
private JPanel createBlacklistPanel(@NotNull Language language) {
    InlayParameterHintsProvider provider = InlayParameterHintsExtension.INSTANCE.forLanguage(language);
    if (!provider.isBlackListSupported())
        return null;
    String blackList = getLanguageBlackList(language);
    EditorTextField editorTextField = createEditorField(blackList);
    editorTextField.addDocumentListener(new DocumentAdapter() {

        @Override
        public void documentChanged(DocumentEvent e) {
            updateOkEnabled(language, editorTextField);
        }
    });
    updateOkEnabled(language, editorTextField);
    myEditors.put(language, editorTextField);
    JPanel blacklistPanel = new JPanel();
    BoxLayout layout = new BoxLayout(blacklistPanel, BoxLayout.Y_AXIS);
    blacklistPanel.setLayout(layout);
    blacklistPanel.setBorder(IdeBorderFactory.createTitledBorder("Blacklist"));
    blacklistPanel.add(new JBLabel(getBlacklistExplanationHTML(language)));
    blacklistPanel.add(editorTextField);
    return blacklistPanel;
}
Also used : InlayParameterHintsProvider(com.intellij.codeInsight.hints.InlayParameterHintsProvider) EditorTextField(com.intellij.ui.EditorTextField) JBLabel(com.intellij.ui.components.JBLabel) DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

InlayParameterHintsProvider (com.intellij.codeInsight.hints.InlayParameterHintsProvider)3 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)2 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)2 EditorTextField (com.intellij.ui.EditorTextField)2 JBLabel (com.intellij.ui.components.JBLabel)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 CodeInsightBundle (com.intellij.codeInsight.CodeInsightBundle)1 HintUtilsKt (com.intellij.codeInsight.hints.HintUtilsKt)1 InlayParameterHintsExtension (com.intellij.codeInsight.hints.InlayParameterHintsExtension)1 Option (com.intellij.codeInsight.hints.Option)1 Language (com.intellij.lang.Language)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 ERRORS_ATTRIBUTES (com.intellij.openapi.editor.colors.CodeInsightColors.ERRORS_ATTRIBUTES)1 HighlighterLayer (com.intellij.openapi.editor.markup.HighlighterLayer)1 MarkupModel (com.intellij.openapi.editor.markup.MarkupModel)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1