Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 357547 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java (-1 / +247 lines)
Lines 37-43 Link Here
37
	}
37
	}
38
	
38
	
39
	static {
39
	static {
40
		//TESTS_NAMES = new String[] {"testBug123836"};
40
		//TESTS_NAMES = new String[] {"testBug357547f"};
41
	}
41
	}
42
42
43
	public static Test suite() {
43
	public static Test suite() {
Lines 481-484 Link Here
481
			deleteProject("P");
481
			deleteProject("P");
482
		}
482
		}
483
	}
483
	}
484
	
485
	/**
486
	 * @bug 357547: [search] Search for method references is returning methods as overriden even if the superclass's method is only package-visible
487
	 * @test Search for a non-overriden method because of package visibility should not be found
488
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547"
489
	 */
490
	public void testBug357547a() throws CoreException {
491
		IJavaProject project = null;
492
		try
493
		{
494
			project = createJavaProject("P");
495
			createFolder("/P/p1");
496
			createFile("/P/p1/B.java",
497
					"package p1;\n" +
498
					"import p2.*;\n" +
499
					"public class B extends A {\n" +
500
					"long k(){\n" +
501
					"return 0;\n" +
502
			  		"}\n" +
503
					"}\n");
504
			createFolder("/P/p2");
505
			createFile("/P/p2/A.java",
506
					"package p2;\n" +
507
					"public class A {\n" +
508
					"long k(){\n" +
509
					"return 0;\n" +
510
			  		"}\n" +
511
			  		"public long m(){\n"+
512
			  		"return new A().k();\n" +
513
			  		"}\n"+
514
					"}\n");
515
			IType type = getCompilationUnit("/P/p1/B.java").getType("B");
516
			IMethod method = type.getMethod("k", new String[]{});
517
			search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector);
518
			assertSearchResults("Should not get any results", "", this.resultCollector);
519
		} finally {
520
			deleteProject(project);
521
		}
522
	}
523
	
524
	// search for the method name should also not return matches if not-overriden because of package-visible
525
	public void testBug357547b() throws CoreException {
526
		IJavaProject project = null;
527
		try
528
		{
529
			project = createJavaProject("P");
530
			createFolder("/P/p1");
531
			createFile("/P/p1/B.java",
532
					"package p1;\n" +
533
					"import p2.*;\n" +
534
					"public class B extends A {\n" +
535
					"long k(){\n" +
536
					"return 0;\n" +
537
			  		"}\n" +
538
					"}\n");
539
			createFolder("/P/p2");
540
			createFile("/P/p2/A.java",
541
					"package p2;\n" +
542
					"public class A {\n" +
543
					"long k(){\n" +
544
					"return 0;\n" +
545
			  		"}\n" +
546
			  		"public long m(){\n"+
547
			  		"return new A().k();\n" +
548
			  		"}\n"+
549
					"}\n");
550
			waitUntilIndexesReady();
551
			// search
552
			SearchPattern pattern = SearchPattern.createPattern("p*B.k()", METHOD, REFERENCES, EXACT_RULE);
553
			search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
554
			assertSearchResults("Should not get any results", "", this.resultCollector);
555
		} finally {
556
			deleteProject(project);
557
		}
558
	}
559
	
560
	// search for the method name should return the match if same package 
561
	public void testBug357547c() throws CoreException {
562
		IJavaProject project = null;
563
		try
564
		{
565
			project = createJavaProject("P");
566
			createFolder("/P/p2");
567
			createFile("/P/p2/B.java",
568
					"package p2;\n" +
569
					"public class B extends A {\n" +
570
					"long k(){\n" +
571
					"return 0;\n" +
572
			  		"}\n" +
573
					"}\n");
574
			createFile("/P/p2/A.java",
575
					"package p2;\n" +
576
					"public class A {\n" +
577
					"public long k(){\n" +
578
					"return 0;\n" +
579
			  		"}\n" +
580
			  		"public long m(){\n"+
581
			  		"return new A().k();\n" +
582
			  		"}\n"+
583
					"}\n");
584
			waitUntilIndexesReady();
585
			// search
586
			SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
587
			search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
588
			assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector);
589
		} finally {
590
			deleteProject(project);
591
		}
