Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ModuleTypeInfo


     */
    boolean shouldAcceptTypeConsBasedOnScopeOnly(ModuleName moduleName, String unqualifiedName) {
        ////
        /// First the entity must exist for its documentation to be generated.
        //
        ModuleTypeInfo moduleTypeInfo = programModelManager.getModuleTypeInfo(moduleName);
        if (moduleTypeInfo == null) {
            return false;
        } else {
            ScopedEntity entity = moduleTypeInfo.getTypeConstructor(unqualifiedName);
            if (entity == null) {
                return false;
            } else {
                ////
                /// Having found the entity, now defer to the user-specified filter for the final answer.
View Full Code Here


     */
    boolean isDocForDataConsGenerated(ModuleName moduleName, String unqualifiedName) {
        ////
        /// First the entity must exist for its documentation to be generated.
        //
        ModuleTypeInfo moduleTypeInfo = programModelManager.getModuleTypeInfo(moduleName);
        if (moduleTypeInfo == null) {
            return false;
        } else {
            ScopedEntity entity = moduleTypeInfo.getDataConstructor(unqualifiedName);
            if (entity == null) {
                return false;
            } else {
                ////
                /// Having found the entity, now defer to the user-specified filter for the final answer.
View Full Code Here

     */
    boolean isDocForFunctionOrClassMethodGenerated(ModuleName moduleName, String unqualifiedName) {
        ////
        /// First the entity must exist for its documentation to be generated.
        //
        ModuleTypeInfo moduleTypeInfo = programModelManager.getModuleTypeInfo(moduleName);
        if (moduleTypeInfo == null) {
            return false;
        } else {
            ScopedEntity entity = moduleTypeInfo.getFunctionOrClassMethod(unqualifiedName);
            if (entity == null) {
                return false;
            } else {
                ////
                /// Having found the entity, now defer to the user-specified filter for the final answer.
View Full Code Here

     */
    boolean isDocForTypeClassGenerated(ModuleName moduleName, String unqualifiedName) {
        ////
        /// First the entity must exist for its documentation to be generated.
        //
        ModuleTypeInfo moduleTypeInfo = programModelManager.getModuleTypeInfo(moduleName);
        if (moduleTypeInfo == null) {
            return false;
        } else {
            ScopedEntity entity = moduleTypeInfo.getTypeClass(unqualifiedName);
            if (entity == null) {
                return false;
            } else {
                ////
                /// Having found the entity, now defer to the user-specified filter for the final answer.
View Full Code Here

     * @param moduleName the name of the type constructor's module.
     * @param unqualifiedName the unqualified name of the type constructor.
     * @return the scope of the type constructor.
     */
    Scope getTypeConstructorScope(ModuleName moduleName, String unqualifiedName) {
        ModuleTypeInfo moduleTypeInfo = programModelManager.getModuleTypeInfo(moduleName);
        if (moduleTypeInfo == null) {
            return Scope.PRIVATE;
        } else {
            ScopedEntity entity = moduleTypeInfo.getTypeConstructor(unqualifiedName);
            if (entity == null) {
                return Scope.PRIVATE;
            } else {
                return entity.getScope();
            }
View Full Code Here

                            return;
                        }
                    }
                }
               
                ModuleTypeInfo typeInfo;
                ModuleName resolvedModuleName = resolveModuleNameInWorkspace(moduleNamePattern, false); // false so that no warning is logged if the module does not exist - it may be a regular expression
                if (resolvedModuleName == null) {
                    typeInfo = null;
                } else {
                    typeInfo = workspaceManager.getModuleTypeInfo(resolvedModuleName);
View Full Code Here

            ModuleName moduleName,
            String targetPackage,
            boolean publicEntities,
            boolean testOnly) {
       
        ModuleTypeInfo typeInfo = workspaceManager.getModuleTypeInfo(moduleName);
        if (typeInfo == null) {
            iceLogger.log(Level.INFO, "The module " + moduleName + " does not exist in the current workspace.");
            return;
        }
       
        if (testOnly) {
            String fullClassName = JavaBindingGenerator.getPackageName(targetPackage, moduleName) + '.' + JavaBindingGenerator.getClassName(moduleName, publicEntities);
            try {
                if(JavaBindingGenerator.checkJavaBindingClass(typeInfo, targetPackage, publicEntities, false)) {
                    iceLogger.log(Level.INFO, "The binding class " + fullClassName + (publicEntities ? " for the public members of " : " for the non-public members of ") + moduleName + " is up to date.");
                } else {
                    iceLogger.log(Level.INFO, "WARNING:");
                    iceLogger.log(Level.INFO, "The binding class " + fullClassName + (publicEntities ? " for the public members of " : " for the non-public members of ") + moduleName + " is not up to date.");
                }
            } catch (UnableToResolveForeignEntityException e) {
                iceLogger.log(Level.INFO, "Unable to check the java binding file for module " + moduleName + ":");
                iceLogger.log(Level.INFO, "  " + e.getCompilerMessage());
            }
            return;
        }
       
        // Generate the source for the Java binding class.
        final String text;
        try {
            text = JavaBindingGenerator.getJavaBinding(typeInfo, targetPackage, publicEntities);
           
        } catch (UnableToResolveForeignEntityException e) {
            iceLogger.log(Level.INFO, "Unable to generate the java binding file for module " + moduleName + ":");
            iceLogger.log(Level.INFO, "  " + e.getCompilerMessage());
            return;
        }
       
        // Need to find where to write the file.
        String location = getModulePath(moduleName);
        if (location == null) {
            iceLogger.log(Level.INFO, "Unable to determine location for java binding file for module " + moduleName + ".");
            return;
        }
       
        // Generally this location will follow the pattern of project_root\src\cal\module.cal or
        // project_root\test\cal\module.cal.  However, if the Eclipse project has its output
        // set to a different directory, such as 'bin', the CAL source file will be in
        // project_root\bin\module.cal.
       
        File root = null;
        while (root == null) {
            if (location.indexOf(File.separator + "src" + File.separator) != -1) {
                root = new File(location.substring(0,location.indexOf(File.separator + "src" + File.separator) + 5));
            } else
            if (location.indexOf(File.separator + "test" + File.separator) != -1) {
                root = new File(location.substring(0,location.indexOf(File.separator + "test" + File.separator) + 6));
            } else
            if (location.indexOf(File.separator + "bin" + File.separator) != -1) {
                root = new File(location.substring(0,location.indexOf(File.separator + "bin" + File.separator)));
                // This should be the project root.  Try to find the location of the CAL
                // source file.
                File[] files = root.listFiles();
                root = null;
               
                for (int i = 0; i < files.length; ++i) {
                    File f = files[i];
                    if (f.isDirectory() && !f.getName().equals("bin")) {
                        root = findFile(f, moduleName + ".cal");
                        if (root != null) {
                            break;
                        }
                    }
                }
               
                if (root != null) {
                    // At this point root is the location of the CAL source other than the bin directory.
                    // Reset the location string and keep going.
                    location = root.getAbsolutePath();
                    root = null;
                } else {
                    // We couldn't find a location other than the one in the bin directory.
                    // Exit the loop and try moving relative to the CAL source location.
                    root = null;
                    break;
                }
            } else {
                break;
            }
        }
       
        if (root == null) {
            // Go up one directory from the CAL source location
            // and then add on org\openquark\cal\module
            File f = new File (location);
            f = f.getParentFile();
            if (f.getName().equals("CAL")) {
                f = f.getParentFile();
            }
            root = f;
        }   
       
        String actualPackage;
        if (targetPackage != null) {
            actualPackage = JavaBindingGenerator.getPackageName(targetPackage.trim(), typeInfo.getModuleName());
        } else {
            actualPackage = JavaBindingGenerator.getPackageName(targetPackage, typeInfo.getModuleName());
        }
       
        String packageDirs = actualPackage.replace('.', File.separatorChar);
       
        File bindingLocation = new File (root, packageDirs);
        if (!bindingLocation.exists()) {
            // Try to create the containing directory.
            if (!bindingLocation.mkdirs()) {
                iceLogger.log(Level.INFO, "Unable to create necessary directory " + bindingLocation.getPath() + ".");
                return;
            } else {
                iceLogger.log(Level.INFO, "Directory " + bindingLocation.getPath() + " created.");
            }
        }
       
        // We differentiate the generated classes for public vs. private module elements.
        bindingLocation = new File(bindingLocation, JavaBindingGenerator.getClassName(typeInfo.getModuleName(), publicEntities) + ".java");
       
        if (bindingLocation.exists()) {
            try {
                // Check to see if there is a difference between the new source
                // and the existing source.
View Full Code Here

           
            if (oldNameAsQualifiedName != null) {
                ModuleName moduleName = oldNameAsQualifiedName.getModuleName();
                String unqualifiedName = oldNameAsQualifiedName.getUnqualifiedName();
               
                ModuleTypeInfo moduleTypeInfo = getWorkspaceManager().getModuleTypeInfo(moduleName);
                if(moduleTypeInfo != null) {

                    if(moduleTypeInfo.getFunctionOrClassMethod(unqualifiedName) != null) {
                        entityCategories.add(Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD);
                    }

                    if(moduleTypeInfo.getDataConstructor(unqualifiedName) != null) {
                        entityCategories.add(Category.DATA_CONSTRUCTOR);
                    }

                    if(moduleTypeInfo.getTypeConstructor(unqualifiedName) != null) {
                        entityCategories.add(Category.TYPE_CONSTRUCTOR);
                    }

                    if(moduleTypeInfo.getTypeClass(unqualifiedName) != null) {
                        entityCategories.add(Category.TYPE_CLASS);
                    }
                }
            }
           
View Full Code Here

       
        if(category == Category.MODULE_NAME) {
            return getWorkspaceManager().hasModuleInProgram(qualifiedName.getModuleName());
        }

        ModuleTypeInfo moduleTypeInfo = getWorkspaceManager().getModuleTypeInfo(qualifiedName.getModuleName());
        if(category == Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD) {
            return (moduleTypeInfo.getFunctionOrClassMethod(qualifiedName.getUnqualifiedName()) != null);

        } else if(category == Category.DATA_CONSTRUCTOR) {
            return (moduleTypeInfo.getDataConstructor(qualifiedName.getUnqualifiedName()) != null);

        } else if(category == Category.TYPE_CONSTRUCTOR) {
            return (moduleTypeInfo.getTypeConstructor(qualifiedName.getUnqualifiedName()) != null);
           
        } else if(category == Category.TYPE_CLASS) {
            return (moduleTypeInfo.getDataConstructor(qualifiedName.getUnqualifiedName()) != null);
       
        } else {
            throw new IllegalArgumentException("invalid category " + category);
        }
    }
View Full Code Here

            argi++;
        } else {
            moduleName = targetModule;
        }

        ModuleTypeInfo moduleTypeInfo = getWorkspaceManager().getModuleTypeInfo(moduleName);     

       
        //are optional function names present
        final HashSet<String> functionNames = new HashSet<String>();
        while (args.length > argi && LanguageInfo.isValidFunctionName(args[argi])) {

            //make sure the function exists
            if (moduleTypeInfo.getFunction(args[argi]) == null) {
                iceLogger
                .log(Level.INFO,
                        "Invalid arguments:  function " + args[argi]+" does not exist in module " + moduleName);
                return;
            }
View Full Code Here

TOP

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

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.