Package org.aspectj.org.eclipse.jdt.internal.compiler.ast

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral


        if (ans[i].memberValuePairs().length == 0) {
          return ""; // empty pointcut expression
        }
        Expression expr = ans[i].memberValuePairs()[0].value;
        if (expr instanceof StringLiteral) {
          StringLiteral sLit = ((StringLiteral) expr);
          return new String(sLit.source());
        } else if (expr instanceof NameReference && (((NameReference) expr).binding instanceof FieldBinding)) {
          Binding b = ((NameReference) expr).binding;
          Constant c = ((FieldBinding) b).constant;
          return c.stringValue();
        } else {
View Full Code Here


  private String getStringLiteralFor(String memberName, Annotation inAnnotation, int[] location) {
    if (inAnnotation instanceof SingleMemberAnnotation && memberName.equals("value")) {
      SingleMemberAnnotation sma = (SingleMemberAnnotation) inAnnotation;
      if (sma.memberValue instanceof StringLiteral) {
        StringLiteral sv = (StringLiteral) sma.memberValue;
        location[0] = sv.sourceStart;
        location[1] = sv.sourceEnd;
        return new String(sv.source());
      } else if (sma.memberValue instanceof NameReference
          && (((NameReference) sma.memberValue).binding instanceof FieldBinding)) {
        Binding b = ((NameReference) sma.memberValue).binding;
        Constant c = ((FieldBinding) b).constant;
        return c.stringValue();
      }
    }
    if (!(inAnnotation instanceof NormalAnnotation))
      return null;
    NormalAnnotation ann = (NormalAnnotation) inAnnotation;
    MemberValuePair[] mvps = ann.memberValuePairs;
    if (mvps == null)
      return null;
    for (int i = 0; i < mvps.length; i++) {
      if (CharOperation.equals(memberName.toCharArray(), mvps[i].name)) {
        if (mvps[i].value instanceof StringLiteral) {
          StringLiteral sv = (StringLiteral) mvps[i].value;
          location[0] = sv.sourceStart;
          location[1] = sv.sourceEnd;
          return new String(sv.source());
        }
      }
    }
    return null;
  }
View Full Code Here

          SingleMemberAnnotation sma = (SingleMemberAnnotation) this.annotations[i];
          if (sma.memberValue instanceof ArrayInitializer) {
            ArrayInitializer memberValue = (ArrayInitializer) sma.memberValue;
            for (int j = 0; j < memberValue.expressions.length; j++) {
              if (memberValue.expressions[j] instanceof StringLiteral) {
                StringLiteral val = (StringLiteral) memberValue.expressions[j];
                if (new String(val.source()).equals(NOEXPLICITCONSTRUCTORCALL))
                  return true;
              }
            }
          }
        }
View Full Code Here

    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference orgAspectJLangAnnotationAspect = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation atAspectAnnotation = new NormalAnnotation(orgAspectJLangAnnotationAspect,pos);
    if (!perclause.equals("")) {
      // we have to set the value
      Expression perclauseExpr = new StringLiteral(perclause.toCharArray(),pos,pos,1);
      MemberValuePair[] mvps = new MemberValuePair[1];
      mvps[0] = new MemberValuePair(value,pos,pos,perclauseExpr);
      atAspectAnnotation.memberValuePairs = mvps;
    }
    return atAspectAnnotation;
View Full Code Here

  public static Annotation createBeforeAnnotation(String pointcutExpression, String argNames, int pos) {
    char[][] typeName = new char[][] {org,aspectj,lang,annotation,before};
    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference annType = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation ann = new NormalAnnotation(annType,pos);
    Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos,1);
    MemberValuePair[] mvps = new MemberValuePair[2];
    mvps[0] = new MemberValuePair("value".toCharArray(),pos,pos,pcExpr);
    Expression argNamesExpr = new StringLiteral(argNames.toCharArray(),pos,pos,1);
    mvps[1] = new MemberValuePair("argNames".toCharArray(),pos,pos,argNamesExpr);
    ann.memberValuePairs = mvps;
    return ann;
  }
