Example usage for org.aspectj.weaver.patterns DeclareAnnotation isDeclareAtField

List of usage examples for org.aspectj.weaver.patterns DeclareAnnotation isDeclareAtField

Introduction

In this page you can find the example usage for org.aspectj.weaver.patterns DeclareAnnotation isDeclareAtField.

Prototype

public boolean isDeclareAtField() 

Source Link

Usage

From source file:org.eclipse.ajdt.core.parserbridge.AJCompilationUnitStructureRequestor.java

License:Open Source License

public void enterDeclare(int declarationStart, int modifiers, char[] returnType, char[] name,
        int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames,
        char[][] exceptionTypes, DeclareDeclaration decl) {

    nameSourceStart += 8;//from  w  w  w . ja v  a  2 s.c  om
    nameSourceEnd = nameSourceStart;
    Object parentInfo = this.infoStack.peek();
    JavaElement parentHandle = (JavaElement) this.handleStack.peek();
    DeclareElement handle = null;

    DeclareElementInfo info = new DeclareElementInfo();

    if (decl.declareDecl instanceof DeclareErrorOrWarning) {
        if (((DeclareErrorOrWarning) decl.declareDecl).isError()) {
            info.setAJKind(IProgramElement.Kind.DECLARE_ERROR);
            nameSourceEnd += 4;
        } else {
            info.setAJKind(IProgramElement.Kind.DECLARE_WARNING);
            nameSourceEnd += 6;
        }
    } else if (decl.declareDecl instanceof DeclareParents) {
        info.setAJKind(IProgramElement.Kind.DECLARE_PARENTS);
        nameSourceEnd += 6;
    } else if (decl.declareDecl instanceof DeclarePrecedence) {
        info.setAJKind(IProgramElement.Kind.DECLARE_PRECEDENCE);
        nameSourceEnd += 9;
    } else if (decl.declareDecl instanceof DeclareAnnotation) {
        DeclareAnnotation anno = (DeclareAnnotation) decl.declareDecl;
        if (anno.isDeclareAtConstuctor()) {
            info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR);
            nameSourceEnd += "@constructor".length() - 1; //$NON-NLS-1$
        } else if (anno.isDeclareAtField()) {
            info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD);
            nameSourceEnd += "@field".length() - 1; //$NON-NLS-1$
        } else if (anno.isDeclareAtMethod()) {
            info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD);
            nameSourceEnd += "@method".length() - 1; //$NON-NLS-1$
        } else if (anno.isDeclareAtType()) {
            info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE);
            nameSourceEnd += "@type".length() - 1; //$NON-NLS-1$
        }

        info.setAnnotationRemover(anno.isRemover());
    } else {
        //assume declare soft
        info.setAJKind(IProgramElement.Kind.DECLARE_SOFT);
        nameSourceEnd += 3;
    }
    String nameString = info.getAJKind().toString();

    // translate nulls to empty arrays
    if (parameterTypes == null) {
        parameterTypes = CharOperation.NO_CHAR_CHAR;
    }
    if (parameterNames == null) {
        parameterNames = CharOperation.NO_CHAR_CHAR;
    }
    if (exceptionTypes == null) {
        exceptionTypes = CharOperation.NO_CHAR_CHAR;
    }

    String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);

    handle = new DeclareElement(parentHandle, nameString, parameterTypeSigs);

    resolveDuplicates(handle);

    info.setSourceRangeStart(declarationStart);
    int flags = modifiers;
    info.setName(nameString.toCharArray());
    info.setNameSourceStart(nameSourceStart);
    info.setNameSourceEnd(nameSourceEnd);
    info.setFlags(flags);
    info.setArgumentNames(parameterNames);
    //info.setArgumentTypeNames(parameterTypes);
    info.setReturnType(returnType == null ? VOID : returnType);
    info.setExceptionTypeNames(exceptionTypes);

    addToChildren(parentInfo, handle);
    this.newElements.put(handle, info);
    this.infoStack.push(info);
    this.handleStack.push(handle);
}