mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more precise external annotation range for multiline elements (PY-8614)
This commit is contained in:
@@ -17,6 +17,7 @@ import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
@@ -155,16 +156,20 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
}
|
||||
}
|
||||
if (problemElement != null) {
|
||||
TextRange problemRange = problemElement.getTextRange();
|
||||
if (StringUtil.offsetToLineNumber(text, problemRange.getStartOffset()) != StringUtil.offsetToLineNumber(text, problemRange.getEndOffset())) {
|
||||
problemRange = new TextRange(offset, StringUtil.lineColToOffset(text, problem.myLine, 0)-1);
|
||||
}
|
||||
final Annotation annotation;
|
||||
final String message = "PEP 8: " + problem.myDescription;
|
||||
if (annotationResult.level == HighlightDisplayLevel.ERROR) {
|
||||
annotation = holder.createErrorAnnotation(problemElement, message);
|
||||
annotation = holder.createErrorAnnotation(problemRange, message);
|
||||
}
|
||||
else if (annotationResult.level == HighlightDisplayLevel.WARNING) {
|
||||
annotation = holder.createWarningAnnotation(problemElement, message);
|
||||
annotation = holder.createWarningAnnotation(problemRange, message);
|
||||
}
|
||||
else {
|
||||
annotation = holder.createWeakWarningAnnotation(problemElement, message);
|
||||
annotation = holder.createWeakWarningAnnotation(problemRange, message);
|
||||
}
|
||||
annotation.registerUniversalFix(new ReformatFix(), null, null);
|
||||
annotation.registerFix(new IgnoreErrorFix(problem.myCode, annotationResult.ignoredErrors));
|
||||
|
||||
Reference in New Issue
Block a user