mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-130071 (SSR incorrectly says pattern does not match anything in selected scope)
This commit is contained in:
+25
-1
@@ -436,7 +436,31 @@ public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor {
|
||||
|
||||
|
||||
private void handleReference(PsiJavaCodeReferenceElement reference) {
|
||||
handleReferenceText(reference.getReferenceName(), myCompilingVisitor.getContext());
|
||||
if (shouldOccur(reference)) {
|
||||
handleReferenceText(reference.getReferenceName(), myCompilingVisitor.getContext());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldOccur(PsiJavaCodeReferenceElement reference) {
|
||||
final CompileContext compileContext = myCompilingVisitor.getContext();
|
||||
final PsiElement parent = reference.getParent();
|
||||
if (!(parent instanceof PsiReferenceList)) {
|
||||
return true;
|
||||
}
|
||||
final PsiElement grandParent = parent.getParent();
|
||||
if (!(grandParent instanceof PsiMethod)) {
|
||||
return true;
|
||||
}
|
||||
final PsiMethod method = (PsiMethod)grandParent;
|
||||
if (method.getThrowsList() != parent) {
|
||||
return true;
|
||||
}
|
||||
final String name = method.getName();
|
||||
if (!compileContext.getPattern().isTypedVar(name)) {
|
||||
return true;
|
||||
}
|
||||
final SubstitutionHandler handler = (SubstitutionHandler)compileContext.getPattern().getHandler(name);
|
||||
return !(handler != null && handler.getMinOccurs() == 0);
|
||||
}
|
||||
|
||||
private static void handleReferenceText(String refname, CompileContext compileContext) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class TestModeOptimizingSearchHelper extends OptimizingSearchHelperBase {
|
||||
}
|
||||
|
||||
protected void doAddSearchWordInCode(final String refname) {
|
||||
append(refname, "reserved in code:");
|
||||
append(refname, "in code:");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-8
@@ -1,18 +1,22 @@
|
||||
package com.intellij.structuralsearch;
|
||||
|
||||
import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler;
|
||||
import com.intellij.idea.Bombed;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author Maxim.Mossienko
|
||||
*/
|
||||
@Bombed(day = 28, description = "support it", month = Calendar.JULY, user = "maxim.mossienko")
|
||||
public abstract class OptimizedSearchScanTest extends StructuralSearchTestCase {
|
||||
public void _testClassByQName() throws Exception {
|
||||
String plan = findWordsToBeUsedWhenSearchingFor("A.f");
|
||||
assertEquals("[in code:f]", plan);
|
||||
public class OptimizedSearchScanTest extends StructuralSearchTestCase {
|
||||
|
||||
public void testClassByQName() throws Exception {
|
||||
final String plan = findWordsToBeUsedWhenSearchingFor("A.f");
|
||||
assertEquals("[in code:f][in code:A]", plan);
|
||||
}
|
||||
|
||||
public void testOptionalMethodWithThrowsClause() {
|
||||
final String plan = findWordsToBeUsedWhenSearchingFor("class C {" +
|
||||
" void 'm{0,1} () throws OMGWTFBBQException {}" +
|
||||
"}");
|
||||
assertEquals("exception should not be in plan", "[in code:C]", plan);
|
||||
}
|
||||
|
||||
private String findWordsToBeUsedWhenSearchingFor(final String s) {
|
||||
|
||||
Reference in New Issue
Block a user