Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
c150b3d1
Commit
c150b3d1
authored
6 years ago
by
Bas Leijdekkers
1
Browse files
Options
Download
Email Patches
Plain Diff
SSR: don't try to match when there are no more pattern nodes (EA-120394, IDEA-197743)
parent
3d777dc8
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SubstitutionHandler.java
+2
-2
...uralsearch/impl/matcher/handlers/SubstitutionHandler.java
platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
+14
-2
...e/com/intellij/structuralsearch/StructuralSearchTest.java
with
16 additions
and
4 deletions
+16
-4
platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SubstitutionHandler.java
+
2
-
2
View file @
c150b3d1
// Copyright 2000-201
8
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-201
9
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.dupLocator.iterators.FilteringNodeIterator
;
...
...
@@ -373,7 +373,7 @@ public class SubstitutionHandler extends MatchingHandler {
if
(
patternNodes
.
hasNext
())
{
final
MatchingHandler
nextHandler
=
context
.
getPattern
().
getHandler
(
patternNodes
.
current
());
while
(
matchedOccurs
>=
minOccurs
)
{
while
(
matchedOccurs
>=
minOccurs
&&
patternNodes
.
hasNext
()
)
{
if
(
nextHandler
.
matchSequentially
(
patternNodes
,
matchNodes
,
context
))
{
totalMatchedOccurs
=
matchedOccurs
;
// match found
...
...
This diff is collapsed.
Click to expand it.
platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
+
14
-
2
View file @
c150b3d1
...
...
@@ -2384,13 +2384,18 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
"}"
+
"interface ABC {"
+
" void m();"
+
"}"
+
"interface KLM {"
+
"}"
+
"interface I {"
+
" void m();"
+
"}"
;
String
pattern1
=
"interface '_Class { default '_ReturnType 'MethodName+('_ParameterType '_Parameter*);}"
;
assertEquals
(
"should find default method"
,
1
,
findMatchesCount
(
source
,
pattern1
));
String
pattern2
=
"interface 'Class { default '_ReturnType '_MethodName{0,0}('_ParameterType '_Parameter*);}"
;
assertEquals
(
"should find interface without default methods"
,
1
,
findMatchesCount
(
source
,
pattern2
));
assertEquals
(
"should find interface without default methods"
,
3
,
findMatchesCount
(
source
,
pattern2
));
String
pattern3
=
"default '_ReturnType 'MethodName('_ParameterType '_Parameter*);"
;
assertEquals
(
"find naked default method"
,
1
,
findMatchesCount
(
source
,
pattern3
));
...
...
@@ -2423,6 +2428,14 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
assertEquals
(
"should find Runnable method references"
,
4
,
findMatchesCount
(
source
,
pattern5
));
}
public
void
testNoException
()
{
String
s
=
"class X {"
+
" void x(String[] tt, String[] ss, String s) {}"
+
"}"
;
assertEquals
(
"don't throw exception during matching"
,
0
,
findMatchesCount
(
s
,
"void '_Method('_ParameterType '_Parameter*, '_LastType[] '_lastParameter);"
));
}
public
void
testNoUnexpectedException
()
{
String
source
=
""
;
...
...
@@ -2444,7 +2457,6 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
findMatchesCount
(
source
,
pattern3
);
fail
(
"malformed pattern warning expected"
);
}
catch
(
MalformedPatternException
ignored
)
{}
}
public
void
testInvalidPatternWarnings
()
{
...
...
This diff is collapsed.
Click to expand it.
小 白蛋
@baidan
mentioned in commit
e6a82248
·
2 years ago
mentioned in commit
e6a82248
mentioned in commit e6a8224835d333581caf0f4035d0ed5e847283a4
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help