Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeClass


            }
            nameToFuncInfo.put(fe.getName().getUnqualifiedName(), fe);
        }
       
        for (int i = 0, n = moduleTypeInfo.getNTypeClasses(); i < n; ++i) {
            TypeClass tc = moduleTypeInfo.getNthTypeClass(i);

           
            for (int j = 0, k = tc.getNClassMethods(); j < k; ++j) {
                ClassMethod cm = tc.getNthClassMethod(j);
                if (cm.getScope().isPublic() == publicEntities) {
                    nameToFuncInfo.put(cm.getName().getUnqualifiedName(), cm);
                }
            }
        }
View Full Code Here


        typeClassClass.setJavaDoc(jdc);

        // Build up a list of TypeClass names and sort.
        List<String> typeClassNames = new ArrayList<String>();
        for (int i = 0, n = moduleTypeInfo.getNTypeClasses(); i < n; ++i) {
            TypeClass tc = moduleTypeInfo.getNthTypeClass(i);
            if (tc.getScope().isPublic() != publicEntities) {
                continue;
            }
            typeClassNames.add(tc.getName().getUnqualifiedName());
        }
        Collections.sort(typeClassNames);
       
        if (typeClassNames.size() == 0) {
            return;
        }
       
        bindingClass.addInnerClass(typeClassClass);

        // Generate a QualifiedName field for each type class.
        for (final String typeClassName : typeClassNames) {
            TypeClass tc = moduleTypeInfo.getTypeClass(typeClassName);
            // Add a field for the TypeClass name.
            // 'static final String typeClassName = "typeClassName";'
            // We need to check for conflict between the functionName
            // and java keywords.  It is valid to have a CAL
            // function called assert but not valid to have java code
            // 'static final QualifiedName assert = ...
            String fieldName = fixupVarName(typeClassName);
           
            // Since TypeClass names are capitalized it's possible to have a conflict
            // between the name of the field and the name of the top level class.
            if (fieldName.equals(this.bindingClassName)) {
                fieldName = fieldName + "_";
            }
           
            JavaFieldDeclaration jfd =
                makeQualifiedNameDeclaration(fieldName, typeClassName);

            // Add JavaDoc.  We use any CALDoc for the type class if available.
            JavaDocComment comment;
            CALDocComment cdc = tc.getCALDocComment();
            if (cdc != null) {
                comment = new JavaDocComment(calDocCommentToJavaComment(cdc, null, false));
            } else {
                comment = new JavaDocComment("/** Name binding for TypeClass: " + tc.getName().getQualifiedName() + ". */");
            }
            jfd.setJavaDoc(comment);
           
            typeClassClass.addFieldDeclaration(jfd);
        }
View Full Code Here

                    caldocComments.put("data cons " + dataCons.getName().getQualifiedName(), dataCons.getCALDocComment());
                }
            }
           
            for (int i = 0, n = moduleInfo.getNTypeClasses(); i < n; i++) {
                final TypeClass typeClass = moduleInfo.getNthTypeClass(i);
                caldocComments.put("class " + typeClass.getName().getQualifiedName(), typeClass.getCALDocComment());

                for (int j = 0, m = typeClass.getNClassMethods(); j < m; j++) {
                    final ClassMethod method = typeClass.getNthClassMethod(j);
                    caldocComments.put("class method " + method.getName().getQualifiedName(), method.getCALDocComment());
                }
            }
           
            for (int i = 0, n = moduleInfo.getNClassInstances(); i < n; i++) {
                final ClassInstance instance = moduleInfo.getNthClassInstance(i);
                final TypeClass typeClass = instance.getTypeClass();
               
                caldocComments.put("instance " + instance.getNameWithContext(), instance.getCALDocComment());

                for (int j = 0, m = typeClass.getNClassMethods(); j < m; j++) {
                    final ClassMethod method = typeClass.getNthClassMethod(j);
                    caldocComments.put(
                        "instance method " + instance.getNameWithContext() + " " + method.getName().getQualifiedName(),
                        method.getCALDocComment());
                }
            }
View Full Code Here

            emptyModuleStatusStr = GemCutter.getResourceString("RNRD_EmptyModuleStatusTypeCons");
           
        } else if ( entityType == EntityType.TypeClass ) {
           
            for (int i = 0, n = module.getTypeInfo().getNTypeClasses(); i < n; i++) {
                TypeClass typeClass = module.getTypeInfo().getNthTypeClass(i);
                if(typeClass.getName().getModuleName().equals(module.getName())) {
                    entityList.add(typeClass.getName().getUnqualifiedName());
                }
            }
            emptyModuleComboStr = GemCutter.getResourceString("RNRD_EmptyModuleComboTypeClass");
            emptyModuleStatusStr = GemCutter.getResourceString("RNRD_EmptyModuleStatusTypeClass");
        }