592
	}
593
	
594
	//presence of same name in the package should not effect the result
595
	public void testBug357547d() throws CoreException {
596
		IJavaProject project = null;
597
		try
598
		{
599
			project = createJavaProject("P");
600
			createFolder("/P/p1");
601
			createFile("/P/p1/B.java",
602
					"package p1;\n" +
603
					"import p2.*;\n" +
604
					"public class B extends A {\n" +
605
					"long k(){\n" +
606
					"return 0;\n" +
607
			  		"}\n" +
608
					"}\n");
609
			createFolder("/P/p2");
610
			createFile("/P/p2/A.java",
611
					"package p2;\n" +
612
					"public class A{ \n" +
613
					"long k(){\n" +
614
					"return 0;\n" +
615
			  		"}\n" +
616
			  		"public long m(){\n"+
617
			  		"return new A().k();\n" +
618
			  		"}\n"+
619
					"}\n");
620
			createFile("/P/p2/B.java",
621
					"package p2;\n" +
622
					"public class B {\n" +
623
					"}\n");
624
			waitUntilIndexesReady();
625
			// search
626
			SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
627
			search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
628
			assertSearchResults("Should not get any results", "", this.resultCollector);
629
		} finally {
630
			deleteProject(project);
631
		}
632
	}
633
	
634
	// search for the method name should also not return matches if not-overriden because of package-visible
635
	// even if they are in jars
636
	public void testBug357547e() throws CoreException, IOException {
637
		IJavaProject project = null;
638
		try
639
		{
640
			project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5");
641
			org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
642
					"p2/A.java",
643
					"package p2;\n" + 
644
					"public class A{}\n" }, 
645
					project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5");
646
			
647
			org.eclipse.jdt.core.tests.util.Util.createJar(
648
					new String[] {
649
						"p1/B.java",
650
						"package p1;\n"+
651
						"import p2.*;\n"+
652
						"public class B extends A {\n" +
653
						"long k(){\n" +
654
						"return 0;\n" +
655
						"}\n" + 
656
						"}\n"},
657
					null,
658
					project.getProject().getLocation().append("lib357547.jar").toOSString(),
659
					new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() },
660
					"1.5");
661
			refresh(project);
662
			createFolder("/P/p2");
663
			createFile("/P/p2/A.java",
664
					"package p2;\n" +
665
					"public class A {\n" +
666
					"long k(){\n" +
667
					"return 0;\n" +
668
			  		"}\n" +
669
			  		"public long m(){\n"+
670
			  		"return new A().k();\n" +
671
			  		"}\n"+
672
					"}\n");
673
			waitUntilIndexesReady();
674
			// search
675
			SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
676
			search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector);
677
			assertSearchResults("Wrong results", "", this.resultCollector);
678
		} finally {
679
			deleteProject(project);
680
		}
681
	}
682
	// search for the method name should also not return matches if not-overriden because of package-visible
683
	// even if they are in jars
684
	public void testBug357547f() throws CoreException, IOException {
685
		IJavaProject project = null;
686
		try
687
		{
688
			project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5");
689
			org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
690
					"p2/A.java",
691
					"package p2;\n" + 
692
					"public class A{}\n" }, 
693
					project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5");
694
			
695
			org.eclipse.jdt.core.tests.util.Util.createJar(
696
					new String[] {
697
						"p2/B.java",
698
						"package p2;\n" +
699
						"import p2.*;\n" +
700
						"public class B extends A {\n" +
701
						"long k(){\n" +
702
						"return 0;\n" +
703
						"}\n" + 
704
						"}\n"},
705
					null,
706
					project.getProject().getLocation().append("lib357547.jar").toOSString(),
707
					new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() },
708
					"1.5");
709
			refresh(project);
710
			createFolder("/P/p2");
711
			createFile("/P/p2/A.java",
712
					"package p2;\n" +
713
					"public class A {\n" +
714
					"long k(){\n" +
715
					"return 0;\n" +
716
			  		"}\n" +
717
			  		"public long m(){\n"+
718
			  		"return new A().k();\n" +
719
			  		"}\n"+
720
					"}\n");
