mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: allow to disable in editor problem highlighting
GitOrigin-RevId: aab198ae69ef7e208260cfe90128c4062aadcfb0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3a0ee456a8
commit
6b36d4a30f
+49
@@ -485,6 +485,9 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
|
||||
@Override
|
||||
public boolean shouldShowProblem(HighlightInfo highlightInfo, PsiFile file) {
|
||||
if (!Registry.is("ssr.in.editor.problem.highlighting")) {
|
||||
return false;
|
||||
}
|
||||
if (highlightInfo.getSeverity() != HighlightSeverity.ERROR && highlightInfo.getSeverity() != HighlightSeverity.INFORMATION) {
|
||||
return false;
|
||||
}
|
||||
@@ -572,6 +575,10 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
public void checkSearchPattern(CompiledPattern pattern) {
|
||||
final ValidatingVisitor visitor = new ValidatingVisitor();
|
||||
final NodeIterator nodes = pattern.getNodes();
|
||||
if (pattern.getNodeCount() == 1 && (
|
||||
nodes.current() instanceof PsiExpressionStatement || nodes.current() instanceof PsiDeclarationStatement)) {
|
||||
visitor.setCurrent(nodes.current());
|
||||
}
|
||||
while (nodes.hasNext()) {
|
||||
nodes.current().accept(visitor);
|
||||
nodes.advance();
|
||||
@@ -593,6 +600,9 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
final boolean replaceIsExpression = statements2.length == 1 && statements2[0].getLastChild() instanceof PsiErrorElement;
|
||||
|
||||
final ValidatingVisitor visitor = new ValidatingVisitor();
|
||||
if (statements2.length == 1 && (statements2[0] instanceof PsiExpressionStatement || statements2[0] instanceof PsiDeclarationStatement)) {
|
||||
visitor.setCurrent(statements2[0]);
|
||||
}
|
||||
for (PsiElement statement : statements2) {
|
||||
statement.accept(visitor);
|
||||
}
|
||||
@@ -617,6 +627,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
}
|
||||
|
||||
static class ValidatingVisitor extends JavaRecursiveElementWalkingVisitor {
|
||||
private PsiElement myCurrent;
|
||||
|
||||
@Override public void visitAnnotation(PsiAnnotation annotation) {
|
||||
super.visitAnnotation(annotation);
|
||||
@@ -642,6 +653,44 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
throw new MalformedPatternException(SSRBundle.message("invalid.modifier.type",name));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
super.visitErrorElement(element);
|
||||
if (Registry.is("ssr.in.editor.problem.highlighting") && Registry.is("ssr.use.new.search.dialog")) {
|
||||
return;
|
||||
}
|
||||
final PsiElement parent = element.getParent();
|
||||
final String errorDescription = element.getErrorDescription();
|
||||
if (parent instanceof PsiClass && "Identifier expected".equals(errorDescription)) {
|
||||
// other class content variable.
|
||||
return;
|
||||
}
|
||||
if (parent instanceof PsiTryStatement && "'catch' or 'finally' expected".equals(errorDescription)) {
|
||||
// searching for naked try allowed
|
||||
return;
|
||||
}
|
||||
if (parent == myCurrent) {
|
||||
// search for expression, type, annotation or symbol
|
||||
if ("';' expected".equals(errorDescription) && element.getNextSibling() == null) {
|
||||
// expression
|
||||
return;
|
||||
}
|
||||
if ("Identifier or type expected".equals(errorDescription)) {
|
||||
// annotation
|
||||
return;
|
||||
}
|
||||
if ("Identifier expected".equals(errorDescription)) {
|
||||
// type
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new MalformedPatternException(errorDescription);
|
||||
}
|
||||
|
||||
void setCurrent(PsiElement current) {
|
||||
myCurrent = current;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user