Skip to content

Commit

Permalink
Fix JavaModelHelper.resolveType() to use project scope (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis authored Mar 20, 2017
1 parent 268625b commit ac5361f
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions ca.ubc.cs.ferret.jdt/src/ca/ubc/cs/ferret/jdt/JavaModelHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,7 @@ public IType call() throws Exception {
IJavaSearchConstants.TYPE,
IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
// We tried using a JavaElement search scope, but it doesn't work
// often resolve the types
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
IJavaSearchScope scope = createSearchScope(referencingMember);
performSearch(pattern, scope, requestor, new NullProgressMonitor());
List<Object> results = new ArrayList<Object>(requestor.getValues());
if(results.size() > 1) {
Expand All @@ -686,13 +684,28 @@ public IType call() throws Exception {
}

/**
* Resolve the child type defined within the provided type. Assumes <code>remainder</code>
* has no further $.
* @param parent the parent type
* @param fqParentName the parent's fully-qualified name
* @param simpleName the type name within the parent
* @return the resolved type, or null if not found
*/
* @param referencingMember
* @return
*/
protected IJavaSearchScope createSearchScope(IJavaElement referencingMember) {
if (referencingMember == null) {
return SearchEngine.createWorkspaceScope();
}
return SearchEngine.createJavaSearchScope(new IJavaElement[] { referencingMember.getJavaProject() });
}

/**
* Resolve the child type defined within the provided type. Assumes
* <code>remainder</code> has no further $.
*
* @param parent
* the parent type
* @param fqParentName
* the parent's fully-qualified name
* @param simpleName
* the type name within the parent
* @return the resolved type, or null if not found
*/
protected IType resolveEnclosedType(final IType parent, final String fqParentName,
final String simpleName) {
if(parent == null) { return null; }
Expand Down

0 comments on commit ac5361f

Please sign in to comment.