View Full Code Here

  public static Annotation createAfterAnnotation(String pointcutExpression, String argNames, int pos) {
    char[][] typeName = new char[][] {org,aspectj,lang,annotation,after};
    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference annType = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation ann = new NormalAnnotation(annType,pos);
    Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos,1);
    MemberValuePair[] mvps = new MemberValuePair[2];
    mvps[0] = new MemberValuePair("value".toCharArray(),pos,pos,pcExpr);
    Expression argNamesExpr = new StringLiteral(argNames.toCharArray(),pos,pos,1);
    mvps[1] = new MemberValuePair("argNames".toCharArray(),pos,pos,argNamesExpr);
    ann.memberValuePairs = mvps;
    return ann;
  }
View Full Code Here

  public static Annotation createAfterReturningAnnotation(String pointcutExpression,  String argNames, String extraArgumentName, int pos) {
    char[][] typeName = new char[][] {org,aspectj,lang,annotation,afterReturning};
    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference annType = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation ann = new NormalAnnotation(annType,pos);
    Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos,1);
    MemberValuePair[] mvps = new MemberValuePair[3];
    mvps[0] = new MemberValuePair("pointcut".toCharArray(),pos,pos,pcExpr);
    Expression argExpr = new StringLiteral(extraArgumentName.toCharArray(),pos,pos,1);
    mvps[1] = new MemberValuePair("returning".toCharArray(),pos,pos,argExpr);
    Expression argNamesExpr = new StringLiteral(argNames.toCharArray(),pos,pos,1);
    mvps[2] = new MemberValuePair("argNames".toCharArray(),pos,pos,argNamesExpr);
    ann.memberValuePairs = mvps;
    return ann;
  }
View Full Code Here

  public static Annotation createAfterThrowingAnnotation(String pointcutExpression, String argNames, String extraArgumentName, int pos) {
    char[][] typeName = new char[][] {org,aspectj,lang,annotation,afterThrowing};
    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference annType = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation ann = new NormalAnnotation(annType,pos);
    Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos,1);
    MemberValuePair[] mvps = new MemberValuePair[3];
    mvps[0] = new MemberValuePair("pointcut".toCharArray(),pos,pos,pcExpr);
    Expression argExpr = new StringLiteral(extraArgumentName.toCharArray(),pos,pos,1);
    mvps[1] = new MemberValuePair("throwing".toCharArray(),pos,pos,argExpr);
    Expression argNamesExpr = new StringLiteral(argNames.toCharArray(),pos,pos,1);
    mvps[2] = new MemberValuePair("argNames".toCharArray(),pos,pos,argNamesExpr);
    ann.memberValuePairs = mvps;
    return ann;
  }
View Full Code Here

  public static Annotation createAroundAnnotation(String pointcutExpression, String argNames, int pos) {
    char[][] typeName = new char[][] {org,aspectj,lang,annotation,around};
    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference annType = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation ann = new NormalAnnotation(annType,pos);
    Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos,1);
    MemberValuePair[] mvps = new MemberValuePair[2];
    mvps[0] = new MemberValuePair("value".toCharArray(),pos,pos,pcExpr);
    Expression argNamesExpr = new StringLiteral(argNames.toCharArray(),pos,pos,1);
    mvps[1] = new MemberValuePair("argNames".toCharArray(),pos,pos,argNamesExpr);
    ann.memberValuePairs = mvps;
    return ann;
  }
View Full Code Here

  public static Annotation createPointcutAnnotation(String pointcutExpression, String argNames, int pos) {
    char[][] typeName = new char[][] {org,aspectj,lang,annotation,pointcut};
    long[] positions = new long[] {pos,pos,pos,pos,pos};
    TypeReference annType = new QualifiedTypeReference(typeName,positions);
    NormalAnnotation ann = new NormalAnnotation(annType,pos);
    Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos,1);
    MemberValuePair[] mvps = new MemberValuePair[2];
    mvps[0] = new MemberValuePair("value".toCharArray(),pos,pos,pcExpr);
    Expression argExpr = new StringLiteral(argNames.toCharArray(),pos,pos,1);
    mvps[1] = new MemberValuePair("argNames".toCharArray(),pos,pos,argExpr);
    ann.memberValuePairs = mvps;
    return ann; 
  }
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.