721
			waitUntilIndexesReady();
722
			// search
723
			SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
724
			search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector);
725
			assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector);
726
		} finally {
727
			deleteProject(project);
728
		}
729
	}
484
}
730
}
(-)a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java (-10 / +23 lines)
Lines 31-39 Link Here
31
//extra reference info
31
//extra reference info
32
public char[][][] allSuperDeclaringTypeNames;
32
public char[][][] allSuperDeclaringTypeNames;
33
33
34
// This is set only if focus is null. In these cases
35
// it will be hard to determine if the super class is of the same package
36
// at a latter point. Hence, this array is created with all the super class 
37
// names of the same package name as of the matching class name.
38
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547
39
private char[][][] samePkgSuperDeclaringTypeNames;
40
34
private MatchLocator matchLocator;
41
private MatchLocator matchLocator;
35
//method declarations which parameters verification fail
42
//method declarations which parameters verification fail
36
private HashMap methodDeclarationsWithInvalidParam = new HashMap();
43
private HashMap methodDeclarationsWithInvalidParam = new HashMap();
44
37
45
38
public MethodLocator(MethodPattern pattern) {
46
public MethodLocator(MethodPattern pattern) {
39
	super(pattern);
47
	super(pattern);
Lines 75-88 Link Here
75
		start = System.currentTimeMillis();
83
		start = System.currentTimeMillis();
76
	}
84
	}
77
	try {
85
	try {
78
		this.allSuperDeclaringTypeNames =
86
		SuperTypeNamesCollector namesCollector = 
79
			new SuperTypeNamesCollector(
87
			new SuperTypeNamesCollector(
80
				this.pattern,
88
				this.pattern,
81
				this.pattern.declaringSimpleName,
89
				this.pattern.declaringSimpleName,
82
				this.pattern.declaringQualification,
90
				this.pattern.declaringQualification,
83
				locator,
91
				locator,
84
				this.pattern.declaringType,
92
				this.pattern.declaringType,
85
				locator.progressMonitor).collect();
93
				locator.progressMonitor);
94
		this.allSuperDeclaringTypeNames = namesCollector.collect();
95
		this.samePkgSuperDeclaringTypeNames = namesCollector.getSamePackageSuperTypeNames();
86
		this.matchLocator = locator;	
96
		this.matchLocator = locator;	
87
	} catch (JavaModelException e) {
97
	} catch (JavaModelException e) {
88
		// inaccurate matches will be found
98
		// inaccurate matches will be found
Lines 109-115 Link Here
109
 * this message send or not.
119
 * this message send or not.
110
 */
120
 */
111
protected boolean isVirtualInvoke(MethodBinding method, MessageSend messageSend) {
121
protected boolean isVirtualInvoke(MethodBinding method, MessageSend messageSend) {
112
	return !method.isStatic() && !method.isPrivate() && !messageSend.isSuperAccess();
122
		return !method.isStatic() && !method.isPrivate() && !messageSend.isSuperAccess()
123
				&& !(method.isDefault() && this.pattern.focus != null && 
124
				!CharOperation.equals(this.pattern.declaringQualification, method.declaringClass.qualifiedPackageName()));
113
}
125
}
114
public int match(ASTNode node, MatchingNodeSet nodeSet) {
126
public int match(ASTNode node, MatchingNodeSet nodeSet) {
115
	int declarationsLevel = IMPOSSIBLE_MATCH;
127
	int declarationsLevel = IMPOSSIBLE_MATCH;
Lines 669-677 Link Here
669
			if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) {
681
			if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) {
670
				declaringLevel = INACCURATE_MATCH;
682
				declaringLevel = INACCURATE_MATCH;
671
			} else {
683
			} else {
672
				if (resolveLevelAsSuperInvocation(methodReceiverType, method.parameters, true)) {
684
				char[][][] superTypeNames = (method.isDefault() && this.pattern.focus == null) ? this.samePkgSuperDeclaringTypeNames: this.allSuperDeclaringTypeNames;
673
					declaringLevel = methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match
685
				if (superTypeNames != null && resolveLevelAsSuperInvocation(methodReceiverType, method.parameters, superTypeNames, true)) {
674
						| SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level
686
						declaringLevel = methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match
687
							| SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level
675
				}
688
				}
676
			}
689
			}
677
		}
690
		}