View Full Code Here

           
            // We need to determine whether the existing enumeration has only a derived Eq instance,
            // or the full complement of derived instances (i.e. Eq, Ord, Bounded, Enum), so that
            // the correct selection can be shown in the derived instances combo box.
           
            TypeClass ordTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Ord);
            ClassInstance ordInstance = workingModuleTypeInfo.getVisibleClassInstance(ordTypeClass, typeCons);
           
            TypeClass boundedTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Bounded);
            ClassInstance boundedInstance = workingModuleTypeInfo.getVisibleClassInstance(boundedTypeClass, typeCons);
           
            TypeClass enumTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Enum);
            ClassInstance enumInstance = workingModuleTypeInfo.getVisibleClassInstance(enumTypeClass, typeCons);
           
            if (ordInstance == null && boundedInstance == null && enumInstance == null) {
                getDerivedInstancesField().setSelectedItem(DerivedInstancesOption.EQ_ONLY_DERIVED_INSTANCES_OPTION);
            } else {
View Full Code Here

            List<NavTreeNode> classNodes = new ArrayList<NavTreeNode>(classCount);
           
            for (int i = 0; i < classCount; i++) {
   
                TypeClass typeClass = moduleInfo.getNthTypeClass(i);
   
                NavTreeNode typeClassNode = new NavTypeClassNode(typeClass);
                classNodes.add(typeClassNode);
   
                // Load the class methods.
                int methodCount = typeClass.getNClassMethods();
                if (methodCount > 0) {
   
                    List<NavClassMethodNode> classMethodNodes = new ArrayList<NavClassMethodNode>(methodCount);               
                    for (int n = 0; n < methodCount; n++) {
                        classMethodNodes.add(new NavClassMethodNode(typeClass.getNthClassMethod(n)));
                    }

                    addAllNodes(typeClassNode, classMethodNodes, false);
                }
            }
View Full Code Here

                buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
               
            } else if (metadata instanceof TypeClassMetadata) {
                QualifiedName qualifiedName = featureName.toQualifiedName();
                ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(qualifiedName.getModuleName()).getTypeInfo();
                TypeClass typeClass = moduleTypeInfoForFeature.getTypeClass(qualifiedName.getUnqualifiedName());
               
                CALDocComment caldoc = typeClass.getCALDocComment();
                buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
                buffer.append(getTypeClassMetadataHtml(owner, (TypeClassMetadata) metadata));
                buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
               
            } else if (metadata instanceof TypeConstructorMetadata) {
View Full Code Here

     * @param metadata the metadata to get HTML for
     * @return the HTML for type class metadata specific information
     */
    private static String getTypeClassMetadataHtml(NavFrameOwner owner, TypeClassMetadata metadata) {

        TypeClass typeClass = (TypeClass) owner.getPerspective().getWorkspace().getScopedEntity(metadata.getFeatureName());
        StringBuilder buffer = new StringBuilder();

        ScopedEntityNamingPolicy namingPolicy = new UnqualifiedUnlessAmbiguous(owner.getPerspective().getWorkingModuleTypeInfo());
       
        // list the parent classes of the class       
        buffer.append("<h2>" + getAnchorHtml(PARENTS_ANCHOR, NavigatorMessages.getString("NAV_ParentClasses_Header")) + "</h2>");
        int count = typeClass.getNParentClasses();
       
        if (count == 0) {
            buffer.append(NavigatorMessages.getString("NAV_NoValue"));
           
        } else {

            SortedSet<TypeClass> parents = new TreeSet<TypeClass>(new ScopedEntityQualifiedComparator());
           
            for (int i = 0; i < count; i++) {
                parents.add(typeClass.getNthParentClass(i));
            }
           
            buffer.append("<tt>");
            for (final TypeClass parentClass : parents) {
                NavAddress parentUrl = NavAddress.getAddress(parentClass);
                buffer.append(getLinkHtml(parentUrl, NavAddressHelper.getDisplayText(owner, parentUrl, namingPolicy)) + ", ");
            }
   
            // remove trailing comma
            buffer.delete(buffer.length() - 2, buffer.length());
            buffer.append("</tt>");
        }
       
        // list the class methods of this class
        buffer.append("<h2>" + getAnchorHtml(METHODS_ANCHOR, NavigatorMessages.getString("NAV_ClassMethods_Header")) + "</h2>");
       
        buffer.append("<tt>");
       
        count = typeClass.getNClassMethods();
        for (int i = 0; i < count; i++) {
            ClassMethod method = typeClass.getNthClassMethod(i);
            NavAddress methodUrl = NavAddress.getAddress(method);
            buffer.append("<b>" + getLinkHtml(methodUrl, NavAddressHelper.getDisplayText(owner, methodUrl, ScopedEntityNamingPolicy.UNQUALIFIED) + "</b> :: "));
            buffer.append("<i>" + getTypeStringHtml(owner, method.getTypeExpr(), namingPolicy) + "</i>");
            buffer.append("<br>");
        }
       
        // remove trailing <br>
        buffer.delete(buffer.length() - 4, buffer.length());
        buffer.append("</tt>");
       
        // we have to search all instances in all modules to see if they're an instance of this class
        CALWorkspace workspace = owner.getPerspective().getWorkspace();
        List<ClassInstance> instances = new ArrayList<ClassInstance>();
        List<TypeConstructor> types = new ArrayList<TypeConstructor>();
       
        for (int n = 0, numMods = workspace.getNMetaModules(); n < numMods; n++) {
           
            MetaModule metaModule = workspace.getNthMetaModule(n);
            ModuleTypeInfo moduleTypeInfo = metaModule.getTypeInfo();
           
            for (int i = 0, num = moduleTypeInfo.getNClassInstances(); i < num; i++) {
               
                ClassInstance instance = moduleTypeInfo.getNthClassInstance(i);
                if (instance.isUniversalRecordInstance()) {
                    continue;
                }
               
                if (instance.getTypeClass().getName().equals(typeClass.getName())) {                  
                    QualifiedName typeConsName = ((TypeConsApp)instance.getType()).getName();
                    MetaModule typeModule = owner.getPerspective().getMetaModule(typeConsName.getModuleName());
                    TypeConstructor typeCons = typeModule.getTypeInfo().getTypeConstructor(typeConsName.getUnqualifiedName());
                    types.add(typeCons);
                    instances.add(instance);
View Full Code Here

        ScopedEntityNamingPolicy namingPolicy = new UnqualifiedUnlessAmbiguous(owner.getPerspective().getWorkingModuleTypeInfo());       
        ClassInstanceIdentifier identifier = metadata.getFeatureName().toInstanceIdentifier();
               
        CALFeatureName className = CALFeatureName.getTypeClassFeatureName(identifier.getTypeClassName());       
        TypeClass typeClass = (TypeClass) owner.getPerspective().getWorkspace().getScopedEntity(className);
       
        // list the instance class and type       
        buffer.append("<h2>" + getAnchorHtml(INSTANCE_CLASS_ANCHOR, NavigatorMessages.getString("NAV_InstanceClass_Header")) + "</h2>");
        buffer.append(getLinkHtml(NavAddress.getAddress(typeClass), typeClass.getAdaptedName(namingPolicy)));
       
        if (identifier instanceof ClassInstanceIdentifier.TypeConstructorInstance) {              
            CALFeatureName typeName = CALFeatureName.getTypeConstructorFeatureName(((ClassInstanceIdentifier.TypeConstructorInstance)identifier).getTypeConsName());
            TypeConstructor typeCons = (TypeConstructor) owner.getPerspective().getWorkspace().getScopedEntity(typeName);
            buffer.append("<h2>" + getAnchorHtml(INSTANCE_TYPE_ANCHOR, NavigatorMessages.getString("NAV_InstanceType_Header")) + "</h2>");
            buffer.append(getLinkHtml(NavAddress.getAddress(typeCons), typeCons.getAdaptedName(namingPolicy)));
        }
       
        // list the instance methods of this instance
        buffer.append("<h2>" + getAnchorHtml(INSTANCE_METHODS_ANCHOR, NavigatorMessages.getString("NAV_InstanceMethods_Header")) + "</h2>");
       
        buffer.append("<tt>");
       
        ModuleTypeInfo featureModuleTypeInfo = owner.getPerspective().getMetaModule(metadata.getFeatureName().toModuleName()).getTypeInfo();
        ClassInstance instance = featureModuleTypeInfo.getClassInstance(identifier);
       
        int count = instance.getNInstanceMethods();
        for (int i = 0; i < count; i++) {
            ClassMethod method = typeClass.getNthClassMethod(i);
            String methodName = method.getName().getUnqualifiedName();
           
            NavAddress methodUrl = NavAddress.getAddress(CALFeatureName.getInstanceMethodFeatureName(identifier, metadata.getFeatureName().toModuleName(), methodName));
            buffer.append("<b>" + getLinkHtml(methodUrl, NavAddressHelper.getDisplayText(owner, methodUrl, ScopedEntityNamingPolicy.UNQUALIFIED) + "</b> :: "));
            buffer.append("<i>" + getTypeStringHtml(owner, instance.getInstanceMethodType(i), namingPolicy) + "</i>");
View Full Code Here

            } else if (metadata instanceof ClassMethodMetadata) {

                typeString = NavigatorMessages.getString("NAV_ClassMethod_Location");

                // figure out the type class this method belongs to
                TypeClass parentClass = null;
                CALFeatureName methodFeatureName = ((ClassMethodMetadata) metadata).getFeatureName();
                QualifiedName methodName = methodFeatureName.toQualifiedName();
                int classCount = module.getTypeInfo().getNTypeClasses();
               
                for (int i = 0; i < classCount; i++) {
                    TypeClass typeClass = module.getTypeInfo().getNthTypeClass(i);
                   
                    int methodCount = typeClass.getNClassMethods();
                    for (int n = 0; n < methodCount; n++) {
                        if (typeClass.getNthClassMethod(n).getName().equals(methodName)) {
                            parentClass = typeClass;
                            break;
                        }
                    }
                   
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.TypeClass

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.