com.intellij.codeInspection.InspectionProfileEntry Java Examples
The following examples show how to use
com.intellij.codeInspection.InspectionProfileEntry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BashLightQuickfixParametrizedTest.java From BashSupport with Apache License 2.0 | 6 votes |
protected void enableInspectionTools(@NotNull Class<?>... classes) { final InspectionProfileEntry[] tools = new InspectionProfileEntry[classes.length]; final List<InspectionEP> eps = ContainerUtil.newArrayList(); ContainerUtil.addAll(eps, Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)); ContainerUtil.addAll(eps, Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION)); next: for (int i = 0; i < classes.length; i++) { for (InspectionEP ep : eps) { if (classes[i].getName().equals(ep.implementationClass)) { tools[i] = ep.instantiateTool(); continue next; } } throw new IllegalArgumentException("Unable to find extension point for " + classes[i].getName()); } enableInspectionTools(tools); }
Example #2
Source File: SingleCheckboxOptionsPanel.java From consulo with Apache License 2.0 | 6 votes |
public SingleCheckboxOptionsPanel(@Nonnull String label, @Nonnull InspectionProfileEntry owner, @NonNls String property) { super(new GridBagLayout()); final boolean selected = getPropertyValue(owner, property); final JCheckBox checkBox = new JCheckBox(label, selected); final ButtonModel model = checkBox.getModel(); final SingleCheckboxChangeListener listener = new SingleCheckboxChangeListener(owner, property, model); model.addChangeListener(listener); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.anchor = GridBagConstraints.FIRST_LINE_START; constraints.fill = GridBagConstraints.HORIZONTAL; add(checkBox, constraints); }
Example #3
Source File: SingleIntegerFieldOptionsPanel.java From consulo with Apache License 2.0 | 6 votes |
public SingleIntegerFieldOptionsPanel(String labelString, final InspectionProfileEntry owner, @NonNls final String property, int integerFieldColumns) { super(new GridBagLayout()); final JLabel label = new JLabel(labelString); final JFormattedTextField valueField = createIntegerFieldTrackingValue(owner, property, integerFieldColumns); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.insets.right = UIUtil.DEFAULT_HGAP; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.BASELINE_LEADING; constraints.fill = GridBagConstraints.NONE; add(label, constraints); constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.insets.right = 0; constraints.anchor = GridBagConstraints.BASELINE_LEADING; constraints.fill = GridBagConstraints.NONE; add(valueField, constraints); }
Example #4
Source File: SingleIntegerFieldOptionsPanel.java From consulo with Apache License 2.0 | 6 votes |
/** * Sets integer number format to JFormattedTextField instance, * sets value of JFormattedTextField instance to object's field value, * synchronizes object's field value with the value of JFormattedTextField instance. * * @param textField JFormattedTextField instance * @param owner an object whose field is synchronized with {@code textField} * @param property object's field name for synchronization */ public static void setupIntegerFieldTrackingValue(final JFormattedTextField textField, final InspectionProfileEntry owner, final String property) { NumberFormat formatter = NumberFormat.getIntegerInstance(); formatter.setParseIntegerOnly(true); textField.setFormatterFactory(new DefaultFormatterFactory(new NumberFormatter(formatter))); textField.setValue(getPropertyValue(owner, property)); final Document document = textField.getDocument(); document.addDocumentListener(new DocumentAdapter() { @Override public void textChanged(DocumentEvent e) { try { textField.commitEdit(); setPropertyValue(owner, property, ((Number) textField.getValue()).intValue()); } catch (ParseException e1) { // No luck this time } } }); }
Example #5
Source File: LightPlatformTestCase.java From consulo with Apache License 2.0 | 6 votes |
protected void enableInspectionTools(@Nonnull Class<?>... classes) { final InspectionProfileEntry[] tools = new InspectionProfileEntry[classes.length]; final List<InspectionEP> eps = ContainerUtil.newArrayList(); ContainerUtil.addAll(eps, LocalInspectionEP.LOCAL_INSPECTION.getExtensionList()); ContainerUtil.addAll(eps, InspectionEP.GLOBAL_INSPECTION.getExtensionList()); next: for (int i = 0; i < classes.length; i++) { for (InspectionEP ep : eps) { if (classes[i].getName().equals(ep.implementationClass)) { tools[i] = ep.instantiateTool(); continue next; } } throw new IllegalArgumentException("Unable to find extension point for " + classes[i].getName()); } enableInspectionTools(tools); }
Example #6
Source File: HaxeCodeInsightFixtureTestCase.java From intellij-haxe with Apache License 2.0 | 6 votes |
/** * Use reflection to load an annotator inspection class. * Specific to annotation tests, but placed here just to avoid adding yet another single-function base class. * * When we don't support versions of the plugin prior to v2016.1, we can revert the code to importing * the classes directly and get rid of this function. * * @return - An annotator-based inspection class instance. */ protected InspectionProfileEntry getAnnotatorBasedInspection() { // Because we're loading an inner class, and Class.forName simply substitutes '.' for '/', it won't find // the class unless we use the '$' as the final path separator. (Which is what the Java compiler does // when it creates an inner class.) //String defaultInspectorClassName = IdeaTarget.IS_VERSTION_16_COMPATIBLE // ? "com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitorBasedInspection$AnnotatorBasedInspection" // : "com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection$AnnotatorBasedInspection"; String defaultInspectorClassName = IdeaTarget.IS_VERSTION_16_COMPATIBLE ? "com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitorBasedInspection" : "com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection"; ClassWrapper<InspectionProfileEntry> wrapper = new ClassWrapper<InspectionProfileEntry>(defaultInspectorClassName); ClassWrapper<InspectionProfileEntry> annotator = new ClassWrapper<InspectionProfileEntry>(wrapper, "AnnotatorBasedInspection"); return annotator.newInstance(); }
Example #7
Source File: BashSyntaxHighlighterPerformanceTest.java From BashSupport with Apache License 2.0 | 6 votes |
private void enableInspections() { Class[] inspectionClasses = new BashTestInspections().getInspectionClasses(); ArrayList<InspectionProfileEntry> inspections = new ArrayList<InspectionProfileEntry>(); LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); for (LocalInspectionEP extension : extensions) { for (Class inspectionClass : inspectionClasses) { if (extension.implementationClass.equals(inspectionClass.getCanonicalName())) { extension.enabledByDefault = true; inspections.add(extension.instantiateTool()); } } } myFixture.enableInspections(inspections.toArray(new InspectionProfileEntry[inspections.size()])); }
Example #8
Source File: BashPerformanceTest.java From BashSupport with Apache License 2.0 | 6 votes |
private void enableInspections() { Class[] inspectionClasses = new BashTestInspections().getInspectionClasses(); ArrayList<InspectionProfileEntry> inspections = new ArrayList<InspectionProfileEntry>(); LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); for (LocalInspectionEP extension : extensions) { for (Class inspectionClass : inspectionClasses) { if (extension.implementationClass.equals(inspectionClass.getCanonicalName())) { extension.enabledByDefault = true; inspections.add(extension.instantiateTool()); } } } myFixture.enableInspections(inspections.toArray(new InspectionProfileEntry[inspections.size()])); }
Example #9
Source File: Descriptor.java From consulo with Apache License 2.0 | 5 votes |
public Descriptor(@Nonnull ScopeToolState state, @Nonnull InspectionProfileImpl inspectionProfile, @Nonnull Project project) { myState = state; myInspectionProfile = inspectionProfile; InspectionToolWrapper tool = state.getTool(); myText = tool.getDisplayName(); final String[] groupPath = tool.getGroupPath(); myGroup = groupPath.length == 0 ? new String[]{InspectionProfileEntry.GENERAL_GROUP_NAME} : groupPath; myKey = HighlightDisplayKey.find(tool.getShortName()); myScopeName = state.getScopeName(); myScope = state.getScope(project); myLevel = inspectionProfile.getErrorLevel(myKey, myScope, project); myEnabled = inspectionProfile.isToolEnabled(myKey, myScope, project); myToolWrapper = tool; }
Example #10
Source File: CheckBox.java From consulo with Apache License 2.0 | 5 votes |
public CheckBox(@Nonnull String label, @Nonnull InspectionProfileEntry owner, @NonNls String property) { super(label, getPropertyValue(owner, property)); final ButtonModel model = getModel(); final SingleCheckboxChangeListener listener = new SingleCheckboxChangeListener(owner, property, model); model.addChangeListener(listener); }
Example #11
Source File: InspectionProfileWrapper.java From consulo with Apache License 2.0 | 5 votes |
public static void checkInspectionsDuplicates(@Nonnull InspectionToolWrapper[] toolWrappers) { if (alreadyChecked) return; alreadyChecked = true; Set<InspectionProfileEntry> uniqTools = new THashSet<InspectionProfileEntry>(toolWrappers.length); for (InspectionToolWrapper toolWrapper : toolWrappers) { ProgressManager.checkCanceled(); if (!uniqTools.add(toolWrapper.getTool())) { LOG.error("Inspection " + toolWrapper.getDisplayName() + " (" + toolWrapper.getTool().getClass() + ") already registered"); } } }
Example #12
Source File: InspectionProfileImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public <T extends InspectionProfileEntry> void modifyToolSettings(@Nonnull final Key<T> shortNameKey, @Nonnull final PsiElement psiElement, @Nonnull final Consumer<T> toolConsumer) { modifyProfile(new Consumer<ModifiableModel>() { @Override public void consume(@Nonnull ModifiableModel model) { InspectionProfileEntry tool = model.getUnwrappedTool(shortNameKey.toString(), psiElement); //noinspection unchecked toolConsumer.consume((T) tool); } }); }
Example #13
Source File: GlobalInspectionContextUtil.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isToCheckFile(PsiFile file, @Nonnull InspectionProfileEntry tool, Tools tools, ProfileManager profileManager) { if (tools != null && file != null) { for (ScopeToolState state : tools.getTools()) { final NamedScope namedScope = state.getScope(file.getProject()); if (namedScope == null || namedScope.getValue().contains(file, profileManager.getScopesManager())) { if (state.isEnabled()) { InspectionToolWrapper toolWrapper = state.getTool(); if (toolWrapper.getTool() == tool) return true; } return false; } } } return false; }
Example #14
Source File: SingleIntegerFieldOptionsPanel.java From consulo with Apache License 2.0 | 5 votes |
private static int getPropertyValue(InspectionProfileEntry owner, String property) { try { return owner.getClass().getField(property).getInt(owner); } catch (Exception e) { return 0; } }
Example #15
Source File: SingleIntegerFieldOptionsPanel.java From consulo with Apache License 2.0 | 5 votes |
private static void setPropertyValue(InspectionProfileEntry owner, String property, int value) { try { owner.getClass().getField(property).setInt(owner, value); } catch (Exception e) { // OK } }
Example #16
Source File: SingleIntegerFieldOptionsPanel.java From consulo with Apache License 2.0 | 5 votes |
public static JFormattedTextField createIntegerFieldTrackingValue(@Nonnull InspectionProfileEntry owner, @Nonnull String property, int integerFieldColumns) { JFormattedTextField valueField = new JFormattedTextField(); valueField.setColumns(integerFieldColumns); setupIntegerFieldTrackingValue(valueField, owner, property); return valueField; }
Example #17
Source File: BashTestUtils.java From BashSupport with Apache License 2.0 | 5 votes |
public static InspectionProfileEntry findInspectionProfileEntry(Class<? extends LocalInspectionTool> clazz) { LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); for (LocalInspectionEP extension : extensions) { if (extension.implementationClass.equals(clazz.getCanonicalName())) { extension.enabledByDefault = true; return extension.instantiateTool(); } } throw new IllegalStateException("Unable to find inspection profile entry for " + clazz); }
Example #18
Source File: MultipleCheckboxOptionsPanel.java From consulo with Apache License 2.0 | 4 votes |
public static void initAndConfigureCheckbox(InspectionProfileEntry owner, String property, JCheckBox checkBox) { checkBox.setSelected(getPropertyValue(owner, property)); configureCheckbox(owner, property, checkBox); }
Example #19
Source File: DefUseInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Nullable @Override protected InspectionProfileEntry getInspection() { return new DefUseInspection(); }
Example #20
Source File: CheckBox.java From consulo with Apache License 2.0 | 4 votes |
SingleCheckboxChangeListener(InspectionProfileEntry owner, String property, ButtonModel model) { this.owner = owner; this.property = property; this.model = model; }
Example #21
Source File: DelegateInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected InspectionProfileEntry getInspection() { return new LombokInspection(); }
Example #22
Source File: OnXAnnotationInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected InspectionProfileEntry getInspection() { return new LombokInspection(); }
Example #23
Source File: DiverseInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected InspectionProfileEntry getInspection() { return new LombokInspection(); }
Example #24
Source File: InspectionProfileImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public <T extends InspectionProfileEntry> T getUnwrappedTool(@Nonnull Key<T> shortNameKey, @Nonnull PsiElement element) { //noinspection unchecked return (T) getUnwrappedTool(shortNameKey.toString(), element); }
Example #25
Source File: InspectionProfileImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Override public InspectionProfileEntry getUnwrappedTool(@Nonnull String shortName, @Nonnull PsiElement element) { InspectionToolWrapper tool = getInspectionTool(shortName, element); return tool == null ? null : tool.getTool(); }
Example #26
Source File: RedundantModifiersOnUtilityClassLombokInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected InspectionProfileEntry getInspection() { return new RedundantModifiersOnUtilityClassLombokAnnotationInspection(); }
Example #27
Source File: GlobalInspectionContextUtil.java From consulo with Apache License 2.0 | 4 votes |
public static boolean isToCheckMember(@Nonnull RefElement owner, @Nonnull InspectionProfileEntry tool, Tools tools, ProfileManager profileManager) { return isToCheckFile(((RefElementImpl)owner).getContainingFile(), tool, tools, profileManager) && !((RefElementImpl)owner).isSuppressed(tool.getShortName()); }
Example #28
Source File: LightPlatformTestCase.java From consulo with Apache License 2.0 | 4 votes |
protected void enableInspectionTool(@Nonnull InspectionProfileEntry tool) { InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool); enableInspectionTool(myAvailableInspectionTools, toolWrapper); }
Example #29
Source File: LightPlatformTestCase.java From consulo with Apache License 2.0 | 4 votes |
protected void enableInspectionTools(@Nonnull InspectionProfileEntry... tools) { for (InspectionProfileEntry tool : tools) { enableInspectionTool(tool); } }
Example #30
Source File: DefaultConstructorInspectionTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected InspectionProfileEntry getInspection() { return new LombokInspection(); }