Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.QualifiedName


        } else {
            // A mapping is either being added or removed.
           
            if (argValues.get(0).trim().startsWith("-r")) {
                // Remove an existing mapping.
                QualifiedName calTypeName = QualifiedName.makeFromCompoundName(argValues.get(1));
                userDefined_typeToClassMappings.remove(calTypeName);
            } else {
                // Add a new mapping.
                QualifiedName calTypeName = QualifiedName.makeFromCompoundName(argValues.get(0));
                ModuleName resolvedModuleName = resolveModuleNameInProgram(calTypeName.getModuleName().toSourceText(), true);
                if (resolvedModuleName == null) {
                    getIceLogger().log(
                            Level.INFO,
                            "Unable to resolve CAL type name " + calTypeName + ".");
                    return;
                } else {
                    calTypeName = QualifiedName.make(resolvedModuleName, calTypeName.getUnqualifiedName());
                }
       
                String javaClassName = argValues.get(1);
               
                // Try to find the java class.
View Full Code Here


               
                if (typeName.indexOf('.') == -1) {
                    typeName = getTargetModule().toString() + "." + typeName;
                }
               
                QualifiedName typeConstructorName = QualifiedName.makeFromCompoundName(typeName);
                typeConstructorsToIgnore.add(typeConstructorName);
            }
        }       

        Level origLogLevel = getIceLogger().getLevel();
        if (!verbose) {
            getIceLogger().setLevel(Level.WARNING);
        }
       
        // Get the module type info for the specified module.
        ModuleTypeInfo moduleTypeInfo = getWorkspaceManager().getModuleTypeInfo(moduleName);
        if (moduleTypeInfo == null) {
            throw new NullPointerException("Unable to retrieve type information for module " + moduleName);
        }
       
        // Generate the i/o code.  This is returned in the form of a
        // SourceModel.ModuleDefn and a collection of JavaClassRep.
        IO_Source_Generator.GeneratedIO generatedIO;
        try {
            Map<QualifiedName, JavaTypeName> typeMappings = new HashMap<QualifiedName, JavaTypeName>(builtIn_typeToClassMappings);
            typeMappings.putAll(userDefined_typeToClassMappings);
           
            generatedIO = new IO_Source_Generator().generateIO(
                    moduleTypeInfo,
                    targetPackage,
                    typeConstructorsToIgnore,
                    typeMappings,
                    userDefined_moduleToPackageMappings);

        } catch (UnableToResolveForeignEntityException e) {
            getIceLogger().log(Level.INFO, "Unable to generate java type for module " + moduleName + ":");
            getIceLogger().log(Level.INFO, "  " + e.getCompilerMessage());
            return;
        }
        // Map of QualifiedName -> JavaClassRep
        Map<QualifiedName, JavaClassRep> javaClassReps =
            generatedIO.getJavaClasses();
       
        // The module containing the generated CAL code.
        SourceModel.ModuleDefn moduleDefn =
            generatedIO.getIoModule();
       
        // Determine the root directory for writing out the CAL and Java source.
        File generatedCodeRoot = getGeneratedCodeRoot(moduleName, targetRootProject, targetRootDirectory);
       
        boolean firstWrite = true;
       
        // Write out each Java class.
        for (Map.Entry<QualifiedName, JavaClassRep> entry : javaClassReps.entrySet()) {
            JavaClassRep classRep = (JavaClassRep)entry.getValue();
            QualifiedName qn = (QualifiedName)entry.getKey();
           
            if (writeJavaClass(generatedCodeRoot, moduleName, targetPackage, classRep)) {
                if (firstWrite) {
                    firstWrite = false;
                    for (LogRecord record : generatedIO.getIoLogMessages()) {
View Full Code Here

    public void setInitialValue() {
       
        DataConstructorValueNode valueNode = getDataConstructorValueNode();
        TypeExpr valueNodeTypeExpr = valueNode.getTypeExpr();
       
        QualifiedName typeConstructorName = valueNode.getTypeExpr().rootTypeConsApp().getName();
        DataConstructor[] dataConsList = valueEditorManager.getPerspective().getDataConstructorsForType(typeConstructorName);

        DataConstructor currentDataCons = valueNode.getDataConstructor();

        ValueEditorListener childListener = new ChildValueEditorListener();
View Full Code Here

                return "<html><body><b>Prelude Record</b></body></html>";
               
            } else if (listEntryData instanceof TypeConsApp) {
           
                TypeConsApp typeConsApp = (TypeConsApp) listEntryData;
                QualifiedName typeConsName = typeConsApp.getName();
               
                TypeConstructor typeCons = valueEditorManager.getPerspective().getTypeConstructor(typeConsName);
                return ToolTipHelpers.getEntityToolTip(typeCons, getNamingPolicy(), valueEditorManager.getWorkspace(), invoker);
               
            } else {
View Full Code Here

            if (metadata.getFeatureName().getType() == CALFeatureName.MODULE) {
                if (oldName.getUnqualifiedName().equals(metadata.getFeatureName().getName())) {
                    return CALFeatureName.getModuleFeatureName(newName.getModuleName());
                }
            } else {
                QualifiedName oldMetadataName = QualifiedName.makeFromCompoundName(metadata.getFeatureName().getName());
                if (oldName.getModuleName().equals(oldMetadataName.getModuleName())) {
                    QualifiedName newMetadataName = QualifiedName.make(newName.getModuleName(), oldMetadataName.getUnqualifiedName());
                    return new CALFeatureName(metadata.getFeatureName().getType(), newMetadataName.getQualifiedName());
                }
            }
        // If we are not renaming a module, we only need to rename the metadata if is corresponds to the entity which we are renaming.
        } else {
            if (metadata.getFeatureName().getType() != CALFeatureName.MODULE) {
                QualifiedName oldMetadataName = QualifiedName.makeFromCompoundName(metadata.getFeatureName().getName());
                if (oldName.equals(oldMetadataName)) {
                   return new CALFeatureName(metadata.getFeatureName().getType(), newName.getQualifiedName());
                }
            }
        }
View Full Code Here

        // Display refactoring dialog and recompile dirty modules if any changes are made
       
        RenameRefactoringDialog.Result renameResult = renameDialog.display();
       
        if(renameResult != null){
            QualifiedName qualifiedFromName = QualifiedName.makeFromCompoundName(renameResult.getFromName());
            QualifiedName qualifiedToName = QualifiedName.makeFromCompoundName(renameResult.getToName());
           
            try {
                GemCutterRenameUpdater designUpdater = new GemCutterRenameUpdater(new Status("GemGraph update status"), gemCutter.getTypeChecker(), qualifiedToName, qualifiedFromName, renameResult.getCategory());
                designUpdater.updateTableTop(gemCutter);
            } catch( GemEntityNotPresentException fanpe) {
View Full Code Here

       
        // Display refactoring dialog and recompile dirty modules if any changes are made
       
        RenameRefactoringDialog.Result renameResult = renameDialog.display();
        if(renameResult != null){
            QualifiedName qualifiedFromName = QualifiedName.makeFromCompoundName(renameResult.getFromName());
            QualifiedName qualifiedToName = QualifiedName.makeFromCompoundName(renameResult.getToName());
           
            try {
                GemCutterRenameUpdater designUpdater = new GemCutterRenameUpdater(new Status("GemGraph update status"), gemCutter.getTypeChecker(), qualifiedToName, qualifiedFromName, renameResult.getCategory());
                designUpdater.updateTableTop(gemCutter);
            } catch( GemEntityNotPresentException fanpe) {
View Full Code Here

        // TODO
        // Right now this either replaces the gem text if the gem is defined and the appropriate markers
        // can be found, or fails. If save succeeds, the design view is also written out to an XML file.

        // Determine the name of the gem being saved
        QualifiedName gemName = QualifiedName.make(gemCutter.getWorkingModuleName(), gemToSave.getUnqualifiedName());

        // Get the gem definition.
        String gemDefinition = getGemDefinition(gemToSave, scope);
       
        // Get the gem metadata as functional agent metadata.
View Full Code Here

     * @param gemDesign the design to load.
     * @param loadStatus a Status object for storing the status of the load operation.
     */
    void loadGemDesign(GemDesign gemDesign, Status loadStatus) {
        // Switch to the module the design is from.
        QualifiedName designName = gemDesign.getDesignName();
        ModuleName moduleName = designName.getModuleName();
        if (gemCutter.getWorkspace().getMetaModule(moduleName) != null) {
            gemCutter.changeModuleAndNewTableTop(moduleName, false);
        }
       
        loadXML(gemDesign.getDesignDocument().getDocumentElement(), loadStatus);
       
        // Find the collector that was loaded on the table top.
        String unqualifiedDesignName = designName.getUnqualifiedName();
        Set<CollectorGem> collectors = gemCutter.getTableTop().getGemGraph().getCollectorsForName(unqualifiedDesignName);

        if (collectors.iterator().hasNext()) {
            CollectorGem collectorGem = collectors.iterator().next();
       
View Full Code Here

        };
       
        for (final Category sectionCategory : categories) {
            Set<String> unqualifiedNames = qualificationMap.getUnqualifiedNames(sectionCategory);
            for (final String unqualifiedName : unqualifiedNames) {
                QualifiedName qualifiedName = qualificationMap.getQualifiedName(unqualifiedName, sectionCategory);
               
                if (category == sectionCategory && oldName.equals(qualifiedName)) {
                    qualificationMap.removeQualification(unqualifiedName, sectionCategory);
                    qualificationMap.putQualification(newName.getUnqualifiedName(), newName.getModuleName(), sectionCategory);
                    changesMade = true;
                } else if (category == SourceIdentifier.Category.MODULE_NAME && oldName.getModuleName().equals(qualifiedName.getModuleName())) {
                    qualificationMap.removeQualification(unqualifiedName, sectionCategory);
                    qualificationMap.putQualification(unqualifiedName, newName.getModuleName(), sectionCategory);
                    changesMade = true;
                }
            }
View Full Code Here

TOP

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

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.