final IBinding binding = simpleName.resolveBinding();
final ITypeBinding typeBinding = simpleName.resolveTypeBinding();
if (binding.getKind() == IBinding.VARIABLE) {
final IVariableBinding variableBinding = (IVariableBinding) binding;
if (variableBinding.isEnumConstant()) {
final ICPPASTQualifiedName qualifiedName = f.newQualifiedName();
qualifiedName.addName(f.newName(typeBinding.getName().toCharArray()));
qualifiedName.addName(new NameInfo(simpleName).getName());
return f.newIdExpression(qualifiedName);
} else if (((variableBinding.getModifiers() & Modifier.STATIC) != 0) && ((variableBinding.getModifiers() & Modifier.FINAL) != 0)) {
final ICPPASTQualifiedName qualifiedName = f.newQualifiedName();
qualifiedName.addName(f.newName(variableBinding.getDeclaringClass().getName().toCharArray()));
qualifiedName.addName(new NameInfo(simpleName).getName());
return f.newIdExpression(qualifiedName);
} else if (typeDeclaration != null) {
final List<String> tokens = new NameInfo(typeDeclaration.getName()).tokenize();
if ((variableBinding.getDeclaringClass() != null) && !variableBinding.getDeclaringClass().getName().equals(tokens.get(tokens.size() - 1))) {
if (!typeDeclaration.resolveBinding().isSubTypeCompatible(variableBinding.getDeclaringClass())) {