Lines 24-29
Link Here
|
24 |
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; |
24 |
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; |
25 |
import org.eclipse.jdt.internal.core.search.BasicSearchEngine; |
25 |
import org.eclipse.jdt.internal.core.search.BasicSearchEngine; |
26 |
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor; |
26 |
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor; |
|
|
27 |
import org.eclipse.jdt.internal.core.util.Util; |
27 |
|
28 |
|
28 |
/** |
29 |
/** |
29 |
* This class provides a <code>SearchableBuilderEnvironment</code> for code assist which |
30 |
* This class provides a <code>SearchableBuilderEnvironment</code> for code assist which |
Lines 35-40
Link Here
|
35 |
public NameLookup nameLookup; |
36 |
public NameLookup nameLookup; |
36 |
protected ICompilationUnit unitToSkip; |
37 |
protected ICompilationUnit unitToSkip; |
37 |
protected org.eclipse.jdt.core.ICompilationUnit[] workingCopies; |
38 |
protected org.eclipse.jdt.core.ICompilationUnit[] workingCopies; |
|
|
39 |
protected WorkingCopyOwner owner; |
38 |
|
40 |
|
39 |
protected JavaProject project; |
41 |
protected JavaProject project; |
40 |
protected IJavaSearchScope searchScope; |
42 |
protected IJavaSearchScope searchScope; |
Lines 58-63
Link Here
|
58 |
*/ |
60 |
*/ |
59 |
public SearchableEnvironment(JavaProject project, WorkingCopyOwner owner) throws JavaModelException { |
61 |
public SearchableEnvironment(JavaProject project, WorkingCopyOwner owner) throws JavaModelException { |
60 |
this(project, owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(owner, true/*add primary WCs*/)); |
62 |
this(project, owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(owner, true/*add primary WCs*/)); |
|
|
63 |
this.owner = owner; |
61 |
} |
64 |
} |
62 |
|
65 |
|
63 |
private static int convertSearchFilterToModelFilter(int searchFilter) { |
66 |
private static int convertSearchFilterToModelFilter(int searchFilter) { |
Lines 85-90
Link Here
|
85 |
protected NameEnvironmentAnswer find(String typeName, String packageName) { |
88 |
protected NameEnvironmentAnswer find(String typeName, String packageName) { |
86 |
if (packageName == null) |
89 |
if (packageName == null) |
87 |
packageName = IPackageFragment.DEFAULT_PACKAGE_NAME; |
90 |
packageName = IPackageFragment.DEFAULT_PACKAGE_NAME; |
|
|
91 |
if (this.owner != null) { |
92 |
String source = this.owner.findSource(typeName, packageName); |
93 |
if (source != null) { |
94 |
ICompilationUnit cu = new BasicCompilationUnit(source.toCharArray(), CharOperation.splitOn('.', packageName.toCharArray()), typeName + Util.defaultJavaExtension()); |
95 |
return new NameEnvironmentAnswer(cu, null); |
96 |
} |
97 |
} |
88 |
NameLookup.Answer answer = |
98 |
NameLookup.Answer answer = |
89 |
this.nameLookup.findType( |
99 |
this.nameLookup.findType( |
90 |
typeName, |
100 |
typeName, |
Lines 98-104
Link Here
|
98 |
try { |
108 |
try { |
99 |
return new NameEnvironmentAnswer((IBinaryType) ((BinaryType) answer.type).getElementInfo(), answer.restriction); |
109 |
return new NameEnvironmentAnswer((IBinaryType) ((BinaryType) answer.type).getElementInfo(), answer.restriction); |
100 |
} catch (JavaModelException npe) { |
110 |
} catch (JavaModelException npe) { |
101 |
return null; |
111 |
// fall back to using owner |
102 |
} |
112 |
} |
103 |
} else { //SourceType |
113 |
} else { //SourceType |
104 |
try { |
114 |
try { |
Lines 123-129
Link Here
|
123 |
} |
133 |
} |
124 |
return new NameEnvironmentAnswer(sourceTypes, answer.restriction); |
134 |
return new NameEnvironmentAnswer(sourceTypes, answer.restriction); |
125 |
} catch (JavaModelException npe) { |
135 |
} catch (JavaModelException npe) { |
126 |
return null; |
136 |
// fall back to using owner |
127 |
} |
137 |
} |
128 |
} |
138 |
} |
129 |
} |
139 |
} |
Lines 501-507
Link Here
|
501 |
pkgName[i] = new String(parentPackageName[i]); |
511 |
pkgName[i] = new String(parentPackageName[i]); |
502 |
pkgName[length] = new String(subPackageName); |
512 |
pkgName[length] = new String(subPackageName); |
503 |
} |
513 |
} |
504 |
return this.nameLookup.isPackage(pkgName); |
514 |
return |
|
|
515 |
(this.owner != null && this.owner.isPackage(pkgName)) |
516 |
|| this.nameLookup.isPackage(pkgName); |
505 |
} |
517 |
} |
506 |
|
518 |
|
507 |
/** |
519 |
/** |