View | Details | Raw Unified | Return to bug 221130 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/core/search/IJavaSearchConstants.java (+11 lines)
Lines 382-387 Link Here
382
	 * @category limitTo
382
	 * @category limitTo
383
	 */
383
	 */
384
	int WILDCARD_BOUND_TYPE_REFERENCE = 0x80000;
384
	int WILDCARD_BOUND_TYPE_REFERENCE = 0x80000;
385
386
	/**
387
	 * Return only type references used as an instance of.
388
	 * <p>
389
	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
390
	 * returned.
391
	 *</p>
392
	 * @since 3.4
393
	 * @category limitTo
394
	 */
395
	int INSTANCEOF_TYPE_REFERENCE = 0x100000;
385
	
396
	
386
	/**
397
	/**
387
	 * Return only super field accesses or super method invocations (e.g. using the
398
	 * Return only super field accesses or super method invocations (e.g. using the
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java (+15 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.matching;
11
package org.eclipse.jdt.internal.core.search.matching;
12
12
13
import org.eclipse.jdt.core.dom.InfixExpression;
13
import org.eclipse.jdt.core.search.IJavaSearchConstants;
14
import org.eclipse.jdt.core.search.IJavaSearchConstants;
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.ast.*;
16
import org.eclipse.jdt.internal.compiler.ast.*;
Lines 322-327 Link Here
322
	this.patternLocator.match((LocalDeclaration) this.astStack[this.astPtr], this.nodeSet);
323
	this.patternLocator.match((LocalDeclaration) this.astStack[this.astPtr], this.nodeSet);
323
}
324
}
324
325
326
protected void consumeInstanceOfExpression() {
327
	super.consumeInstanceOfExpression();
328
	if ((this.patternFineGrain & IJavaSearchConstants.INSTANCEOF_TYPE_REFERENCE) != 0) {
329
		InstanceOfExpression expression = (InstanceOfExpression) this.expressionStack[this.expressionPtr];
330
		this.patternLocator.match(expression.type, this.nodeSet);
331
	}
332
}
333
protected void consumeInstanceOfExpressionWithName() {
334
	super.consumeInstanceOfExpressionWithName();
335
	if ((this.patternFineGrain & IJavaSearchConstants.INSTANCEOF_TYPE_REFERENCE) != 0) {
336
		InstanceOfExpression expression = (InstanceOfExpression) this.expressionStack[this.expressionPtr];
337
		this.patternLocator.match(expression.type, this.nodeSet);
338
	}
339
}
325
protected void consumeInterfaceType() {
340
protected void consumeInterfaceType() {
326
	super.consumeInterfaceType();
341
	super.consumeInterfaceType();
327
	if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
342
	if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) {
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java (+45 lines)
Lines 436-441 Link Here
436
	);
436
	);
437
}
437
}
438
438
439
/**
440
 * @bug 221130: [search] No fine-grain search for instanceof criteria
441
 * @test Verify that type references are only reported in instanceof pattern when
442
 * 	corresponding fine grain flag is set.
443
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=221130"
444
 */
445
public void testTypeRef_InstanceOf() throws CoreException {
446
	workingCopies = new ICompilationUnit[1];
447
	workingCopies[0] = getWorkingCopy("/JavaSearch15/src/Test.java",
448
		"public class Test {\n" + 
449
		"	Object field;\n" + 
450
		"	void foo(Object param) {\n" + 
451
		"		if (field instanceof java.lang.String) {\n" + 
452
		"		}\n" + 
453
		"		if (param instanceof Test) {\n" + 
454
		"		}\n" + 
455
		"	}\n" + 
456
		"}\n"
457
	);
458
	search("*", TYPE, INSTANCEOF_TYPE_REFERENCE);
459
	assertSearchResults(
460
		"src/Test.java void Test.foo(Object) [		if (field instanceof §|java.lang.String|§) {@84] EXACT_MATCH\n" + 
461
		"src/Test.java void Test.foo(Object) [		if (param instanceof §|Test|§) {@131] EXACT_MATCH"
462
	);
463
}
464
public void testTypeRef_InstanceOfWithParenthesis() throws CoreException {
465
	workingCopies = new ICompilationUnit[1];
466
	workingCopies[0] = getWorkingCopy("/JavaSearch15/src/Test.java",
467
		"public class Test {\n" + 
468
		"	Object field;\n" + 
469
		"	void foo(Object param) {\n" + 
470
		"		if ((field instanceof Test)) {\n" + 
471
		"		}\n" + 
472
		"		if ((param instanceof java.lang.Throwable)) {\n" + 
473
		"		}\n" + 
474
		"	}\n" + 
475
		"}\n"
476
	);
477
	search("*", TYPE, INSTANCEOF_TYPE_REFERENCE);
478
	assertSearchResults(
479
		"src/Test.java void Test.foo(Object) [		if ((field instanceof §|Test|§)) {@85] EXACT_MATCH\n" + 
480
		"src/Test.java void Test.foo(Object) [		if ((param instanceof §|java.lang.Throwable|§)) {@122] EXACT_MATCH"
481
	);
482
}
483
439
/*
484
/*
440
 * References to a all types (using '*' string pattern)
485
 * References to a all types (using '*' string pattern)
441
 */
486
 */

Return to bug 221130