本文整理汇总了Java中com.intellij.codeInsight.daemon.impl.HighlightInfoType.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java HighlightInfoType.ERROR属性的具体用法?Java HighlightInfoType.ERROR怎么用?Java HighlightInfoType.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.codeInsight.daemon.impl.HighlightInfoType
的用法示例。
在下文中一共展示了HighlightInfoType.ERROR属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: highlightTypeFromDescriptor
@NotNull
public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor,
@NotNull HighlightSeverity severity,
@NotNull SeverityRegistrar severityRegistrar) {
final ProblemHighlightType highlightType = problemDescriptor.getHighlightType();
switch (highlightType) {
case GENERIC_ERROR_OR_WARNING:
return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
case LIKE_DEPRECATED:
return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.DEPRECATED.getAttributesKey());
case LIKE_UNKNOWN_SYMBOL:
if (severity == HighlightSeverity.ERROR) {
return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.WRONG_REF.getAttributesKey());
}
if (severity == HighlightSeverity.WARNING) {
return new HighlightInfoType.HighlightInfoTypeImpl(severity, CodeInsightColors.WEAK_WARNING_ATTRIBUTES);
}
return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
case LIKE_UNUSED_SYMBOL:
return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
case INFO:
return HighlightInfoType.INFO;
case WEAK_WARNING:
return HighlightInfoType.WEAK_WARNING;
case ERROR:
return HighlightInfoType.WRONG_REF;
case GENERIC_ERROR:
return HighlightInfoType.ERROR;
case INFORMATION:
final TextAttributesKey attributes = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes();
if (attributes != null) {
return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, attributes);
}
return HighlightInfoType.INFORMATION;
}
throw new RuntimeException("Cannot map " + highlightType);
}
示例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: checkAmbiguousMethodCallIdentifier
@Nullable
static HighlightInfo checkAmbiguousMethodCallIdentifier(@NotNull PsiReferenceExpression referenceToMethod,
@NotNull JavaResolveResult[] resolveResults,
@NotNull PsiExpressionList list,
final PsiElement element,
@NotNull JavaResolveResult resolveResult,
@NotNull PsiMethodCallExpression methodCall,
@NotNull PsiResolveHelper resolveHelper) {
MethodCandidateInfo methodCandidate1 = null;
MethodCandidateInfo methodCandidate2 = null;
for (JavaResolveResult result : resolveResults) {
if (!(result instanceof MethodCandidateInfo)) continue;
MethodCandidateInfo candidate = (MethodCandidateInfo)result;
if (candidate.isApplicable() && !candidate.getElement().isConstructor()) {
if (methodCandidate1 == null) {
methodCandidate1 = candidate;
}
else {
methodCandidate2 = candidate;
break;
}
}
}
MethodCandidateInfo[] candidates = toMethodCandidates(resolveResults);
HighlightInfoType highlightInfoType = HighlightInfoType.ERROR;
if (methodCandidate2 != null) {
return null;
}
String description;
PsiElement elementToHighlight;
if (element != null && !resolveResult.isAccessible()) {
description = HighlightUtil.buildProblemWithAccessDescription(referenceToMethod, resolveResult);
elementToHighlight = referenceToMethod.getReferenceNameElement();
}
else if (element != null && !resolveResult.isStaticsScopeCorrect()) {
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(referenceToMethod);
final String staticInterfaceMethodMessage =
element instanceof PsiMethod
? LambdaUtil.getInvalidQualifier4StaticInterfaceMethodMessage((PsiMethod)element, referenceToMethod,
resolveResult.getCurrentFileResolveScope(), languageLevel)
: null;
description = staticInterfaceMethodMessage != null
? staticInterfaceMethodMessage
: HighlightUtil.buildProblemWithStaticDescription(element);
elementToHighlight = referenceToMethod.getReferenceNameElement();
}
else {
String methodName = referenceToMethod.getReferenceName() + buildArgTypesList(list);
description = JavaErrorMessages.message("cannot.resolve.method", methodName);
if (candidates.length == 0) {
elementToHighlight = referenceToMethod.getReferenceNameElement();
highlightInfoType = HighlightInfoType.WRONG_REF;
}
else {
return null;
}
}
String toolTip = XmlStringUtil.escapeString(description);
HighlightInfo info =
HighlightInfo.newHighlightInfo(highlightInfoType).range(elementToHighlight).description(description).escapedToolTip(toolTip).create();
registerMethodCallIntentions(info, methodCall, list, resolveHelper);
if (element != null && !resolveResult.isStaticsScopeCorrect()) {
HighlightUtil.registerStaticProblemQuickFixAction(element, info, referenceToMethod);
}
TextRange fixRange = getFixRange(elementToHighlight);
CastMethodArgumentFix.REGISTRAR.registerCastActions(candidates, methodCall, info, fixRange);
WrapArrayToArraysAsListFix.REGISTAR.registerCastActions(candidates, methodCall, info, fixRange);
PermuteArgumentsFix.registerFix(info, methodCall, candidates, fixRange);
WrapExpressionFix.registerWrapAction(candidates, list.getExpressions(), info);
registerChangeParameterClassFix(methodCall, list, info);
return info;
}
示例4: 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);
}
}
示例5: getHighlightInfoType
public HighlightInfoType getHighlightInfoType(XmlFile file) {
return HighlightInfoType.ERROR;
}