}
return makeBinding("unknown", null, null);
}
private ISourceLocation resolveBinding(ASTNode parentNode, VariableDeclaration thisNode) {
ISourceLocation parentBinding = resolveBinding(parentNode);
// Something has to declare it!!!
while(parentBinding.getScheme().equals("unknown") || parentBinding.getScheme().equals("unresolved")) {
if (parentNode == null) {
//truely unresolved/unknown
return makeBinding("unresolved", null, null);
}
parentNode = parentNode.getParent();
parentBinding = resolveBinding(parentNode);
}
// TODO: @ashimshahi please check this additional null check and the way we return an unresolved binding here
IVariableBinding resolvedBinding = thisNode.resolveBinding();
if (resolvedBinding == null) {
return makeBinding("unresolved", null, null);
}
String key = resolvedBinding.getKey();
// Binding keys for initializers are not unique so we always force them to be recomputed
if (!(parentNode instanceof Initializer)) {
if (EclipseJavaCompiler.cache.containsKey(key)) {
return EclipseJavaCompiler.cache.get(key);
}
}
String qualifiedName = parentBinding.getPath();
String[] bindingKeys = key.split("#");
if (bindingKeys.length > 2) {
// scoped variable that may have the same name as some other scoped variable
for (int i = 1; i < bindingKeys.length - 1; i++) {
if (!qualifiedName.endsWith("/"))
qualifiedName += "/";
qualifiedName += "scope("+bindingKeys[i]+")/";
}
}
// FIXME: May not be variable only!!!
ISourceLocation childBinding = makeBinding("java+variable", null, qualifiedName.concat(thisNode.getName().getIdentifier()));
EclipseJavaCompiler.cache.put(key, childBinding);
return childBinding;
}