use of com.intellij.codeInspection.InspectionProfile in project intellij-community by JetBrains.
the class AddCustomHtmlElementIntentionAction method applyFix.
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
profile.modifyToolSettings(myInspectionKey, element, tool -> tool.addEntry(myName));
}
use of com.intellij.codeInspection.InspectionProfile in project intellij-community by JetBrains.
the class AddHtmlTagOrAttributeToCustomsIntention method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
profile.modifyToolSettings(myInspectionKey, descriptor.getPsiElement().getContainingFile(), entry -> {
XmlEntitiesInspection xmlEntitiesInspection = (XmlEntitiesInspection) entry;
xmlEntitiesInspection.addEntry(myName);
});
}
use of com.intellij.codeInspection.InspectionProfile in project intellij-community by JetBrains.
the class DomHighlightingLiteTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myInspectionProfile = new MockInspectionProfile();
myAnnotationsManager = new DomElementAnnotationsManagerImpl(getProject()) {
@Override
protected InspectionProfile getInspectionProfile(final DomFileElement fileElement) {
return myInspectionProfile;
}
};
final XmlFile file = createXmlFile("<a/>");
final MockDomElement rootElement = new MockDomElement() {
@Override
@Nullable
public XmlElement getXmlElement() {
return getXmlTag();
}
@Override
public XmlTag getXmlTag() {
return file.getRootTag();
}
@NotNull
@Override
public Type getDomElementType() {
return DomElement.class;
}
};
myElement = new MockDomFileElement() {
@Override
@Nullable
public XmlElement getXmlElement() {
return file;
}
@Override
@NotNull
public XmlFile getFile() {
return file;
}
@Override
public DomElement getParent() {
return null;
}
@Override
@NotNull
public DomElement getRootElement() {
return rootElement;
}
@NotNull
@Override
public Class getRootElementClass() {
return DomElement.class;
}
@Override
public boolean isValid() {
return true;
}
};
}
use of com.intellij.codeInspection.InspectionProfile in project intellij-community by JetBrains.
the class XmlTagInsertHandler method addRequiredAttributes.
@Nullable
private static StringBuilder addRequiredAttributes(XmlElementDescriptor descriptor, @Nullable XmlTag tag, Template template, PsiFile containingFile) {
boolean htmlCode = HtmlUtil.hasHtml(containingFile) || HtmlUtil.supportsXmlTypedHandlers(containingFile);
Set<String> notRequiredAttributes = Collections.emptySet();
if (tag instanceof HtmlTag) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getCurrentProfile();
XmlEntitiesInspection inspection = (XmlEntitiesInspection) profile.getUnwrappedTool(XmlEntitiesInspection.REQUIRED_ATTRIBUTES_SHORT_NAME, tag);
if (inspection != null) {
StringTokenizer tokenizer = new StringTokenizer(inspection.getAdditionalEntries());
notRequiredAttributes = new HashSet<>();
while (tokenizer.hasMoreElements()) notRequiredAttributes.add(tokenizer.nextToken());
}
}
XmlAttributeDescriptor[] attributes = descriptor.getAttributesDescriptors(tag);
StringBuilder indirectRequiredAttrs = null;
if (WebEditorOptions.getInstance().isAutomaticallyInsertRequiredAttributes()) {
final XmlExtension extension = XmlExtension.getExtension(containingFile);
for (XmlAttributeDescriptor attributeDecl : attributes) {
String attributeName = attributeDecl.getName(tag);
boolean shouldBeInserted = extension.shouldBeInserted(attributeDecl);
if (shouldBeInserted && (tag == null || tag.getAttributeValue(attributeName) == null)) {
if (!notRequiredAttributes.contains(attributeName)) {
if (!extension.isIndirectSyntax(attributeDecl)) {
template.addTextSegment(" " + attributeName + "=" + XmlAttributeInsertHandler.getAttributeQuote(htmlCode));
template.addVariable(new MacroCallNode(new CompleteMacro()), true);
template.addTextSegment(XmlAttributeInsertHandler.getAttributeQuote(htmlCode));
} else {
if (indirectRequiredAttrs == null)
indirectRequiredAttrs = new StringBuilder();
indirectRequiredAttrs.append("\n<jsp:attribute name=\"").append(attributeName).append("\"></jsp:attribute>\n");
}
}
} else if (shouldBeInserted && attributeDecl.isFixed() && attributeDecl.getDefaultValue() != null && !htmlCode) {
template.addTextSegment(" " + attributeName + "=" + XmlAttributeInsertHandler.getAttributeQuote(false) + attributeDecl.getDefaultValue() + XmlAttributeInsertHandler.getAttributeQuote(false));
}
}
}
return indirectRequiredAttrs;
}
use of com.intellij.codeInspection.InspectionProfile in project intellij-community by JetBrains.
the class PyCompatibilityInspectionAdvertiser method isCompatibilityInspectionEnabled.
private static boolean isCompatibilityInspectionEnabled(@NotNull PsiElement anchor) {
final InspectionProfile profile = InspectionProfileManager.getInstance(anchor.getProject()).getCurrentProfile();
final InspectionToolWrapper tool = profile.getInspectionTool(getCompatibilityInspectionShortName(), anchor.getProject());
return tool != null && profile.isToolEnabled(HighlightDisplayKey.findById(tool.getID()), anchor);
}
Aggregations