Example usage for org.eclipse.jdt.core.dom AnnotationTypeMemberDeclaration setName

List of usage examples for org.eclipse.jdt.core.dom AnnotationTypeMemberDeclaration setName

Introduction

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

Prototype

public void setName(SimpleName memberName) 

Source Link

Document

Sets the name of the annotation type member declared in this declaration to the given name.

Usage

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

License:Open Source License

@Override
public void setValueFeatureValue(Object element, Object feature, Object value) {
    if (CodeSyncPackage.eINSTANCE.getCodeSyncElement_Name().equals(feature)) {
        AnnotationTypeMemberDeclaration member = getAnnotationMember(element);
        member.setName(member.getAST().newSimpleName((String) value));
    }//from w w w.  ja  v a2s.c  o m
    if (AstCacheCodePackage.eINSTANCE.getAnnotationMember_DefaultValue().equals(feature)) {
        AnnotationTypeMemberDeclaration member = getAnnotationMember(element);
        member.setDefault(getExpressionFromString(member.getAST(), (String) value));
    }
    if (AstCacheCodePackage.eINSTANCE.getTypedElement_Type().equals(feature)) {
        AnnotationTypeMemberDeclaration member = getAnnotationMember(element);
        member.setType(getTypeFromString(member.getAST(), (String) value));
    }
    super.setValueFeatureValue(element, feature, value);
}

From source file:java5totext.input.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration node) {
    AnnotationTypeMemberDeclaration element = (AnnotationTypeMemberDeclaration) this.binding.get(node);
    this.initializeNode(element, node);
    element.setName(node.getName().getIdentifier());
    endVisitBD(node, element);//  w w  w. ja  va2 s .c  om
    if (this.binding.get(node.getType()) != null)
        element.setType((NamedElementRef) this.binding.get(node.getType()));
    if (this.binding.get(node.getDefault()) != null)
        element.setDefault((Expression) this.binding.get(node.getDefault()));
    JDTVisitorUtils.manageBindingDeclaration(element, node.getName(), this);
}

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

public ASTNode convert(
        org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
    checkCanceled();/* w  w w .j a  v a2  s .  c  om*/
    if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
        return null;
    }
    AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration2 = new AnnotationTypeMemberDeclaration(
            this.ast);
    setModifiers(annotationTypeMemberDeclaration2, annotationTypeMemberDeclaration);
    final SimpleName methodName = new SimpleName(this.ast);
    methodName.internalSetIdentifier(new String(annotationTypeMemberDeclaration.selector));
    int start = annotationTypeMemberDeclaration.sourceStart;
    int end = retrieveIdentifierEndPosition(start, annotationTypeMemberDeclaration.sourceEnd);
    methodName.setSourceRange(start, end - start + 1);
    annotationTypeMemberDeclaration2.setName(methodName);
    org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = annotationTypeMemberDeclaration.returnType;
    if (typeReference != null) {
        Type returnType = convertType(typeReference);
        setTypeForMethodDeclaration(annotationTypeMemberDeclaration2, returnType, 0);
    }
    int declarationSourceStart = annotationTypeMemberDeclaration.declarationSourceStart;
    int declarationSourceEnd = annotationTypeMemberDeclaration.bodyEnd;
    annotationTypeMemberDeclaration2.setSourceRange(declarationSourceStart,
            declarationSourceEnd - declarationSourceStart + 1);
    // The javadoc comment is now got from list store in compilation unit declaration
    convert(annotationTypeMemberDeclaration.javadoc, annotationTypeMemberDeclaration2);
    org.eclipse.jdt.internal.compiler.ast.Expression memberValue = annotationTypeMemberDeclaration.defaultValue;
    if (memberValue != null) {
        annotationTypeMemberDeclaration2.setDefault(convert(memberValue));
    }
    if (this.resolveBindings) {
        recordNodes(annotationTypeMemberDeclaration2, annotationTypeMemberDeclaration);
        recordNodes(methodName, annotationTypeMemberDeclaration);
        annotationTypeMemberDeclaration2.resolveBinding();
    }
    return annotationTypeMemberDeclaration2;
}

From source file:org.eclipse.modisco.java.discoverer.internal.io.java.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(final org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration node) {
    AnnotationTypeMemberDeclaration element = (AnnotationTypeMemberDeclaration) this.binding.get(node);
    initializeNode(element, node);// w w w  .  j  av a2  s . c om

    element.setName(node.getName().getIdentifier());

    if (this.binding.get(node.getType()) != null) {
        element.setType(JDTVisitorUtils.completeTypeAccess(this.binding.get(node.getType()), this));
    }

    if (this.binding.get(node.getDefault()) != null) {
        element.setDefault(JDTVisitorUtils.completeExpression(this.binding.get(node.getDefault()), this));
    }

    endVisitBD(node, element);
    JDTVisitorUtils.manageBindingDeclaration(element, node.getName(), this);
}

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

License:Open Source License

@Override
public void setValueFeatureValue(Object element, Object feature, Object value) {
    if (CoreConstants.NAME.equals(feature)) {
        AnnotationTypeMemberDeclaration member = getAnnotationMember(element);
        member.setName(member.getAST().newSimpleName((String) value));
    } else if (CodeSyncCodeJavaConstants.ANNOTATION_MEMBER_DEFAULT_VALUE.equals(feature)) {
        AnnotationTypeMemberDeclaration member = getAnnotationMember(element);
        member.setDefault(getExpressionFromString(member.getAST(), (String) value));
    } else if (CodeSyncCodeJavaConstants.TYPED_ELEMENT_TYPE.equals(feature)) {
        AnnotationTypeMemberDeclaration member = getAnnotationMember(element);
        member.setType(getTypeFromString(member.getAST(), (String) value));
    }//from   w ww  . j  a v a  2s  .  c o m
    super.setValueFeatureValue(element, feature, value);
}

From source file:org.whole.lang.java.util.JDTTransformerVisitor.java

License:Open Source License

public boolean visit(AnnotationTypeMemberDeclaration node) {
    org.whole.lang.java.model.AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration;
    appendBodyDeclaration(annotationTypeMemberDeclaration = lf
            .create(JavaEntityDescriptorEnum.AnnotationTypeMemberDeclaration));

    if (acceptChild(node.getJavadoc()))
        annotationTypeMemberDeclaration.setJavadoc(this.javadoc);

    List<?> modifiers = node.modifiers();
    if (!modifiers.isEmpty()) {
        annotationTypeMemberDeclaration.setModifiers(lf.create(JavaEntityDescriptorEnum.ExtendedModifiers));
        setExtendedModifiers(annotationTypeMemberDeclaration.getModifiers(), modifiers);
    }//  w ww . j a va  2  s. co  m

    acceptChild(node.getName());
    annotationTypeMemberDeclaration.setName((org.whole.lang.java.model.SimpleName) this.name);

    acceptChild(node.getType());
    annotationTypeMemberDeclaration.setType(this.type);

    if (acceptChild(node.getDefault()))
        annotationTypeMemberDeclaration.setDefault(this.exp);

    return false;
}