mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java inspection: When the element to be processed by information-level inspections is a whitespace process the nearest previous non-space element instead. (IDEA-157727)
This commit is contained in:
+12
-3
@@ -47,7 +47,6 @@ import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
|
||||
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -314,7 +313,17 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
if (HighlightingLevelManager.getInstance(project).shouldInspect(hostFile)) {
|
||||
collectIntentionsFromDoNotShowLeveledInspections(project, hostFile, psiElement, offset, intentions);
|
||||
PsiElement adjustedElement = psiElement;
|
||||
int adjustedOffset = offset;
|
||||
if (psiElement instanceof PsiWhiteSpace) {
|
||||
final PsiElement prev = psiElement.getPrevSibling();
|
||||
if (prev != null) {
|
||||
adjustedElement = prev;
|
||||
final TextRange range = prev.getTextRange();
|
||||
adjustedOffset = range.isEmpty() ? range.getEndOffset() : range.getEndOffset() - 1;
|
||||
}
|
||||
}
|
||||
collectIntentionsFromDoNotShowLeveledInspections(project, hostFile, adjustedElement, adjustedOffset, intentions);
|
||||
}
|
||||
|
||||
final int line = hostDocument.getLineNumber(offset);
|
||||
@@ -377,7 +386,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
|
||||
super.registerProblem(problemDescriptor);
|
||||
if (problemDescriptor instanceof ProblemDescriptorBase) {
|
||||
final TextRange range = ((ProblemDescriptorBase)problemDescriptor).getTextRange();
|
||||
if (range != null && range.contains(offset)) {
|
||||
if (range != null && range.contains(offset)) { //add whitespace at the right
|
||||
final QuickFix[] fixes = problemDescriptor.getFixes();
|
||||
if (fixes != null) {
|
||||
for (int k = 0; k < fixes.length; k++) {
|
||||
|
||||
Reference in New Issue
Block a user