mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: fix exception on invalid search template (IDEA-259106)
GitOrigin-RevId: 2baa413344e36389a2614407417f18f8a913f765
This commit is contained in:
committed by
intellij-monorepo-bot
parent
247f4ac865
commit
d9a5f3609d
+4
-4
@@ -1,13 +1,10 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.structuralsearch.impl.matcher.handlers;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Handler for statement search
|
||||
*/
|
||||
public class StatementHandler extends MatchingHandler {
|
||||
|
||||
@Override
|
||||
@@ -16,6 +13,9 @@ public class StatementHandler extends MatchingHandler {
|
||||
// typed statement matches statements (including block statements) and comments
|
||||
return false;
|
||||
}
|
||||
if (!(patternNode instanceof PsiExpressionStatement)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiExpression expression = ((PsiExpressionStatement)patternNode).getExpression();
|
||||
return context.getMatcher().match(expression, matchedNode);
|
||||
|
||||
+10
@@ -2591,6 +2591,16 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
"}";
|
||||
assertEquals("don't throw exception during matching", 0,
|
||||
findMatchesCount(s, "void '_Method('_ParameterType '_Parameter*, '_LastType[] '_lastParameter);"));
|
||||
|
||||
String s2 = "class X {" +
|
||||
" void x() {" +
|
||||
" x();" +
|
||||
" }" +
|
||||
"}";
|
||||
assertEquals("don't throw exception during matching", 0,
|
||||
findMatchesCount(s2, "void '_x() {\n" +
|
||||
" '_x;\n" +
|
||||
"}"));
|
||||
}
|
||||
|
||||
public void testNoUnexpectedException() {
|
||||
|
||||
Reference in New Issue
Block a user