Lines 44-49
Link Here
|
44 |
|
44 |
|
45 |
public boolean needsRefresh; |
45 |
public boolean needsRefresh; |
46 |
|
46 |
|
|
|
47 |
private boolean onlySubtypes= false; |
48 |
private HashSet subTypes; // only set when onlySubtypes==true |
49 |
private IJavaProject javaProject= null; |
50 |
|
47 |
/* (non-Javadoc) |
51 |
/* (non-Javadoc) |
48 |
* Adds the given resource to this search scope. |
52 |
* Adds the given resource to this search scope. |
49 |
*/ |
53 |
*/ |
Lines 59-64
Link Here
|
59 |
elements[elementCount++] = element; |
63 |
elements[elementCount++] = element; |
60 |
} |
64 |
} |
61 |
|
65 |
|
|
|
66 |
/** |
67 |
* Creates a new hierarchy scope for the given type. |
68 |
* @param project constrain the search result to this project |
69 |
* @param type the root of the hierarchy |
70 |
* @param owner |
71 |
* @param onlySubtypes if true search only subtypes of 'type' (not including 'type') |
72 |
*/ |
73 |
public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes) |
74 |
throws JavaModelException |
75 |
{ |
76 |
this(type, owner); |
77 |
this.javaProject= project; |
78 |
this.onlySubtypes= onlySubtypes; |
79 |
} |
80 |
|
62 |
/* (non-Javadoc) |
81 |
/* (non-Javadoc) |
63 |
* Creates a new hiearchy scope for the given type. |
82 |
* Creates a new hiearchy scope for the given type. |
64 |
*/ |
83 |
*/ |
Lines 100-109
Link Here
|
100 |
private void buildResourceVector() { |
119 |
private void buildResourceVector() { |
101 |
HashMap resources = new HashMap(); |
120 |
HashMap resources = new HashMap(); |
102 |
HashMap paths = new HashMap(); |
121 |
HashMap paths = new HashMap(); |
103 |
this.types = this.hierarchy.getAllTypes(); |
122 |
if (this.onlySubtypes) { |
|
|
123 |
this.types= this.hierarchy.getAllSubtypes(this.focusType); |
124 |
this.subTypes= new HashSet(this.types.length); |
125 |
} else { |
126 |
this.types = this.hierarchy.getAllTypes(); |
127 |
} |
104 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
128 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
105 |
for (int i = 0; i < this.types.length; i++) { |
129 |
for (int i = 0; i < this.types.length; i++) { |
106 |
IType type = this.types[i]; |
130 |
IType type = this.types[i]; |
|
|
131 |
if (this.onlySubtypes) |
132 |
this.subTypes.add(type); |
107 |
IResource resource = type.getResource(); |
133 |
IResource resource = type.getResource(); |
108 |
if (resource != null && resources.get(resource) == null) { |
134 |
if (resource != null && resources.get(resource) == null) { |
109 |
resources.put(resource, resource); |
135 |
resources.put(resource, resource); |
Lines 288-293
Link Here
|
288 |
IType type = null; |
314 |
IType type = null; |
289 |
if (element instanceof IType) { |
315 |
if (element instanceof IType) { |
290 |
type = (IType) element; |
316 |
type = (IType) element; |
|
|
317 |
if (this.onlySubtypes) { |
318 |
// searching subtypes and have a type: only check in this.subTypes: |
319 |
if (this.subTypes.contains(type)) |
320 |
return true; |
321 |
// be flexible: look at original element (see bug 14106 and below) |
322 |
IType original = type.isBinary() ? null : (IType)type.getPrimaryElement(); |
323 |
if (original != type && this.subTypes.contains(original)) |
324 |
return true; |
325 |
return false; |
326 |
} |
291 |
} else if (element instanceof IMember) { |
327 |
} else if (element instanceof IMember) { |
292 |
type = ((IMember) element).getDeclaringType(); |
328 |
type = ((IMember) element).getDeclaringType(); |
293 |
} |
329 |
} |
Lines 325-331
Link Here
|
325 |
this.elementCount = 0; |
361 |
this.elementCount = 0; |
326 |
this.needsRefresh = false; |
362 |
this.needsRefresh = false; |
327 |
if (this.hierarchy == null) { |
363 |
if (this.hierarchy == null) { |
328 |
this.hierarchy = this.focusType.newTypeHierarchy(this.owner, null); |
364 |
if (this.javaProject != null) |
|
|
365 |
this.hierarchy = this.focusType.newTypeHierarchy(this.javaProject, this.owner, null); |
366 |
else |
367 |
this.hierarchy = this.focusType.newTypeHierarchy(this.owner, null); |
329 |
} else { |
368 |
} else { |
330 |
this.hierarchy.refresh(null); |
369 |
this.hierarchy.refresh(null); |
331 |
} |
370 |
} |