mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: fix matching method parameters in super classes (IDEA-193171)
This commit is contained in:
+10
-1
@@ -957,7 +957,16 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.matchOptionally(initializer, var2Initializer));
|
||||
}
|
||||
finally {
|
||||
myMatchingVisitor.scopeMatch(nameIdentifier, isTypedVar, var2.getNameIdentifier());
|
||||
final PsiIdentifier identifier = var2.getNameIdentifier();
|
||||
final String name;
|
||||
if (identifier == null && (name = var2.getName()) != null) {
|
||||
// when matching a stub or compiled code
|
||||
final PsiIdentifier fakeIdentifier = JavaPsiFacade.getElementFactory(var2.getProject()).createIdentifier(name);
|
||||
myMatchingVisitor.scopeMatch(nameIdentifier, isTypedVar, fakeIdentifier);
|
||||
}
|
||||
else {
|
||||
myMatchingVisitor.scopeMatch(nameIdentifier, isTypedVar, identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -2,11 +2,13 @@
|
||||
package com.intellij.structuralsearch;
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.plugin.ui.Configuration;
|
||||
import com.intellij.structuralsearch.plugin.ui.SearchConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -142,18 +144,26 @@ public class JavaPredefinedConfigurationsTest extends StructuralSearchTestCase {
|
||||
" <T extends U, V> X(int i) {}" +
|
||||
"}",
|
||||
"<T> X(String s) {}", "<T extends U, V> X(int i) {}");
|
||||
doTest(configurationMap.remove(SSRBundle.message("predefined.configuration.all.methods.of.the.class.within.hierarchy")),
|
||||
"class X {}",
|
||||
PsiElement::getText,
|
||||
"registerNatives", "getClass", "hashCode", "equals", "clone", "toString", "notify", "notifyAll", "wait", "wait", "wait", "finalize");
|
||||
//assertTrue("untested configurations: " + configurationMap.keySet(), configurationMap.isEmpty());
|
||||
}
|
||||
|
||||
private void doTest(Configuration template, String source, String... results) {
|
||||
doTest(template, source, e -> StructuralSearchUtil.getPresentableElement(e).getText(), results);
|
||||
}
|
||||
|
||||
private void doTest(Configuration template, String source, Function<? super PsiElement, String> resultConverter, String... expectedResults) {
|
||||
if (!(template instanceof SearchConfiguration)) fail();
|
||||
final SearchConfiguration searchConfiguration = (SearchConfiguration)template;
|
||||
options = searchConfiguration.getMatchOptions();
|
||||
final List<MatchResult> matches = testMatcher.testFindMatches(source, options, true, StdFileTypes.JAVA, null, false);
|
||||
assertEquals(template.getName(), results.length, matches.size());
|
||||
for (int i = 0; i < matches.size(); i++) {
|
||||
final String matchText = StructuralSearchUtil.getPresentableElement(matches.get(i).getMatch()).getText();
|
||||
assertEquals(template.getName(), results[i], matchText);
|
||||
assertEquals(template.getName(), expectedResults.length, matches.size());
|
||||
String[] actualResults = matches.stream().map(MatchResult::getMatch).map(resultConverter).toArray(String[]::new);
|
||||
for (int i = 0; i < actualResults.length; i++) {
|
||||
assertEquals(template.getName(), expectedResults[i], actualResults[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user