@Override
 public Void visitLiteral(LiteralTree tree, AnnotatedTypeMirror type) {
   if (!type.isAnnotatedInHierarchy(LOCALIZED)) {
     if (tree.getKind() == Tree.Kind.STRING_LITERAL && tree.getValue().equals("")) {
       type.addAnnotation(LOCALIZED);
     }
   }
   return super.visitLiteral(tree, type);
 }
Exemplo n.º 2
0
 public Void visitLiteral(LiteralTree tree, Void ignore) {
   System.err.println(tree);
   Class expect = map.get(tree.getKind());
   if (!check(tree.getValue(), expect)) {
     System.err.println("tree: " + tree);
     System.err.println("expected class: " + expect);
     if (tree.getValue() != null)
       System.err.println("actual class: " + tree.getValue().getClass());
     throw new AssertionError("unexpected value for literal");
   }
   return null;
 }
 @Override
 public Void visitLiteral(LiteralTree tree, AnnotatedTypeMirror type) {
   if (!type.isAnnotatedInHierarchy(theAnnot)
       && tree.getKind() == Tree.Kind.STRING_LITERAL
       && strContains(lookupKeys, tree.getValue().toString())) {
     type.addAnnotation(theAnnot);
   }
   // A possible extension is to record all the keys that have been used and
   // in the end output a list of keys that were not used in the program,
   // possibly pointing to the opposite problem, keys that were supposed to
   // be used somewhere, but have not been, maybe because of copy-and-paste errors.
   return super.visitLiteral(tree, type);
 }
 @Override
 public Void visitLiteral(LiteralTree tree, AnnotatedTypeMirror type) {
   if (tree.getKind() != Tree.Kind.NULL_LITERAL) {
     type.addAnnotation(COMMITTED);
   }
   return super.visitLiteral(tree, type);
 }
    @Override
    public Void visitLiteral(LiteralTree tree, AnnotatedTypeMirror type) {
      if (isUnderlyingTypeAValue(type)) {
        switch (tree.getKind()) {
          case BOOLEAN_LITERAL:
            AnnotationMirror boolAnno =
                createBooleanAnnotation(Collections.singletonList((Boolean) tree.getValue()));
            type.replaceAnnotation(boolAnno);
            return null;

          case CHAR_LITERAL:
            AnnotationMirror charAnno =
                createCharAnnotation(Collections.singletonList((Character) tree.getValue()));
            type.replaceAnnotation(charAnno);
            return null;

          case DOUBLE_LITERAL:
            AnnotationMirror doubleAnno =
                createNumberAnnotationMirror(
                    Collections.<Number>singletonList((Double) tree.getValue()));
            type.replaceAnnotation(doubleAnno);
            return null;

          case FLOAT_LITERAL:
            AnnotationMirror floatAnno =
                createNumberAnnotationMirror(
                    Collections.<Number>singletonList((Float) tree.getValue()));
            type.replaceAnnotation(floatAnno);
            return null;
          case INT_LITERAL:
            AnnotationMirror intAnno =
                createNumberAnnotationMirror(
                    Collections.<Number>singletonList((Integer) tree.getValue()));
            type.replaceAnnotation(intAnno);
            return null;
          case LONG_LITERAL:
            AnnotationMirror longAnno =
                createNumberAnnotationMirror(
                    Collections.<Number>singletonList((Long) tree.getValue()));
            type.replaceAnnotation(longAnno);
            return null;
          case STRING_LITERAL:
            AnnotationMirror stringAnno =
                createStringAnnotation(Collections.singletonList((String) tree.getValue()));
            type.replaceAnnotation(stringAnno);
            return null;
          default:
            return null;
        }
      }
      return null;
    }
 public CharacterLiteralNode(LiteralTree t) {
   super(t);
   assert t.getKind().equals(Tree.Kind.CHAR_LITERAL);
 }