Lines 13-20
Link Here
|
13 |
|
13 |
|
14 |
import org.eclipse.jdt.core.IJavaElement; |
14 |
import org.eclipse.jdt.core.IJavaElement; |
15 |
import org.eclipse.jdt.core.util.IModifierConstants; |
15 |
import org.eclipse.jdt.core.util.IModifierConstants; |
|
|
16 |
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; |
16 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
17 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
17 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
18 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
|
|
19 |
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
21 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.TagBits; |
22 |
import org.eclipse.jdt.internal.compiler.lookup.TagBits; |
Lines 212-221
Link Here
|
212 |
} |
214 |
} |
213 |
} |
215 |
} |
214 |
// local variable |
216 |
// local variable |
215 |
IMethodBinding declaringMethod = getDeclaringMethod(); |
|
|
216 |
if (declaringMethod == null) return null; |
217 |
JavaElement method = (JavaElement) declaringMethod.getJavaElement(); |
218 |
if (method == null) return null; |
219 |
if (!(this.resolver instanceof DefaultBindingResolver)) return null; |
217 |
if (!(this.resolver instanceof DefaultBindingResolver)) return null; |
220 |
VariableDeclaration localVar = (VariableDeclaration) ((DefaultBindingResolver) this.resolver).bindingsToAstNodes.get(this); |
218 |
VariableDeclaration localVar = (VariableDeclaration) ((DefaultBindingResolver) this.resolver).bindingsToAstNodes.get(this); |
221 |
if (localVar == null) return null; |
219 |
if (localVar == null) return null; |
Lines 236-243
Link Here
|
236 |
sourceStart = node.getStartPosition(); |
234 |
sourceStart = node.getStartPosition(); |
237 |
sourceLength = node.getLength(); |
235 |
sourceLength = node.getLength(); |
238 |
} |
236 |
} |
|
|
237 |
int sourceEnd = sourceStart+sourceLength-1; |
239 |
char[] typeSig = this.binding.type.genericTypeSignature(); |
238 |
char[] typeSig = this.binding.type.genericTypeSignature(); |
240 |
return new LocalVariable(method, localVar.getName().getIdentifier(), sourceStart, sourceStart+sourceLength-1, nameStart, nameStart+nameLength-1, new String(typeSig), ((LocalVariableBinding) this.binding).declaration.annotations); |
239 |
JavaElement parent = null; |
|
|
240 |
IMethodBinding declaringMethod = getDeclaringMethod(); |
241 |
if (declaringMethod == null) { |
242 |
ReferenceContext referenceContext = ((LocalVariableBinding) binding).declaringScope.referenceContext(); |
243 |
if (referenceContext instanceof TypeDeclaration){ |
244 |
// Local variable is declared inside an initializer |
245 |
TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext; |
246 |
JavaElement typeHandle = null; |
247 |
if (this.resolver instanceof DefaultBindingResolver) { |
248 |
DefaultBindingResolver defaultBindingResolver = (DefaultBindingResolver) this.resolver; |
249 |
typeHandle = Util.getUnresolvedJavaElement( |
250 |
typeDeclaration.binding, |
251 |
defaultBindingResolver.workingCopyOwner, |
252 |
defaultBindingResolver.getBindingsToNodesMap()); |
253 |
} else { |
254 |
typeHandle = Util.getUnresolvedJavaElement(typeDeclaration.binding, null, null); |
255 |
} |
256 |
parent = Util.getUnresolvedJavaElement(sourceStart, sourceEnd, typeHandle); |
257 |
} else { |
258 |
return null; |
259 |
} |
260 |
} else { |
261 |
parent = (JavaElement) declaringMethod.getJavaElement(); |
262 |
} |
263 |
if (parent == null) return null; |
264 |
return new LocalVariable(parent, localVar.getName().getIdentifier(), sourceStart, sourceEnd, nameStart, nameStart+nameLength-1, new String(typeSig), ((LocalVariableBinding) this.binding).declaration.annotations); |
241 |
} |
265 |
} |
242 |
|
266 |
|
243 |
/* |
267 |
/* |