Beispiel #1
0
 public static boolean isPrimitiveConstant(IVariableBinding binding) {
   return isFinal(binding)
       && binding.getType().isPrimitive()
       && binding.getConstantValue() != null
       // Exclude local variables declared final.
       && binding.getDeclaringClass() != null;
 }
 @Override
 public boolean visit(SimpleName node) {
   List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
   if (path != null) {
     if (path.size() == 1 && path.get(0).getConstantValue() != null) {
       IVariableBinding var = path.get(0);
       node.replaceWith(TreeUtil.newLiteral(var.getConstantValue()));
     } else {
       node.replaceWith(Name.newName(fixPath(path)));
     }
   }
   return true;
 }
Beispiel #3
0
 public static boolean isStringConstant(IVariableBinding binding) {
   Object constantValue = binding.getConstantValue();
   return constantValue != null
       && constantValue instanceof String
       && UnicodeUtils.hasValidCppCharacters((String) constantValue);
 }