Package com.sun.mirror.type

Examples of com.sun.mirror.type.TypeMirror


                {
                    if ( decl instanceof FieldDeclaration )
                    {
                        FieldDeclaration fd = (FieldDeclaration)decl;
                        TypeDeclaration clientType = fd.getDeclaringType();
                        TypeMirror controlFieldType = fd.getType();
                        addControlType( clientsMap, clientType, controlFieldType );

                        /*
                        Add the control type to any derived class.  Fields with
                        private and default (package) access are also included
                        here as the controls in superclasses may be exposed
                        through public or protected methods to subclasses.
                        */
                        Collection<TypeDeclaration> specifiedTypeDeclartions = env.getSpecifiedTypeDeclarations();
                        for (TypeDeclaration td : specifiedTypeDeclartions)
                        {
                            if (td instanceof ClassDeclaration)
                            {
                                ClassType superclass = ((ClassDeclaration) td).getSuperclass();
                                while (superclass != null)
                                {
                                    if (superclass.getDeclaration().equals(clientType))
                                    {
                                        addControlType(clientsMap, td, controlFieldType);
                                        break;
                                    }

                                    superclass = superclass.getSuperclass();
                                }
                            }
                        }
                    }
                }
            }
            else if (atd.getSimpleName().equals("ControlReferences"))
            {
                Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
                for (Declaration decl : decls)
                {
                    if ( decl instanceof TypeDeclaration )
                    {
                        TypeDeclaration clientType = (TypeDeclaration)decl;
                        Set<TypeMirror> controlTypes = clientsMap.get( clientType );
                        if ( controlTypes == null )
                        {
                            controlTypes = new HashSet<TypeMirror>();
                            clientsMap.put( clientType, controlTypes );
                        }

                        // Read ControlReferences annotation
                        AnnotationMirror controlMirror = null;
                        for (AnnotationMirror annot : clientType.getAnnotationMirrors())
                        {
                            if (annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
                                    "org.apache.beehive.controls.api.bean.ControlReferences"))
                            {
                                controlMirror = annot;
                                break;
                            }
                        }

                        assert( controlMirror != null );

                        // Add each control type listed in the ControlReferences annotation
                        AptAnnotationHelper controlAnnot = new AptAnnotationHelper(controlMirror);
                        Collection<AnnotationValue> references = (Collection<AnnotationValue>)controlAnnot.getObjectValue("value");
                        if ( references != null )
                        {
                            for ( AnnotationValue av : references )
                            {
                                TypeMirror crType = (TypeMirror)av.getValue();
                                controlTypes.add( crType );
                            }
                        }
                    }
                }
View Full Code Here


    {
    }

    private void checkControlField( FieldDeclaration f )
    {
        TypeMirror fieldType = f.getType();

        // Make sure that this field doesn't try to override another that's inherited.
        String fieldName = f.getSimpleName();
        TypeDeclaration declaringType = f.getDeclaringType();
View Full Code Here

        //
        StringBuffer sb = new StringBuffer();
        boolean isFirst = true;
        while (paramBoundIter.hasNext())
        {
            TypeMirror paramBound = paramBoundIter.next();
            TypeParameterDeclaration paramDecl = paramDeclIter.next();

            //
            // Save a mapping from the formal type name to the bound mirror type
            //
View Full Code Here

     * Initializes a ControlInterface associated with this context field.  Because
     * contextual services can expose both APIs and events, they are similar to controls.
     */
    protected AptControlInterface initControlInterface()
    {
        TypeMirror fieldType = _fieldDecl.getType();       
        if (! (fieldType instanceof InterfaceType))
        {
            _ap.printError( _fieldDecl, "context.field.badinterface" );
            return null;
        }
View Full Code Here

    /**
     * Initializes the ControlInterface associated with this ControlField
     */
    protected AptControlInterface initControlInterface()
    {
        TypeMirror controlType = _fieldDecl.getType();
        if (! (controlType instanceof DeclaredType))
        {
            _ap.printError( _fieldDecl, "control.field.bad.type" );
            return null;
        }

        //
        // The field can either be declared as the bean type or the public interface type.
        // If it is the bean type, then we need to reflect to find the public interface
        // type it implements.
        //
        TypeDeclaration typeDecl = ((DeclaredType)controlType).getDeclaration();
        InterfaceDeclaration controlIntf = null;

        //
        // It is possible that the declared type is associated with a to-be-generated
        // bean type.  In this case, look for the associated control interface on the
        // processor input list.
        //
        if ( typeDecl == null )
        {
            String className = controlType.toString();
            String intfName = className.substring(0, className.length() - 4);
            String interfaceHint = getControlInterfaceHint();
            controlIntf = (InterfaceDeclaration)_ap.getAnnotationProcessorEnvironment().getTypeDeclaration(intfName);

            if (controlIntf == null)
View Full Code Here

            }

            //
            // Locate the EventSet based upon the eventSet element value
            //
            TypeMirror tm = (TypeMirror)( handlerAnnot.getObjectValue("eventSet") );
            if ( tm == null )
                continue;
            String setName = tm.toString();
            AptControlInterface controlIntf = eventField.getControlInterface();

            // todo: remove workaround once bug has been resolved.
            /* Workaround for JIRA issue BEEHIVE-1143, eventset name may
               contain a '$' seperator between the outer class and inner class.
               Should be a '.' seperator. Only applies to Eclipse APT. This
               workaround is also present in AptControlClient.initEventAdapters
             */
            if (tm.getClass().getName().startsWith("org.eclipse.")) {
                setName = setName.replace('$', '.');
            }
            // end of workaround

            AptEventSet eventSet = controlIntf.getEventSet(setName);
View Full Code Here

            //
            Object tmo = handlerAnnot.getObjectValue("eventSet");
            if (!(tmo instanceof TypeMirror))
                continue;
           
            TypeMirror tm = (TypeMirror)tmo;
            String setName = tm.toString();

            AptControlInterface controlIntf = eventField.getControlInterface();
            AptEventSet eventSet = controlIntf.getEventSet(setName);

            // todo: remove workaround once bug has been resolved.
            /* Workaround JIRA issue BEEHIVE-1143, eventset name may
               contain a '$' seperator between the outer class and inner class.
               Should be a '.' seperator. Only applies to Eclipse APT. This
               workaround is also present in AptControlImplementation.initEventAdapters
             */
            if (tm.getClass().getName().startsWith("org.eclipse.")) {
                setName = setName.replace('$', '.');
            }
            // end of workaround

            if (eventSet == null)
View Full Code Here

            return "";
       
        int i = 0;
        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            TypeMirror paramType = paramDecl.getType();
            if ( paramType == null )
                return "";
               
            if (bindingMap != null && bindingMap.containsKey(paramType.toString()))
                paramType = bindingMap.get(paramType.toString());

            if (i != 0)
                sb.append(", ");
           
            sb.append(paramType.toString());

            sb.append(' ');

            // BUGBUG: when the MethodDeclaration is derived from Reflection, this seems
            // to return 'arg0' for all arguments!
View Full Code Here

        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            if (i++ != 0)
                sb.append(", ");

            TypeMirror paramType = paramDecl.getType();
            if (paramType == null)
                return "";

            //
            // Use the erasure here, because we only want the raw type, not the reference
View Full Code Here

     */
    public boolean hasParameterizedArguments()
    {
        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            TypeMirror paramType = paramDecl.getType();
            if (paramType instanceof ReferenceType || paramType instanceof WildcardType)
                return true;
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of com.sun.mirror.type.TypeMirror

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.