Example usage for org.eclipse.jdt.core.dom MemberValuePair getAST

List of usage examples for org.eclipse.jdt.core.dom MemberValuePair getAST

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom MemberValuePair getAST.

Prototype

public final AST getAST() 

Source Link

Document

Returns this node's AST.

Usage

From source file:com.crispico.flower.mp.codesync.code.java.adapter.JavaMemberValuePairModelAdapter.java

License:Open Source License

@Override
public void setValueFeatureValue(Object element, Object feature, Object value) {
    if (AstCacheCodePackage.eINSTANCE.getAnnotationValue_Name().equals(feature)) {
        MemberValuePair pair = (MemberValuePair) element;
        String name = (String) value;
        pair.setName(pair.getAST().newSimpleName(name));
    }//from  w  w  w  .j a v a2  s.  c o m
    if (AstCacheCodePackage.eINSTANCE.getAnnotationValue_Value().equals(feature)) {
        MemberValuePair pair = (MemberValuePair) element;
        String expression = (String) value;
        pair.setValue(getExpressionFromString(pair.getAST(), expression));
    }
    super.setValueFeatureValue(element, feature, value);
}

From source file:org.eclipse.jpt.common.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter.java

License:Open Source License

/**
 * move the specified, non-null, stand-alone annotation to
 * the container annotation at index=0/* w w w.ja  v  a2s.  com*/
 */
private void moveStandAloneAnnotationToContainerAnnotation(Annotation standAloneAnnotation,
        ModifiedDeclaration declaration) {
    if (standAloneAnnotation.isMarkerAnnotation()) {
        this.zeroNestedAnnotationAdapter.newMarkerAnnotation(declaration);
    } else if (standAloneAnnotation.isSingleMemberAnnotation()) {
        Expression vv = ((SingleMemberAnnotation) standAloneAnnotation).getValue();
        vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
        this.zeroNestedAnnotationAdapter.newSingleMemberAnnotation(declaration).setValue(vv);
    } else if (standAloneAnnotation.isNormalAnnotation()) {
        NormalAnnotation newNA = this.zeroNestedAnnotationAdapter.newNormalAnnotation(declaration);
        List<MemberValuePair> values = this.values(newNA);
        for (MemberValuePair pair : this.values((NormalAnnotation) standAloneAnnotation)) {
            values.add((MemberValuePair) ASTNode.copySubtree(pair.getAST(), pair));
        }
    } else {
        throw new IllegalStateException("unknown annotation type: " + standAloneAnnotation); //$NON-NLS-1$
    }
    this.removeStandAloneAnnotation(declaration);
}

From source file:org.eclipse.jpt.common.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter.java

License:Open Source License

/**
 * move the annotation in the container annotation at index=0
 * to the stand-alone annotation//from  www  . ja  v  a2 s. c o m
 */
private void convertLastElementAnnotationToStandAloneAnnotation(ModifiedDeclaration declaration) {
    Annotation last = this.zeroNestedAnnotationAdapter.getAnnotation(declaration);
    if (last == null) {
        throw new IllegalStateException("the last nested annotation is missing"); //$NON-NLS-1$
    } else if (last.isMarkerAnnotation()) {
        this.newStandAloneMarkerAnnotation(declaration);
    } else if (last.isSingleMemberAnnotation()) {
        Expression vv = ((SingleMemberAnnotation) last).getValue();
        vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
        this.newStandAloneSingleMemberAnnotation(declaration).setValue(vv);
    } else if (last.isNormalAnnotation()) {
        NormalAnnotation newNA = this.newStandAloneNormalAnnotation(declaration);
        List<MemberValuePair> values = this.values(newNA);
        for (MemberValuePair pair : this.values((NormalAnnotation) last)) {
            values.add((MemberValuePair) ASTNode.copySubtree(pair.getAST(), pair));
        }
    } else {
        throw new IllegalStateException("unknown annotation type: " + last); //$NON-NLS-1$
    }
    this.removeContainerAnnotation(declaration);
}

From source file:org.flowerplatform.codesync.code.java.adapter.JavaMemberValuePairModelAdapter.java

License:Open Source License

@Override
public void setValueFeatureValue(Object element, Object feature, Object value) {
    if (CoreConstants.NAME.equals(feature)) {
        MemberValuePair pair = (MemberValuePair) element;
        String name = (String) value;
        pair.setName(pair.getAST().newSimpleName(name));
    } else if (CodeSyncCodeJavaConstants.ANNOTATION_VALUE_VALUE.equals(feature)) {
        MemberValuePair pair = (MemberValuePair) element;
        String expression = (String) value;
        pair.setValue(getExpressionFromString(pair.getAST(), expression));
    }//from   w w  w .j av  a 2 s .  c  om
    super.setValueFeatureValue(element, feature, value);
}

From source file:org.spoofax.interpreter.adapter.ecj.ECJFactory.java

License:LGPL

private MemberValuePair asMemberValuePair(IStrategoTerm term) {
    MemberValuePair x = ((WrappedMemberValuePair) term).getWrappee();
    return x.getParent() == null && x.getAST() == ast ? x : (MemberValuePair) ASTNode.copySubtree(ast, x);
}