From 574e88701dbc0000fc187797b6ec1bdb90d9fd32 Mon Sep 17 00:00:00 2001 From: "Irina.Chernushina" Date: Fri, 5 May 2017 18:00:09 +0200 Subject: [PATCH] WEB-26756 ESLint: warning about new line character is now shown - fix in editor (correctly set "after end of line" for annotation) - fix the same issue for batch inspection run - tests for batch eslint run to test annotation -> problem descriptor conversion --- .../ExternalAnnotatorInspectionVisitor.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ExternalAnnotatorInspectionVisitor.java b/platform/analysis-impl/src/com/intellij/codeInspection/ExternalAnnotatorInspectionVisitor.java index f6beb7428985..60e12651cd79 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ExternalAnnotatorInspectionVisitor.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ExternalAnnotatorInspectionVisitor.java @@ -92,23 +92,32 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor { IdentityHashMap quickFixMappingCache = ContainerUtil.newIdentityHashMap(); for (Annotation annotation : annotations) { if (annotation.getSeverity() == HighlightSeverity.INFORMATION || - annotation.getStartOffset() == annotation.getEndOffset()) { + annotation.getStartOffset() == annotation.getEndOffset() && !annotation.isAfterEndOfLine()) { continue; } - final PsiElement startElement = file.findElementAt(annotation.getStartOffset()); - final PsiElement endElement = file.findElementAt(annotation.getEndOffset() - 1); + final PsiElement startElement; + final PsiElement endElement; + if (annotation.getStartOffset() == annotation.getEndOffset() && annotation.isAfterEndOfLine()) { + startElement = endElement = file.findElementAt(annotation.getEndOffset() - 1); + } else { + startElement = file.findElementAt(annotation.getStartOffset()); + endElement = file.findElementAt(annotation.getEndOffset() - 1); + } if (startElement == null || endElement == null) { continue; } LocalQuickFix[] quickFixes = toLocalQuickFixes(annotation.getQuickFixes(), quickFixMappingCache); - ProblemDescriptor descriptor = manager.createProblemDescriptor(startElement, + ProblemDescriptor descriptor = new ProblemDescriptorBase(startElement, endElement, annotation.getMessage(), + quickFixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, - false, - quickFixes); + annotation.isAfterEndOfLine(), + null, + true, + false); problems.add(descriptor); } return problems.toArray(new ProblemDescriptor[problems.size()]);