Exemple #1
0
  public Expression parseAsNameOrAccess(String string) {
    Expression exp = parseAsExpression(string);
    if (exp == null) {
      return null;
    }
    final Expression result[] = new Expression[1];
    exp.accept(
        new AbstractASTExpressionVisitor() {
          public boolean visitName(Name name) {
            result[0] = name;
            return false;
          }

          public boolean visit(ArrayAccess arrayAccess) {
            result[0] = arrayAccess;
            return false;
          }

          public boolean visit(FieldAccess fieldAccess) {
            result[0] = fieldAccess;
            return false;
          }

          public boolean visit(org.eclipse.edt.compiler.core.ast.SubstringAccess substringAccess) {
            result[0] = substringAccess;
            return false;
          }

          public boolean visitExpression(Expression expression) {
            return false;
          }
        });

    return result[0];
  }
Exemple #2
0
  public Expression parseAsLvalue(String string) {
    Expression exp = parseAsExpression(string);
    if (exp == null) {
      return null;
    }
    final Expression result[] = new Expression[1];

    exp.accept(
        new AbstractASTExpressionVisitor() {
          public boolean visitName(Name name) {
            result[0] = name;
            return false;
          }

          public boolean visit(FieldAccess fieldAccess) {
            result[0] = fieldAccess;
            return false;
          }

          public boolean visit(ArrayAccess arrayAccess) {
            result[0] = arrayAccess;
            return false;
          }

          public boolean visitExpression(Expression expression) {
            return false;
          }
        });

    return result[0];
  }
Exemple #3
0
  public SimpleName parseAsSimpleName(String string) {
    Expression exp = parseAsExpression(string);
    if (exp == null) {
      return null;
    }
    final SimpleName result[] = new SimpleName[1];
    exp.accept(
        new AbstractASTExpressionVisitor() {
          public boolean visit(SimpleName simpleName) {
            result[0] = simpleName;
            return false;
          }

          public boolean visitExpression(Expression expression) {
            return false;
          }
        });

    return result[0];
  }