Skip to content

Commit 117b962

Browse files
committed
Fix testStringAnyStrings01 and 3 others
Signed-off-by: Rob Stryker <[email protected]>
1 parent fa7bd04 commit 117b962

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,18 @@ private IBinding resolveNameImpl(Name name) {
12071207
if (parameterizedType != null) {
12081208
return parameterizedType;
12091209
}
1210-
12111210
}
1211+
1212+
// IBinding ret = resolveNameToJavac(name, tree);
1213+
// if (ret != null) {
1214+
// return ret;
1215+
// }
1216+
//
1217+
// // That didn't work... checking field access
1218+
// IBinding fieldAccessBinding = this.getFieldAccessBinding(jcfa);
1219+
// if( fieldAccessBinding != null ) {
1220+
// return fieldAccessBinding;
1221+
// }
12121222
}
12131223
}
12141224
if( tree != null ) {

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/core/search/PatternLocatorVisitor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,17 @@ private boolean visitType(Type node) {
201201
@Override
202202
public boolean visit(SimpleType type) {
203203
visitType(type);
204+
LocatorResponse resp = defaultVisitImplementationWithFunc(type, (x,y) -> y.match(type, this.nodeSet, this.locator), DOMASTNodeUtils::getBinding);
204205
Name n = type.getName();
205206
if( n instanceof QualifiedName qn ) {
206207
Name qualifier = qn.getQualifier();
207-
if( qualifier instanceof SimpleName sn1 ) {
208-
sn1.accept(this);
209-
} else if( qualifier instanceof QualifiedName qn1) {
210-
qn1.accept(this);
208+
boolean replacementIsChild = resp.replacementNodeFound() && (resp.replacement() == qn.getQualifier() || resp.replacement() == qn.getName());
209+
if( !replacementIsChild ) {
210+
if( qualifier instanceof SimpleName sn1 ) {
211+
sn1.accept(this);
212+
} else if( qualifier instanceof QualifiedName qn1) {
213+
qn1.accept(this);
214+
}
211215
}
212216
}
213217
for (var ann : (List<Annotation>)type.annotations() ) {

org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchModuleImportTest.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package org.eclipse.jdt.core.tests.model;
1515

1616
import java.io.IOException;
17-
17+
import junit.framework.Test;
1818
import org.eclipse.core.runtime.CoreException;
1919
import org.eclipse.jdt.core.ICompilationUnit;
2020
import org.eclipse.jdt.core.IJavaProject;
@@ -28,8 +28,6 @@
2828
import org.eclipse.jdt.core.search.SearchMatch;
2929
import org.eclipse.jdt.core.search.SearchPattern;
3030

31-
import junit.framework.Test;
32-
3331
public class JavaSearchModuleImportTest extends AbstractJavaSearchTests {
3432

3533
public JavaSearchModuleImportTest(String name) {
@@ -88,6 +86,32 @@ public void testModuleImport() throws CoreException, IOException {
8886
lib/mod.one.jar mod.one [No source] EXACT_MATCH""");
8987
}
9088

89+
90+
/*
91+
* Fails on Javac.
92+
* Behavior diverges at DiskIndex.readCategoryTable
93+
* A lot of weird stuff happening in writeCategories.writeCategories
94+
* when the index is for /JavaSearchBugs23. The list of categories to write
95+
* is only 5 elements instead of 9 via jdt. The relevant missing entry is moduleRef
96+
*
97+
* For jdt, the list of matching categories looks like:
98+
* metaIndexQSTQ -> 59
99+
* ref -> 88
100+
* constructorRef -> 151
101+
* superRef -> 172
102+
* constructorDecl -> 258
103+
* moduleRef -> 317
104+
* typeDecl -> 334
105+
* metaIndexQTQ -> 390
106+
* metaIndexSTQ -> 459
107+
*
108+
* While for javac it looks like:
109+
* ref -> 59
110+
* superRef -> 106
111+
* typeDecl -> 192
112+
* constructorDecl -> 248
113+
* metaIndexQTQ -> 307
114+
*/
91115
public void testModuleImportPatternReferences() throws CoreException, IOException {
92116
SearchPattern pattern = SearchPattern.createPattern("*od.*", IJavaSearchConstants.MODULE, REFERENCES, SearchPattern.R_EXACT_MATCH);
93117
search(pattern, getJavaSearchScope(), this.resultCollector);

org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838
import org.eclipse.jdt.core.search.SearchPattern;
3939
import org.eclipse.jdt.core.search.SearchRequestor;
4040
import org.eclipse.jdt.core.search.TypeNameRequestor;
41+
import org.eclipse.jdt.core.tests.javac.JavacFailReason;
4142
import org.eclipse.jdt.core.tests.util.Util;
4243
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
4344
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
4445
import org.eclipse.jdt.internal.core.JavaModelStatus;
46+
import org.junit.Ignore;
47+
import org.junit.experimental.categories.Category;
4548

4649
/**
4750
* Tests the Java search engine where results are JavaElements and source positions.
@@ -3681,6 +3684,10 @@ public void testEnum02() throws CoreException {
36813684
"src/e1/Team.java e1.Team.FREDERIC [FREDERIC]",
36823685
this.resultCollector);
36833686
}
3687+
3688+
@Category(value=Ignore.class) @JavacFailReason(cause=JavacFailReason.VALID_ALTERNATIVE_IMPL)
3689+
// No API available to tell where an anonymous constructor's closing parenthesis is.
3690+
// Off by one error with added space.
36843691
public void testEnum03() throws CoreException {
36853692
IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
36863693
IMethod method = type.getMethod("Team", new String[] { "I" });

0 commit comments

Comments
 (0)