/* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.StringLiteral)
  */
 public boolean visit(StringLiteral node) {
   PTStringLiteral sl = InstantiationFactory.eINSTANCE.createPTStringLiteral();
   sl.setEscapedValue(node.getEscapedValue());
   sl.setLiteralValue(node.getLiteralValue());
   expression = sl;
   return false;
 }
 private void printAnnotationValue(AST ast, Object value) {
   if (value == null) {
     print("nil");
   } else if (value instanceof IVariableBinding) {
     IVariableBinding var = (IVariableBinding) value;
     ITypeBinding declaringClass = var.getDeclaringClass();
     printf("[%s %s]", NameTable.getFullName(declaringClass), var.getName());
   } else if (value instanceof ITypeBinding) {
     ITypeBinding type = (ITypeBinding) value;
     printf("[[%s class] getClass]", NameTable.getFullName(type));
   } else if (value instanceof String) {
     StringLiteral node = ast.newStringLiteral();
     node.setLiteralValue((String) value);
     print(StatementGenerator.generateStringLiteral(node));
   } else if (value instanceof Number || value instanceof Character || value instanceof Boolean) {
     print(value.toString());
   } else if (value.getClass().isArray()) {
     print("[IOSObjectArray arrayWithObjects:(id[]) { ");
     Object[] array = (Object[]) value;
     for (int i = 0; i < array.length; i++) {
       if (i > 0) {
         print(", ");
       }
       printAnnotationValue(ast, array[i]);
     }
     printf(" } count:%d type:[[NSObject class] getClass]]", array.length);
   } else {
     assert false : "unknown annotation value type";
   }
 }
  /**
   * @param method the known TestNG annotation with required parameters
   * @param values array initializer containing StringLiterals for the parameter names
   */
  protected void record(MethodDeclaration method, ArrayInitializer values) {
    List literals = values.expressions();
    List paramNames = new ArrayList(literals.size());
    for (int i = 0; i < literals.size(); i++) {
      StringLiteral str = (StringLiteral) literals.get(i);
      paramNames.add(str.getLiteralValue());
    }

    m_parameters.put(method, paramNames);
  }
  protected LocationInformation getLocationInformation(
      StringLiteral value, JavaContentAssistInvocationContext javaContext) {
    int startPos = value.getStartPosition();
    int invocationOffset = javaContext.getInvocationOffset();
    String literalValue = value.getLiteralValue();
    int length = invocationOffset - startPos;
    if (length > literalValue.length()) {
      length = literalValue.length();
      invocationOffset = startPos + length;
    }
    String filter = literalValue.substring(0, length);

    return new LocationInformation(startPos, invocationOffset, filter, value);
  }
  private List<String> extractValues(Expression paramAttr) {
    List<String> values = Lists.newArrayList();
    if (paramAttr instanceof ArrayInitializer) {
      List<StringLiteral> literals = ((ArrayInitializer) paramAttr).expressions();
      //      List paramNames= new ArrayList(literals.size());
      for (int j = 0; j < literals.size(); j++) {
        StringLiteral str = literals.get(j);
        values.add(str.getLiteralValue());
      }
    } else if (paramAttr instanceof StringLiteral) {
      values.add(((StringLiteral) paramAttr).getLiteralValue());
    }

    return values;
  }
 /* (omit javadoc for this method)
  * Method declared on ASTNode.
  */
 ASTNode clone0(AST target) {
   StringLiteral result = new StringLiteral(target);
   result.setSourceRange(getStartPosition(), getLength());
   result.setEscapedValue(getEscapedValue());
   return result;
 }
Ejemplo n.º 7
0
 public StringLiteral newStringLit(String value) {
   StringLiteral st = ast.newStringLiteral();
   st.setLiteralValue(value);
   return st;
 }
 /*
  * @see ASTVisitor#visit(StringLiteral)
  */
 public boolean visit(StringLiteral node) {
   this.fBuffer.append(node.getEscapedValue());
   return false;
 }
Ejemplo n.º 9
0
 /**
  * Builds a new {@link StringLiteral} instance.
  *
  * @param s the string literal value
  * @return a new string literal
  */
 public StringLiteral string(String s) {
   final StringLiteral sl = ast.newStringLiteral();
   sl.setLiteralValue(s);
   return sl;
 }
 @Override
 protected StringLiteral convertObject(String string, AST ast) {
   StringLiteral stringLiteral = ast.newStringLiteral();
   stringLiteral.setLiteralValue(string);
   return stringLiteral;
 }
Ejemplo n.º 11
0
 @Override
 public void endVisit(StringLiteral node) {
   expressions.push(new VMStringLiteral(node, node.getLiteralValue()));
 }