mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
SSR: report many more java pattern problems in search dialog (IDEA-126794)
This commit is contained in:
+3
-3
@@ -24,7 +24,7 @@ class JavaPredefinedConfigurations {
|
||||
// Expression patterns
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.method.calls"), "'_Instance?.'MethodCall('_Parameter*)", EXPRESSION_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.new.expressions"), "new 'Constructor('_Argument*)", EXPRESSION_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.lambdas"), "('_Parameter*) -> ", EXPRESSION_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.lambdas"), "('_Parameter*) -> {}", EXPRESSION_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.field.selections"),"'_Instance?.'Field",EXPRESSION_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.array.access"),"'_Field['_Index]",EXPRESSION_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.assignments"),"'_Inst = '_Expr",EXPRESSION_TYPE),
|
||||
@@ -279,8 +279,8 @@ class JavaPredefinedConfigurations {
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.fields.variables.read"),"'Symbol:[read]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.fields_variables.with.given.name.pattern.updated"),"'Symbol:[regex( name ) && write]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.usage.of.derived.type.in.cast"),"('CastType:*[regex( Base )]) '_Expr",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.declarations"),"'_Type:Object|Integer|Boolean|Long|Character|Short|Byte 'Var = '_Value:[exprtype( int|boolean|long|char|short|byte )]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.unboxing.in.declarations"),"'_Type:int|boolean|long|char|short|byte 'Var = '_Value:[exprtype( Integer|Boolean|Long|Character|Short|Byte )]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.declarations"),"'_Type:Object|Integer|Boolean|Long|Character|Short|Byte 'Var = '_Value:[exprtype( int|boolean|long|char|short|byte )];",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.unboxing.in.declarations"),"'_Type:int|boolean|long|char|short|byte 'Var = '_Value:[exprtype( Integer|Boolean|Long|Character|Short|Byte )];",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.method.calls"),"'_Instance?.'Call('_BeforeParam*,'_Param:[ exprtype( int|boolean|long|char|short|byte ) && formal( Object|Integer|Boolean|Long|Character|Short|Byte )],'_AfterParam*)",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.unboxing.in.method.calls"), "'_Instance?.'Call('_BeforeParam*,'_Param:[ formal( int|boolean|long|char|short|byte ) && exprtype( Integer|Boolean|Long|Character|Short|Byte )],'_AfterParam*)",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.any.boxing"), "'_expression:[ exprtype( int|boolean|long|char|short|byte ) && formal( Object|Integer|Boolean|Long|Character|Short|Byte )]", INTERESTING_TYPE),
|
||||
|
||||
+29
-6
@@ -407,13 +407,35 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
@Override
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
super.visitErrorElement(element);
|
||||
//final PsiElement parent = element.getParent();
|
||||
//if (parent != myCurrent || !"';' expected".equals(element.getErrorDescription())) {
|
||||
// throw new MalformedPatternException(element.getErrorDescription());
|
||||
//}
|
||||
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)) {
|
||||
// expression
|
||||
return;
|
||||
}
|
||||
if ("Identifier or type expected".equals(errorDescription)) {
|
||||
// annotation
|
||||
return;
|
||||
}
|
||||
if ("Identifier expected".equals(errorDescription)) {
|
||||
// type
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new MalformedPatternException(errorDescription);
|
||||
}
|
||||
|
||||
public void setCurrent(PsiElement current) {
|
||||
void setCurrent(PsiElement current) {
|
||||
myCurrent = current;
|
||||
}
|
||||
}
|
||||
@@ -423,7 +445,8 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
final NodeIterator nodes = compiledPattern.getNodes();
|
||||
while (nodes.hasNext()) {
|
||||
final PsiElement current = nodes.current();
|
||||
visitor.setCurrent(nodeCount == 1 && current instanceof PsiExpressionStatement ? current : null);
|
||||
visitor.setCurrent((nodeCount == 1 && (current instanceof PsiExpressionStatement|| current instanceof PsiDeclarationStatement))
|
||||
? current : null);
|
||||
current.accept(visitor);
|
||||
nodes.advance();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user