本文整理汇总了Java中com.intellij.lang.annotation.HighlightSeverity.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java HighlightSeverity.ERROR属性的具体用法?Java HighlightSeverity.ERROR怎么用?Java HighlightSeverity.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.lang.annotation.HighlightSeverity
的用法示例。
在下文中一共展示了HighlightSeverity.ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runXmlFileSchemaValidation
private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(@NotNull XmlFile xmlFile) {
final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));
final List<ExternalAnnotator> annotators = ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
for (ExternalAnnotator<?, ?> annotator : annotators) {
processAnnotator(xmlFile, holder, annotator);
}
if (!holder.hasAnnotations()) return Collections.emptyMap();
Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
for (final Annotation annotation : holder) {
final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
if (info.getSeverity() == HighlightSeverity.INFORMATION) continue;
final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
final PsiElement endElement = info.startOffset == info.endOffset ? startElement : xmlFile.findElementAt(info.endOffset - 1);
if (startElement == null || endElement == null) continue;
final ProblemDescriptor descriptor =
myInspectionManager.createProblemDescriptor(startElement, endElement, info.getDescription(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false);
final HighlightDisplayLevel level = info.getSeverity() == HighlightSeverity.ERROR? HighlightDisplayLevel.ERROR: HighlightDisplayLevel.WARNING;
problemsMap.put(descriptor, level);
}
return problemsMap;
}
示例2: 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);
}
示例3: convertToProblems
private static List<Problem> convertToProblems(@NotNull Collection<HighlightInfo> infos,
@NotNull VirtualFile file,
final boolean hasErrorElement) {
List<Problem> problems = new SmartList<Problem>();
for (HighlightInfo info : infos) {
if (info.getSeverity() == HighlightSeverity.ERROR) {
Problem problem = new ProblemImpl(file, info, hasErrorElement);
problems.add(problem);
}
}
return problems;
}
示例4: convertSeverity
@NotNull
public static HighlightInfoType convertSeverity(@NotNull HighlightSeverity severity) {
return severity == HighlightSeverity.ERROR? HighlightInfoType.ERROR :
severity == HighlightSeverity.WARNING ? HighlightInfoType.WARNING :
severity == HighlightSeverity.INFO ? HighlightInfoType.INFO :
severity == HighlightSeverity.WEAK_WARNING ? HighlightInfoType.WEAK_WARNING :
severity ==HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING ? HighlightInfoType.GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER :
HighlightInfoType.INFORMATION;
}
示例5: convertSeverityToProblemHighlight
@NotNull
public static ProblemHighlightType convertSeverityToProblemHighlight(HighlightSeverity severity) {
return severity == HighlightSeverity.ERROR ? ProblemHighlightType.ERROR :
severity == HighlightSeverity.WARNING ? ProblemHighlightType.GENERIC_ERROR_OR_WARNING :
severity == HighlightSeverity.INFO ? ProblemHighlightType.INFO :
severity == HighlightSeverity.WEAK_WARNING ? ProblemHighlightType.WEAK_WARNING : ProblemHighlightType.INFORMATION;
}
示例6: add
public boolean add(@Nullable HighlightInfo info) {
if (info == null || !accepted(info)) return false;
HighlightSeverity severity = info.getSeverity();
if (severity == HighlightSeverity.ERROR) {
myErrorCount++;
}
return myInfos.add(info);
}
示例7: collectErrors
private static int collectErrors(final List<CodeSmellInfo> codeSmells) {
int result = 0;
for (CodeSmellInfo codeSmellInfo : codeSmells) {
if (codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) result++;
}
return result;
}
示例8: getTextAttributeKey
protected static String getTextAttributeKey(@NotNull Project project,
@NotNull HighlightSeverity severity,
@NotNull ProblemHighlightType highlightType) {
if (highlightType == ProblemHighlightType.LIKE_DEPRECATED) {
return HighlightInfoType.DEPRECATED.getAttributesKey().getExternalName();
}
if (highlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL && severity == HighlightSeverity.ERROR) {
return HighlightInfoType.WRONG_REF.getAttributesKey().getExternalName();
}
if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
}
SeverityRegistrar registrar = InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar();
return registrar.getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
}
示例9: getUnresolvedHighlightSeverity
@Override
public HighlightSeverity getUnresolvedHighlightSeverity(TypeEvalContext context) {
if (isBuiltInConstant()) return null;
final PyExpression qualifier = myElement.getQualifier();
if (qualifier == null) {
return HighlightSeverity.ERROR;
}
if (context.getType(qualifier) != null) {
return HighlightSeverity.WARNING;
}
return null;
}
示例10: testMinSeverity
public void testMinSeverity() throws Throwable {
final MyElement element = createElement("<a/>", MyElement.class);
final DomElementsProblemsHolderImpl holder = new DomElementsProblemsHolderImpl(DomUtil.getFileElement(element));
final DomElementProblemDescriptorImpl error = new DomElementProblemDescriptorImpl(element, "abc", HighlightSeverity.ERROR);
final DomElementProblemDescriptorImpl warning = new DomElementProblemDescriptorImpl(element, "abc", HighlightSeverity.WARNING);
holder.addProblem(error, MockDomInspection.class);
holder.addProblem(warning, MockDomInspection.class);
assertEquals(Arrays.asList(error), holder.getProblems(element, true, true, HighlightSeverity.ERROR));
assertEquals(Arrays.asList(error, warning), holder.getProblems(element, true, true, HighlightSeverity.WARNING));
}
示例11: createAnnotation
@Override
public Annotation createAnnotation(T element, @NotNull HighlightSeverity severity, String message) {
if (severity == HighlightSeverity.ERROR) {
return myHolder.createErrorAnnotation(element, message);
} else if (severity == HighlightSeverity.WARNING) {
return myHolder.createWarningAnnotation(element, message);
} else if (severity == HighlightSeverity.WEAK_WARNING) {
return myHolder.createWeakWarningAnnotation(element, message);
} else {
return myHolder.createInfoAnnotation(element, message);
}
}
示例12: accept
/**
* Override to filter errors related to type incompatibilities arising from a
* manifold extension adding an interface to an existing classpath class (as opposed
* to a source file). Basically suppress "incompatible type errors" or similar
* involving a structural interface extension.
*/
@Override
public boolean accept( @NotNull HighlightInfo hi, @Nullable PsiFile file )
{
if( hi.getDescription() == null ||
hi.getSeverity() != HighlightSeverity.ERROR ||
file == null )
{
return true;
}
PsiElement firstElem = file.findElementAt( hi.getStartOffset() );
if( firstElem == null )
{
return true;
}
PsiElement elem = firstElem.getParent();
if( elem == null )
{
return true;
}
if( isInvalidStaticMethodOnInterface( hi ) )
{
PsiElement lhsType = ((PsiReferenceExpressionImpl)((PsiMethodCallExpressionImpl)elem.getParent()).getMethodExpression().getQualifierExpression()).resolve();
if( lhsType instanceof ManifoldPsiClass || lhsType instanceof ManifoldExtendedPsiClass )
{
PsiMethod psiMethod = ((PsiMethodCallExpressionImpl)elem.getParent()).resolveMethod();
if( psiMethod.getContainingClass().isInterface() )
{
// ignore "Static method may be invoked on containing interface class only" errors where the method really is directly on a the interface, albeit the delegate
return false;
}
}
return true;
}
//##
//## structural interface extensions cannot be added to the psiClass, so for now we suppress "incompatible type errors" or similar involving a structural interface extension.
//##
Boolean x = acceptInterfaceError( hi, firstElem, elem );
if( x != null ) return x;
return true;
}
示例13: getHighlightSeverity
private static HighlightSeverity getHighlightSeverity(Lint.Issue warn) {
return warn.severity.toLowerCase().equals("error") ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}
示例14: getHighlightSeverity
private static HighlightSeverity getHighlightSeverity(SassLint.Issue warn, boolean treatAsWarnings) {
if (treatAsWarnings) {
return HighlightSeverity.WARNING;
}
return warn.severity.equals("error") ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}
示例15: getActionsToShow
public static void getActionsToShow(@NotNull final Editor hostEditor,
@NotNull final PsiFile hostFile,
@NotNull final IntentionsInfo intentions,
int passIdToShowIntentionsFor) {
final PsiElement psiElement = hostFile.findElementAt(hostEditor.getCaretModel().getOffset());
LOG.assertTrue(psiElement == null || psiElement.isValid(), psiElement);
int offset = hostEditor.getCaretModel().getOffset();
final Project project = hostFile.getProject();
List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableActions(hostEditor, hostFile, passIdToShowIntentionsFor);
final DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
final Document hostDocument = hostEditor.getDocument();
HighlightInfo infoAtCursor = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(hostDocument, offset, true);
if (infoAtCursor == null) {
intentions.errorFixesToShow.addAll(fixes);
}
else {
final boolean isError = infoAtCursor.getSeverity() == HighlightSeverity.ERROR;
for (HighlightInfo.IntentionActionDescriptor fix : fixes) {
if (fix.isError() && isError) {
intentions.errorFixesToShow.add(fix);
}
else {
intentions.inspectionFixesToShow.add(fix);
}
}
}
for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
Pair<PsiFile, Editor> place =
ShowIntentionActionsHandler.chooseBetweenHostAndInjected(hostFile, hostEditor, new PairProcessor<PsiFile, Editor>() {
@Override
public boolean process(PsiFile psiFile, Editor editor) {
return ShowIntentionActionsHandler.availableFor(psiFile, editor, action);
}
});
if (place != null) {
List<IntentionAction> enableDisableIntentionAction = new ArrayList<IntentionAction>();
enableDisableIntentionAction.add(new IntentionHintComponent.EnableDisableIntentionAction(action));
enableDisableIntentionAction.add(new IntentionHintComponent.EditIntentionSettingsAction(action));
HighlightInfo.IntentionActionDescriptor descriptor = new HighlightInfo.IntentionActionDescriptor(action, enableDisableIntentionAction, null);
if (!fixes.contains(descriptor)) {
intentions.intentionsToShow.add(descriptor);
}
}
}
final int line = hostDocument.getLineNumber(offset);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(hostDocument, project, true);
CommonProcessors.CollectProcessor<RangeHighlighterEx> processor = new CommonProcessors.CollectProcessor<RangeHighlighterEx>();
model.processRangeHighlightersOverlappingWith(hostDocument.getLineStartOffset(line),
hostDocument.getLineEndOffset(line),
processor);
for (RangeHighlighterEx highlighter : processor.getResults()) {
GutterIntentionAction.addActions(project, hostEditor, hostFile, highlighter, intentions.guttersToShow);
}
boolean cleanup = appendCleanupCode(intentions.inspectionFixesToShow, hostFile);
if (!cleanup) {
appendCleanupCode(intentions.errorFixesToShow, hostFile);
}
}