Lines 745-754 Link Here
745
 * Return whether the given type binding or one of its possible super interfaces
758
 * Return whether the given type binding or one of its possible super interfaces
746
 * matches a type in the declaring type names hierarchy.
759
 * matches a type in the declaring type names hierarchy.
747
 */
760
 */
748
private boolean resolveLevelAsSuperInvocation(ReferenceBinding type, TypeBinding[] argumentTypes, boolean methodAlreadyVerified) {
761
private boolean resolveLevelAsSuperInvocation(ReferenceBinding type, TypeBinding[] argumentTypes, char[][][] superTypeNames, boolean methodAlreadyVerified) {
749
	char[][] compoundName = type.compoundName;
762
	char[][] compoundName = type.compoundName;
750
	for (int i = 0, max = this.allSuperDeclaringTypeNames.length; i < max; i++) {
763
	for (int i = 0, max = superTypeNames.length; i < max; i++) {
751
		if (CharOperation.equals(this.allSuperDeclaringTypeNames[i], compoundName)) {
764
		if (CharOperation.equals(superTypeNames[i], compoundName)) {
752
			// need to verify if the type implements the pattern method
765
			// need to verify if the type implements the pattern method
753
			if (methodAlreadyVerified) return true; // already verified before enter into this method (see resolveLevel(MessageSend))
766
			if (methodAlreadyVerified) return true; // already verified before enter into this method (see resolveLevel(MessageSend))
754
			MethodBinding[] methods = type.getMethods(this.pattern.selector);
767
			MethodBinding[] methods = type.getMethods(this.pattern.selector);
Lines 780-786 Link Here
780
		ReferenceBinding[] interfaces = type.superInterfaces();
793
		ReferenceBinding[] interfaces = type.superInterfaces();
781
		if (interfaces == null) return false;
794
		if (interfaces == null) return false;
782
		for (int i = 0; i < interfaces.length; i++) {
795
		for (int i = 0; i < interfaces.length; i++) {
783
			if (resolveLevelAsSuperInvocation(interfaces[i], argumentTypes, false)) {
796
			if (resolveLevelAsSuperInvocation(interfaces[i], argumentTypes, superTypeNames, false)) {
784
				return true;
797
				return true;
785
			}
798
			}
786
		}
799
		}
(-)a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java (-11 / +37 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-19 Link Here
13
import org.eclipse.core.runtime.IProgressMonitor;
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.SubProgressMonitor;
14
import org.eclipse.core.runtime.SubProgressMonitor;
15
import org.eclipse.jdt.core.*;
15
import org.eclipse.jdt.core.*;
16
import org.eclipse.jdt.core.ICompilationUnit;
17
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.CharOperation;
18
import org.eclipse.jdt.core.search.*;
17
import org.eclipse.jdt.core.search.*;
19
import org.eclipse.jdt.internal.compiler.ASTVisitor;
18
import org.eclipse.jdt.internal.compiler.ASTVisitor;
Lines 45-63 Link Here
45
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
44
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
46
			ReferenceBinding binding = typeDeclaration.binding;
45
			ReferenceBinding binding = typeDeclaration.binding;
47
			if (SuperTypeNamesCollector.this.matches(binding))
46
			if (SuperTypeNamesCollector.this.matches(binding))
48
				collectSuperTypeNames(binding);
47
				collectSuperTypeNames(binding, binding.compoundName);
49
			return true;
48
			return true;
50
		}
49
		}
51
		public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
50
		public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
52
			ReferenceBinding binding = typeDeclaration.binding;
51
			ReferenceBinding binding = typeDeclaration.binding;
53
			if (SuperTypeNamesCollector.this.matches(binding))
52
			if (SuperTypeNamesCollector.this.matches(binding))
54
				collectSuperTypeNames(binding);
53
				collectSuperTypeNames(binding, binding.compoundName);
55
			return true;
54
			return true;
56
		}
55
		}
57
		public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
56
		public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
58
			ReferenceBinding binding = memberTypeDeclaration.binding;
57
			ReferenceBinding binding = memberTypeDeclaration.binding;
59
			if (SuperTypeNamesCollector.this.matches(binding))
58
			if (SuperTypeNamesCollector.this.matches(binding))
60
				collectSuperTypeNames(binding);
59
				collectSuperTypeNames(binding, binding.compoundName);
61
			return true;
60
			return true;
62
		}
61
		}
63
		public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
62
		public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
Lines 82-87 Link Here
82
char[][][] result;
81
char[][][] result;
83
int resultIndex;
82
int resultIndex;
84
83
84
char[][][] samePackageSuperTypeName; // set only if focus is null
85
int samePackageIndex;
86
85
public SuperTypeNamesCollector(
87
public SuperTypeNamesCollector(
86
	SearchPattern pattern,
88
	SearchPattern pattern,
87
	char[] typeSimpleName,
89
	char[] typeSimpleName,
Lines 98-103 Link Here
98
	this.progressMonitor = progressMonitor;
100
	this.progressMonitor = progressMonitor;
99
}
101
}
100
102
103
private boolean addIfSamePackage(char[][] compoundName, char[][] path) {
104
	if (compoundName.length != path.length) return false;
105
	int resultLength = this.samePackageSuperTypeName.length;
106
	for (int i = 0; i < resultLength; i++)
107
		if (CharOperation.equals(this.samePackageSuperTypeName[i], compoundName)) return false; // already known
108
	
109
	for (int i = 0, length = compoundName.length - 1; i < length; i ++) {
110
		if (!CharOperation.equals(compoundName[i], path[i])) return false;
111
	}
112
	if (resultLength == this.samePackageIndex)
113
		System.arraycopy(this.samePackageSuperTypeName, 0, this.samePackageSuperTypeName = new char[resultLength*2][][], 0, resultLength);
114
	this.samePackageSuperTypeName[this.samePackageIndex++] = compoundName;
115
	return true;
116
}
117
101
protected void addToResult(char[][] compoundName) {
118
protected void addToResult(char[][] compoundName) {
102
	int resultLength = this.result.length;
119
	int resultLength = this.result.length;
103
	for (int i = 0; i < resultLength; i++)
120
	for (int i = 0; i < resultLength; i++)
Lines 107-112 Link Here
107
		System.arraycopy(this.result, 0, this.result = new char[resultLength*2][][], 0, resultLength);
124
		System.arraycopy(this.result, 0, this.result = new char[resultLength*2][][], 0, resultLength);
108
	this.result[this.resultIndex++] = compoundName;
125
	this.result[this.resultIndex++] = compoundName;
109
}
126
}
127
110
/*
128
/*
111
 * Parse the given compiation unit and build its type bindings.
129
 * Parse the given compiation unit and build its type bindings.
112
 */
130
 */
Lines 141-147 Link Here
141
			if (this.type.isBinary()) {
159
			if (this.type.isBinary()) {
142
				BinaryTypeBinding binding = this.locator.cacheBinaryType(this.type, null);
160
				BinaryTypeBinding binding = this.locator.cacheBinaryType(this.type, null);
143
				if (binding != null)
161
				if (binding != null)
144
					collectSuperTypeNames(binding);
162
					collectSuperTypeNames(binding, null);
145
			} else {
163
			} else {
146
				ICompilationUnit unit = this.type.getCompilationUnit();
164
				ICompilationUnit unit = this.type.getCompilationUnit();
147
				SourceType sourceType = (SourceType) this.type;
165
				SourceType sourceType = (SourceType) this.type;
Lines 150-156 Link Here
150
				if (parsedUnit != null) {
168
				if (parsedUnit != null) {
151
					TypeDeclaration typeDecl = new ASTNodeFinder(parsedUnit).findType(this.type);
169
					TypeDeclaration typeDecl = new ASTNodeFinder(parsedUnit).findType(this.type);
152
					if (typeDecl != null && typeDecl.binding != null)
170
					if (typeDecl != null && typeDecl.binding != null)
153
						collectSuperTypeNames(typeDecl.binding);
171
						collectSuperTypeNames(typeDecl.binding, null);
154
				}
172
				}
155
			}
173
			}
156
		} catch (AbortCompilation e) {
174
		} catch (AbortCompilation e) {
Lines 171-176 Link Here
171
	Util.sort(paths); // sort by projects
189
	Util.sort(paths); // sort by projects
172
	JavaProject previousProject = null;
190
	JavaProject previousProject = null;
173
	this.result = new char[1][][];
191
	this.result = new char[1][][];
192
	this.samePackageSuperTypeName = new char[1][][];
174
	this.resultIndex = 0;
193
	this.resultIndex = 0;
175
	for (int i = 0, length = paths.length; i < length; i++) {
194
	for (int i = 0, length = paths.length; i < length; i++) {
176
		try {
195
		try {
Lines 191-197 Link Here
191
				IClassFile classFile = (IClassFile) openable;
210
				IClassFile classFile = (IClassFile) openable;
192
				BinaryTypeBinding binding = this.locator.cacheBinaryType(classFile.getType(), null);
211
				BinaryTypeBinding binding = this.locator.cacheBinaryType(classFile.getType(), null);
193
				if (matches(binding))
212
				if (matches(binding))
194
					collectSuperTypeNames(binding);
213
					collectSuperTypeNames(binding, binding.compoundName);
195
			}
214
			}
196
		} catch (AbortCompilation e) {
215
		} catch (AbortCompilation e) {
197
			// ignore: continue with next element
216
			// ignore: continue with next element
Lines 206-216 Link Here
206
/**
225
/**
207
 * Collects the names of all the supertypes of the given type.
226
 * Collects the names of all the supertypes of the given type.
208
 */
227
 */
209
protected void collectSuperTypeNames(ReferenceBinding binding) {
228
protected void collectSuperTypeNames(ReferenceBinding binding, char[][] path) {
210
	ReferenceBinding superclass = binding.superclass();
229
	ReferenceBinding superclass = binding.superclass();
230
	if (path != null) {
231
		boolean samePackage = addIfSamePackage(superclass.compoundName, path);
232
		if (!samePackage) path = null;
233
	}
211
	if (superclass != null) {
234
	if (superclass != null) {
212
		addToResult(superclass.compoundName);
235
		addToResult(superclass.compoundName);
213
		collectSuperTypeNames(superclass);
236
		collectSuperTypeNames(superclass, null);
214
	}
237
	}
215
238
216
	ReferenceBinding[] interfaces = binding.superInterfaces();
239
	ReferenceBinding[] interfaces = binding.superInterfaces();
Lines 218-224 Link Here
218
		for (int i = 0; i < interfaces.length; i++) {
241
		for (int i = 0; i < interfaces.length; i++) {
219
			ReferenceBinding interfaceBinding = interfaces[i];
242
			ReferenceBinding interfaceBinding = interfaces[i];
220
			addToResult(interfaceBinding.compoundName);
243
			addToResult(interfaceBinding.compoundName);
221
			collectSuperTypeNames(interfaceBinding);
244
			collectSuperTypeNames(interfaceBinding, null);
222
		}
245
		}
223
	}
246
	}
224
}
247
}
Lines 254-259 Link Here
254
		this.progressMonitor == null ? null : new SubProgressMonitor(this.progressMonitor, 100));
277
		this.progressMonitor == null ? null : new SubProgressMonitor(this.progressMonitor, 100));
255
	return pathCollector.getPaths();
278
	return pathCollector.getPaths();
256
}
279
}
280
public char[][][] getSamePackageSuperTypeNames() {
281
	return this.samePackageSuperTypeName;
282
}
257
protected boolean matches(char[][] compoundName) {
283
protected boolean matches(char[][] compoundName) {
258
	int length = compoundName.length;
284
	int length = compoundName.length;
259
	if (length == 0) return false;
285
	if (length == 0) return false;

Return to bug 357547