/* (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;
 }
  /**
   * @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;
  }
Example #5
0
 @Override
 public void endVisit(StringLiteral node) {
   expressions.push(new VMStringLiteral(node, node.getLiteralValue()));
 }