private void reportOneTagProblem( final XmlTag tag, final String name, final String localizedMessage, final IntentionAction basicIntention, final HighlightDisplayKey key, final XmlEntitiesInspection inspection, final int type) { boolean htmlTag = false; if (tag instanceof HtmlTag) { htmlTag = true; if (isAdditionallyDeclared(inspection.getAdditionalEntries(type), name)) return; } final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getInspectionProfile(); final IntentionAction intentionAction = inspection.getIntentionAction(name, type); if (htmlTag && profile.isToolEnabled(key, tag)) { addElementsForTagWithManyQuickFixes( tag, localizedMessage, isInjectedHtmlTagForWhichNoProblemsReporting((HtmlTag) tag) ? HighlightInfoType.INFORMATION : SeverityRegistrar.getInstance(tag.getProject()) .getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), intentionAction, basicIntention); } else if (!htmlTag) { addElementsForTag(tag, localizedMessage, HighlightInfoType.ERROR, basicIntention); } }
protected HighlightSeverity getSeverity(@NotNull RefElement element) { final PsiElement psiElement = element.getPointer().getContainingFile(); if (psiElement != null) { final GlobalInspectionContextImpl context = getContext(); final String shortName = getSeverityDelegateName(); final Tools tools = context.getTools().get(shortName); if (tools != null) { for (ScopeToolState state : tools.getTools()) { InspectionToolWrapper toolWrapper = state.getTool(); if (toolWrapper == getToolWrapper()) { return context .getCurrentProfile() .getErrorLevel(HighlightDisplayKey.find(shortName), psiElement) .getSeverity(); } } } final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile(); final HighlightDisplayLevel level = profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement); return level.getSeverity(); } return null; }
private static HighlightDisplayLevel getHighlightDisplayLevel( final LocalInspectionTool inspectionTool, final InspectionProfile inspectionProfile, PsiElement file) { final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionTool.getShortName()); return inspectionProfile.isToolEnabled(key, file) ? inspectionProfile.getErrorLevel(key, file) : HighlightDisplayLevel.DO_NOT_SHOW; }
@Override @NotNull public HighlightSeverity getSeverity(final PsiElement psiElement) { InspectionProfile profile = psiElement == null ? (InspectionProfile) InspectionProfileManager.getInstance().getRootProfile() : InspectionProjectProfileManager.getInstance(psiElement.getProject()) .getInspectionProfile(); HighlightDisplayLevel level = profile.getErrorLevel(myToolKey, psiElement); LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW); return level.getSeverity(); }
private void exportResults( @NotNull final CommonProblemDescriptor[] descriptors, @NotNull RefEntity refEntity, @NotNull Element parentNode) { for (CommonProblemDescriptor descriptor : descriptors) { @NonNls final String template = descriptor.getDescriptionTemplate(); int line = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor) descriptor).getLineNumber() : -1; final PsiElement psiElement = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor) descriptor).getPsiElement() : null; @NonNls String problemText = StringUtil.replace( StringUtil.replace( template, "#ref", psiElement != null ? ProblemDescriptorUtil.extractHighlightedText(descriptor, psiElement) : ""), " #loc ", " "); Element element = refEntity.getRefManager().export(refEntity, parentNode, line); if (element == null) return; @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag")); problemClassElement.addContent(myToolWrapper.getDisplayName()); final HighlightSeverity severity; if (refEntity instanceof RefElement) { final RefElement refElement = (RefElement) refEntity; severity = getSeverity(refElement); } else { final InspectionProfile profile = InspectionProjectProfileManager.getInstance(getContext().getProject()) .getInspectionProfile(); final HighlightDisplayLevel level = profile.getErrorLevel( HighlightDisplayKey.find(myToolWrapper.getShortName()), psiElement); severity = level.getSeverity(); } if (severity != null) { ProblemHighlightType problemHighlightType = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor) descriptor).getHighlightType() : ProblemHighlightType.GENERIC_ERROR_OR_WARNING; final String attributeKey = getTextAttributeKey(getRefManager().getProject(), severity, problemHighlightType); problemClassElement.setAttribute("severity", severity.myName); problemClassElement.setAttribute("attribute_key", attributeKey); } element.addContent(problemClassElement); if (myToolWrapper instanceof GlobalInspectionToolWrapper) { final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper) myToolWrapper).getTool(); final QuickFix[] fixes = descriptor.getFixes(); if (fixes != null) { @NonNls Element hintsElement = new Element("hints"); for (QuickFix fix : fixes) { final String hint = globalInspectionTool.getHint(fix); if (hint != null) { @NonNls Element hintElement = new Element("hint"); hintElement.setAttribute("value", hint); hintsElement.addContent(hintElement); } } element.addContent(hintsElement); } } try { Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag")); descriptionElement.addContent(problemText); element.addContent(descriptionElement); } catch (IllegalDataException e) { //noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr System.out.println( "Cannot save results for " + refEntity.getName() + ", inspection which caused problem: " + myToolWrapper.getShortName()); } } }
private static HighlightDisplayLevel getHighlightDisplayLevel( Project project, GrReferenceElement ref) { final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile(); return profile.getErrorLevel(HighlightDisplayKey.find(SHORT_NAME), ref); }