return null;
}
}
private JavaElement getJavaElement(LocalVariableBinding binding) {
LocalDeclaration local = binding.declaration;
JavaElement parent = null;
ReferenceContext referenceContext = binding.declaringScope.referenceContext();
if (referenceContext instanceof AbstractMethodDeclaration) {
AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext;
parent = this.getJavaElementOfCompilationUnit(methodDeclaration, methodDeclaration.binding);
} else if (referenceContext instanceof TypeDeclaration){
// Local variable is declared inside an initializer
TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext;
JavaElement type = this.getJavaElementOfCompilationUnit(typeDeclaration, typeDeclaration.binding);
parent = Util.getUnresolvedJavaElement(local.sourceStart, local.sourceEnd, type);
}
if (parent == null) return null;
return new LocalVariable(
parent,
new String(local.name),
local.declarationSourceStart,
local.declarationSourceEnd,
local.sourceStart,
local.sourceEnd,
Util.typeSignature(local.type),
binding.declaration.annotations,
local.modifiers,
local.getKind() == AbstractVariableDeclaration.PARAMETER);
}