Lines 86-91
Link Here
|
86 |
private boolean hasComputedEnclosingJavaElements; |
86 |
private boolean hasComputedEnclosingJavaElements; |
87 |
Map bindingsToNodes; |
87 |
Map bindingsToNodes; |
88 |
private Map bindingsToHandles; |
88 |
private Map bindingsToHandles; |
|
|
89 |
private Map nodesWithProblemsToHandles; |
89 |
private ICompilationUnit compilationUnit; |
90 |
private ICompilationUnit compilationUnit; |
90 |
|
91 |
|
91 |
public InternalExtendedCompletionContext( |
92 |
public InternalExtendedCompletionContext( |
Lines 117-122
Link Here
|
117 |
|
118 |
|
118 |
HashMap handleToBinding = new HashMap(); |
119 |
HashMap handleToBinding = new HashMap(); |
119 |
HashMap bindingToHandle = new HashMap(); |
120 |
HashMap bindingToHandle = new HashMap(); |
|
|
121 |
HashMap nodeWithProblemToHandle = new HashMap(); |
120 |
HashMap handleToInfo = new HashMap(); |
122 |
HashMap handleToInfo = new HashMap(); |
121 |
|
123 |
|
122 |
org.eclipse.jdt.core.ICompilationUnit handle = new AssistCompilationUnit(original, this.owner, handleToBinding, handleToInfo); |
124 |
org.eclipse.jdt.core.ICompilationUnit handle = new AssistCompilationUnit(original, this.owner, handleToBinding, handleToInfo); |
Lines 132-137
Link Here
|
132 |
this.assistNode, |
134 |
this.assistNode, |
133 |
handleToBinding, |
135 |
handleToBinding, |
134 |
bindingToHandle, |
136 |
bindingToHandle, |
|
|
137 |
nodeWithProblemToHandle, |
135 |
handleToInfo); |
138 |
handleToInfo); |
136 |
|
139 |
|
137 |
CompletionElementNotifier notifier = |
140 |
CompletionElementNotifier notifier = |
Lines 149-154
Link Here
|
149 |
new HashMap()); |
152 |
new HashMap()); |
150 |
|
153 |
|
151 |
this.bindingsToHandles = bindingToHandle; |
154 |
this.bindingsToHandles = bindingToHandle; |
|
|
155 |
this.nodesWithProblemsToHandles = nodeWithProblemToHandle; |
152 |
this.compilationUnit = handle; |
156 |
this.compilationUnit = handle; |
153 |
} |
157 |
} |
154 |
} |
158 |
} |
Lines 218-229
Link Here
|
218 |
ReferenceContext referenceContext = binding.declaringScope.referenceContext(); |
222 |
ReferenceContext referenceContext = binding.declaringScope.referenceContext(); |
219 |
if (referenceContext instanceof AbstractMethodDeclaration) { |
223 |
if (referenceContext instanceof AbstractMethodDeclaration) { |
220 |
AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext; |
224 |
AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext; |
221 |
parent = this.getJavaElementOfCompilationUnit(methodDeclaration.binding); |
225 |
parent = this.getJavaElementOfCompilationUnit(methodDeclaration, methodDeclaration.binding); |
222 |
} else if (referenceContext instanceof TypeDeclaration){ |
226 |
} else if (referenceContext instanceof TypeDeclaration){ |
223 |
// Local variable is declared inside an initializer |
227 |
// Local variable is declared inside an initializer |
224 |
TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext; |
228 |
TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext; |
225 |
|
229 |
|
226 |
IType type = (IType)this.getJavaElementOfCompilationUnit(typeDeclaration.binding); |
230 |
IType type = (IType)this.getJavaElementOfCompilationUnit(typeDeclaration, typeDeclaration.binding); |
227 |
if (type != null) { |
231 |
if (type != null) { |
228 |
try { |
232 |
try { |
229 |
IInitializer[] initializers = type.getInitializers(); |
233 |
IInitializer[] initializers = type.getInitializers(); |
Lines 268-273
Link Here
|
268 |
return (JavaElement)this.bindingsToHandles.get(binding); |
272 |
return (JavaElement)this.bindingsToHandles.get(binding); |
269 |
} |
273 |
} |
270 |
|
274 |
|
|
|
275 |
private JavaElement getJavaElementOfCompilationUnit(ASTNode node, Binding binding) { |
276 |
if (!this.hasComputedEnclosingJavaElements) { |
277 |
computeEnclosingJavaElements(); |
278 |
} |
279 |
if (binding != null) { |
280 |
if (this.bindingsToHandles == null) return null; |
281 |
return (JavaElement)this.bindingsToHandles.get(binding); |
282 |
} else { |
283 |
if (this.nodesWithProblemsToHandles == null) return null; |
284 |
return (JavaElement)this.nodesWithProblemsToHandles.get(node); |
285 |
} |
286 |
} |
287 |
|
271 |
private TypeBinding getTypeFromSignature(String typeSignature, Scope scope) { |
288 |
private TypeBinding getTypeFromSignature(String typeSignature, Scope scope) { |
272 |
TypeBinding assignableTypeBinding = null; |
289 |
TypeBinding assignableTypeBinding = null; |
273 |
|
290 |
|
Lines 353-359
Link Here
|
353 |
next : for (int i = 0; i < size; i++) { |
370 |
next : for (int i = 0; i < size; i++) { |
354 |
LocalVariableBinding binding = (LocalVariableBinding) visibleLocalVariables.elementAt(i); |
371 |
LocalVariableBinding binding = (LocalVariableBinding) visibleLocalVariables.elementAt(i); |
355 |
if (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding)) continue next; |
372 |
if (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding)) continue next; |
356 |
result[elementCount++] = getJavaElement(binding); |
373 |
JavaElement localVariable = getJavaElement(binding); |
|
|
374 |
if (localVariable != null) result[elementCount++] = localVariable; |
357 |
} |
375 |
} |
358 |
|
376 |
|
359 |
} |
377 |
} |