本文整理汇总了Java中com.intellij.codeInsight.daemon.impl.HighlightInfoType.WARNING属性的典型用法代码示例。如果您正苦于以下问题:Java HighlightInfoType.WARNING属性的具体用法?Java HighlightInfoType.WARNING怎么用?Java HighlightInfoType.WARNING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.codeInsight.daemon.impl.HighlightInfoType
的用法示例。
在下文中一共展示了HighlightInfoType.WARNING属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTagProblemInfoType
private static HighlightInfoType getTagProblemInfoType(XmlTag tag) {
if (tag instanceof HtmlTag && XmlUtil.HTML_URI.equals(tag.getNamespace())) {
if (isInjectedHtmlTagWithoutValidation((HtmlTag)tag)) return HighlightInfoType.INFORMATION;
return HighlightInfoType.WARNING;
}
return HighlightInfoType.WRONG_REF;
}
示例2: addMessageWithFixes
@Override
public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, @NotNull final IntentionAction... fixes) {
if (message != null && !message.isEmpty()) {
final PsiFile containingFile = context.getContainingFile();
final HighlightInfoType defaultInfoType = type == ErrorType.ERROR ? HighlightInfoType.ERROR : type == ErrorType.WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;
if (context instanceof XmlTag && XmlExtension.getExtension(containingFile).shouldBeHighlightedAsTag((XmlTag)context)) {
addElementsForTagWithManyQuickFixes((XmlTag)context, message, defaultInfoType, fixes);
}
else {
final PsiElement contextOfFile = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile);
final HighlightInfo highlightInfo;
if (contextOfFile != null) {
TextRange range = InjectedLanguageManager.getInstance(context.getProject()).injectedToHost(context, context.getTextRange());
highlightInfo = HighlightInfo.newHighlightInfo(defaultInfoType).range(range).descriptionAndTooltip(message).create();
}
else {
highlightInfo =
HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(context).descriptionAndTooltip(message).create();
}
for (final IntentionAction quickFixAction : fixes) {
if (quickFixAction == null) continue;
QuickFixAction.registerQuickFixAction(highlightInfo, quickFixAction);
}
addToResults(highlightInfo);
}
}
}
示例3: checkAttribute
private void checkAttribute(XmlAttribute attribute) {
XmlTag tag = attribute.getParent();
if (tag == null) return;
final String name = attribute.getName();
if (XmlExtension.getExtension(attribute.getContainingFile()).needWhitespaceBeforeAttribute()) {
PsiElement prevLeaf = PsiTreeUtil.prevLeaf(attribute);
if (!(prevLeaf instanceof PsiWhiteSpace)) {
TextRange textRange = attribute.getTextRange();
HighlightInfoType type = tag instanceof HtmlTag ? HighlightInfoType.WARNING : HighlightInfoType.ERROR;
String description = XmlErrorMessages.message("attribute.should.be.preceded.with.space");
HighlightInfo info = HighlightInfo.newHighlightInfo(type).range(textRange.getStartOffset(), textRange.getStartOffset()).descriptionAndTooltip(description).create();
addToResults(info);
}
}
if (attribute.isNamespaceDeclaration() || XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(attribute.getNamespace())) {
//checkReferences(attribute.getValueElement());
return;
}
XmlElementDescriptor elementDescriptor = tag.getDescriptor();
if (elementDescriptor == null ||
elementDescriptor instanceof AnyXmlElementDescriptor ||
ourDoJaxpTesting) {
return;
}
XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor(attribute);
if (attributeDescriptor == null) {
if (!XmlUtil.attributeFromTemplateFramework(name, tag)) {
final String localizedMessage = XmlErrorMessages.message("attribute.is.not.allowed.here", name);
final HighlightInfo highlightInfo = reportAttributeProblem(tag, name, attribute, localizedMessage);
if (highlightInfo != null) {
PsiFile file = tag.getContainingFile();
if (file != null) {
for (XmlUndefinedElementFixProvider fixProvider : Extensions.getExtensions(XmlUndefinedElementFixProvider.EP_NAME)) {
IntentionAction[] fixes = fixProvider.createFixes(attribute);
if (fixes != null) {
for (IntentionAction action : fixes) {
QuickFixAction.registerQuickFixAction(highlightInfo, action);
}
break;
}
}
}
}
}
}
else {
checkDuplicateAttribute(tag, attribute);
// we skip resolve of attribute references since there is separate check when taking attribute descriptors
PsiReference[] attrRefs = attribute.getReferences();
doCheckRefs(attribute, attrRefs, !attribute.getNamespacePrefix().isEmpty() ? 2 : 1);
}
}
示例4: doCheckRefs
private void doCheckRefs(final PsiElement value, final PsiReference[] references, int start) {
for (int i = start; i < references.length; ++i) {
PsiReference reference = references[i];
ProgressManager.checkCanceled();
if (isUrlReference(reference)) continue;
if (!hasBadResolve(reference, false)) {
continue;
}
String description = getErrorDescription(reference);
final int startOffset = reference.getElement().getTextRange().getStartOffset();
final TextRange referenceRange = reference.getRangeInElement();
// logging for IDEADEV-29655
if (referenceRange.getStartOffset() > referenceRange.getEndOffset()) {
LOG.error("Reference range start offset > end offset: " + reference +
", start offset: " + referenceRange.getStartOffset() + ", end offset: " + referenceRange.getEndOffset());
}
HighlightInfoType type = getTagProblemInfoType(PsiTreeUtil.getParentOfType(value, XmlTag.class));
if (value instanceof XmlAttributeValue) {
PsiElement parent = value.getParent();
if (parent instanceof XmlAttribute) {
String name = ((XmlAttribute)parent).getName().toLowerCase();
if (type.getSeverity(null).compareTo(HighlightInfoType.WARNING.getSeverity(null)) > 0 && name.endsWith("stylename")) {
type = HighlightInfoType.WARNING;
}
}
}
HighlightInfo info = HighlightInfo.newHighlightInfo(type)
.range(startOffset + referenceRange.getStartOffset(), startOffset + referenceRange.getEndOffset())
.descriptionAndTooltip(description).create();
addToResults(info);
if (reference instanceof LocalQuickFixProvider) {
LocalQuickFix[] fixes = ((LocalQuickFixProvider)reference).getQuickFixes();
if (fixes != null) {
InspectionManager manager = InspectionManager.getInstance(reference.getElement().getProject());
for (LocalQuickFix fix : fixes) {
ProblemDescriptor descriptor = manager.createProblemDescriptor(value, description, fix,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true);
QuickFixAction.registerQuickFixAction(info, new LocalQuickFixAsIntentionAdapter(fix, descriptor));
}
}
}
UnresolvedReferenceQuickFixProvider.registerReferenceFixes(reference, new QuickFixActionRegistrarImpl(info));
}
}