mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
less spam in the logs when there's PSI/document inconsistency during reference search (IDEA-115950)
This commit is contained in:
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -39,10 +38,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class LowLevelSearchUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.search.LowLevelSearchUtil");
|
||||
|
||||
private LowLevelSearchUtil() {
|
||||
}
|
||||
|
||||
// TRUE/FALSE -> injected psi has been discovered and processor returned true/false;
|
||||
// null -> there were nothing injected found
|
||||
@@ -95,7 +90,7 @@ public class LowLevelSearchUtil {
|
||||
start = offset - leafElement.getTextRange().getStartOffset() + scopeStartOffset;
|
||||
}
|
||||
if (start < 0) {
|
||||
LOG.error("offset=" + offset + " scopeStartOffset=" + scopeStartOffset + " leafElement=" + leafElement + " scope=" + scope);
|
||||
throw new AssertionError("offset=" + offset + " scopeStartOffset=" + scopeStartOffset + " leafElement=" + leafElement + " scope=" + scope);
|
||||
}
|
||||
boolean contains = false;
|
||||
PsiElement prev = null;
|
||||
@@ -159,7 +154,7 @@ public class LowLevelSearchUtil {
|
||||
int startOffset = scopeStart;
|
||||
int endOffset = range.getEndOffset();
|
||||
if (endOffset > buffer.length()) {
|
||||
LOG.error("Range for element: '"+scope+"' = "+range+" is out of file '" + file + "' range: " + file.getTextLength());
|
||||
throw new AssertionError("Range for element: '"+scope+"' = "+range+" is out of file '" + file + "' range: " + file.getTextLength());
|
||||
}
|
||||
|
||||
final char[] bufferArray = CharArrayUtil.fromSequenceWithoutCopying(buffer);
|
||||
@@ -194,7 +189,9 @@ public class LowLevelSearchUtil {
|
||||
int endOffset,
|
||||
@NotNull StringSearcher searcher,
|
||||
@Nullable ProgressIndicator progress) {
|
||||
LOG.assertTrue(endOffset <= text.length());
|
||||
if (endOffset > text.length()) {
|
||||
throw new AssertionError("end>length");
|
||||
}
|
||||
|
||||
for (int index = startOffset; index < endOffset; index++) {
|
||||
if (progress != null) progress.checkCanceled();
|
||||
|
||||
@@ -86,9 +86,13 @@ public class StringSearcher {
|
||||
}
|
||||
|
||||
public int scan(@NotNull CharSequence text, @Nullable char[] textArray, int _start, int _end) {
|
||||
LOG.assertTrue(_start <= _end, _start - _end);
|
||||
if (_start > _end) {
|
||||
throw new AssertionError("start > end, " + _start + ">" + _end);
|
||||
}
|
||||
final int textLength = text.length();
|
||||
LOG.assertTrue(_end <= textLength, textLength - _end);
|
||||
if (_end > textLength) {
|
||||
throw new AssertionError("end > length, " + _end + ">" + textLength);
|
||||
}
|
||||
if (myForwardDirection) {
|
||||
if (myPatternLength == 1) {
|
||||
// optimization
|
||||
@@ -99,14 +103,14 @@ public class StringSearcher {
|
||||
|
||||
while (start <= end) {
|
||||
int i = myPatternLength - 1;
|
||||
char lastChar = textArray != null ? textArray[start + i]:text.charAt(start + i);
|
||||
char lastChar = textArray != null ? textArray[start + i] : text.charAt(start + i);
|
||||
if (!myCaseSensitive) {
|
||||
lastChar = StringUtil.toLowerCase(lastChar);
|
||||
}
|
||||
if (myPatternArray[i] == lastChar) {
|
||||
i--;
|
||||
while (i >= 0) {
|
||||
char c = textArray != null ? textArray[start + i]:text.charAt(start + i);
|
||||
char c = textArray != null ? textArray[start + i] : text.charAt(start + i);
|
||||
if (!myCaseSensitive) {
|
||||
c = StringUtil.toLowerCase(c);
|
||||
}
|
||||
@@ -135,17 +139,17 @@ public class StringSearcher {
|
||||
}
|
||||
else {
|
||||
int start = 1;
|
||||
int end = _end+1;
|
||||
int end = _end + 1;
|
||||
while (start <= end - myPatternLength + 1) {
|
||||
int i = myPatternLength - 1;
|
||||
char lastChar = textArray != null ? textArray[end - (start + i)]:text.charAt(end - (start + i));
|
||||
char lastChar = textArray != null ? textArray[end - (start + i)] : text.charAt(end - (start + i));
|
||||
if (!myCaseSensitive) {
|
||||
lastChar = StringUtil.toLowerCase(lastChar);
|
||||
}
|
||||
if (myPatternArray[myPatternLength - 1 - i] == lastChar) {
|
||||
i--;
|
||||
while (i >= 0) {
|
||||
char c = textArray != null ? textArray[end - (start + i)]:text.charAt(end - (start + i));
|
||||
char c = textArray != null ? textArray[end - (start + i)] : text.charAt(end - (start + i));
|
||||
if (!myCaseSensitive) {
|
||||
c = StringUtil.toLowerCase(c);
|
||||
}
|
||||
@@ -170,7 +174,6 @@ public class StringSearcher {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user