use of com.intellij.codeInspection.LocalQuickFix in project intellij-community by JetBrains.
the class HtmlUnknownAttributeInspectionBase method checkAttribute.
@Override
protected void checkAttribute(@NotNull final XmlAttribute attribute, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
final XmlTag tag = attribute.getParent();
if (tag instanceof HtmlTag) {
XmlElementDescriptor elementDescriptor = tag.getDescriptor();
if (elementDescriptor == null || elementDescriptor instanceof AnyXmlElementDescriptor) {
return;
}
XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor(attribute);
if (attributeDescriptor == null && !attribute.isNamespaceDeclaration()) {
final String name = attribute.getName();
if (!XmlUtil.attributeFromTemplateFramework(name, tag) && (!isCustomValuesEnabled() || !isCustomValue(name))) {
boolean maySwitchToHtml5 = HtmlUtil.isCustomHtml5Attribute(name) && !HtmlUtil.hasNonHtml5Doctype(tag);
LocalQuickFix[] quickfixes = new LocalQuickFix[maySwitchToHtml5 ? 3 : 2];
quickfixes[0] = new AddCustomHtmlElementIntentionAction(ATTRIBUTE_KEY, name, XmlBundle.message("add.custom.html.attribute", name));
quickfixes[1] = new RemoveAttributeIntentionAction(name);
if (maySwitchToHtml5) {
quickfixes[2] = new SwitchToHtml5WithHighPriorityAction();
}
registerProblemOnAttributeName(attribute, XmlErrorMessages.message("attribute.is.not.allowed.here", attribute.getName()), holder, quickfixes);
}
}
}
}
use of com.intellij.codeInspection.LocalQuickFix in project android by JetBrains.
the class ResourceReferenceConverter method getQuickFixes.
@Override
public LocalQuickFix[] getQuickFixes(ConvertContext context) {
AndroidFacet facet = AndroidFacet.getInstance(context);
if (facet != null) {
final DomElement domElement = context.getInvocationElement();
if (domElement instanceof GenericDomValue) {
final String value = ((GenericDomValue) domElement).getStringValue();
if (value != null) {
ResourceValue resourceValue = ResourceValue.parse(value, false, myWithPrefix, true);
if (resourceValue != null) {
String aPackage = resourceValue.getNamespace();
ResourceType resType = resourceValue.getType();
if (resType == null && myResourceTypes.size() == 1) {
resType = myResourceTypes.iterator().next();
}
final String resourceName = resourceValue.getResourceName();
if (aPackage == null && resType != null && resourceName != null && AndroidResourceUtil.isCorrectAndroidResourceName(resourceName)) {
final List<LocalQuickFix> fixes = new ArrayList<>();
ResourceFolderType folderType = AndroidResourceUtil.XML_FILE_RESOURCE_TYPES.get(resType);
if (folderType != null) {
fixes.add(new CreateFileResourceQuickFix(facet, folderType, resourceName, context.getFile(), false));
}
if (VALUE_RESOURCE_TYPES.contains(resType) && resType != ResourceType.LAYOUT) {
// layouts: aliases only
fixes.add(new CreateValueResourceQuickFix(facet, resType, resourceName, context.getFile(), false));
}
return fixes.toArray(new LocalQuickFix[fixes.size()]);
}
}
}
}
}
return LocalQuickFix.EMPTY_ARRAY;
}
use of com.intellij.codeInspection.LocalQuickFix in project intellij-plugins by JetBrains.
the class FlexUnitMethodReturnTypeInspection method visitPotentialTestMethod.
protected void visitPotentialTestMethod(JSFunction method, ProblemsHolder holder, FlexUnitSupport support) {
if (FlexUnitSupport.getCustomRunner((JSClass) method.getParent()) != null)
return;
if (method.getKind() != JSFunction.FunctionKind.SIMPLE)
return;
if (support.isFlexUnit1Subclass((JSClass) method.getParent()) || support.isFlunitSubclass((JSClass) method.getParent())) {
return;
}
final JSType returnType = method.getReturnType();
if (returnType != null && !(returnType instanceof JSVoidType)) {
final ASTNode nameIdentifier = method.findNameIdentifier();
if (nameIdentifier != null) {
LocalQuickFix[] fix = canFix(method) ? new LocalQuickFix[] { new ChangeTypeFix(method, "void", "javascript.fix.set.method.return.type") } : LocalQuickFix.EMPTY_ARRAY;
holder.registerProblem(nameIdentifier.getPsi(), FlexBundle.message("flexunit.inspection.testmethodreturntype.message"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fix);
}
}
}
use of com.intellij.codeInspection.LocalQuickFix in project intellij-plugins by JetBrains.
the class ActionMethodConverter method getQuickFixes.
public LocalQuickFix[] getQuickFixes(final ConvertContext context) {
final Action action = getActionElement(context);
final String methodName = action.getMethod().getStringValue();
final PsiClass actionClass = action.searchActionClass();
return new LocalQuickFix[] { new CreateActionMethodQuickFix(actionClass, methodName) };
}
Aggregations