Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ModuleTypeInfo


        }
    }
   
    private void validateGemReference(final ScopedEntityReference reference, final String entityName, final WorkspaceManager workspaceManager, final List<String> brokenReferences) {
        if (!reference.isChecked()) {
            final ModuleTypeInfo referencedModuleInfo = workspaceManager.getModuleTypeInfo(reference.getName().getModuleName());
            if (referencedModuleInfo == null || referencedModuleInfo.getFunctionalAgent(reference.getName().getUnqualifiedName()) == null) {
                brokenReferences.add("in CALDoc for " + entityName + ": " + reference);
            }
        }
    }
View Full Code Here


        }
    }
   
    private void validateTypeConsReference(final ScopedEntityReference reference, final String entityName, final WorkspaceManager workspaceManager, final List<String> brokenReferences) {
        if (!reference.isChecked()) {
            final ModuleTypeInfo referencedModuleInfo = workspaceManager.getModuleTypeInfo(reference.getName().getModuleName());
            if (referencedModuleInfo == null || referencedModuleInfo.getTypeConstructor(reference.getName().getUnqualifiedName()) == null) {
                brokenReferences.add("in CALDoc for " + entityName + ": " + reference);
            }
        }
    }
View Full Code Here

        }
    }
   
    private void validateTypeClassReference(final ScopedEntityReference reference, final String entityName, final WorkspaceManager workspaceManager, final List<String> brokenReferences) {
        if (!reference.isChecked()) {
            final ModuleTypeInfo referencedModuleInfo = workspaceManager.getModuleTypeInfo(reference.getName().getModuleName());
            if (referencedModuleInfo == null || referencedModuleInfo.getTypeClass(reference.getName().getUnqualifiedName()) == null) {
                brokenReferences.add("in CALDoc for " + entityName + ": " + reference);
            }
        }
    }
View Full Code Here

     */
    protected Set<TypeExpr> getMatchingInputTypes() {
       
        Set<TypeExpr> dataTypes = getAvailableInputTypes();
        Set<TypeExpr> matchingTypes = new HashSet<TypeExpr>();
        ModuleTypeInfo currentModuleTypeInfo = valueEditorManager.getPerspective().getWorkingModuleTypeInfo();
       
        if (currentModuleTypeInfo != null) {
           
            TypeExpr valueNodeTypeExpr = getValueNode().getTypeExpr();
       
View Full Code Here

        for (int i = 0, n = examples.length; i < n; i++) {
            CALExample curExample = examples[i];
            CALExpression oldExpression = curExample.getExpression();
           
            // Get the qualified version of the new string
            ModuleTypeInfo moduleTypeInfo = moduleContainer.getModuleTypeInfo(oldExpression.getModuleContext());
            if (moduleTypeInfo == null) {
                // The module is not in the workspace.
                String featureName = functionalAgentMetadata.getFeatureName().getName();
                ModuleName moduleContext = oldExpression.getModuleContext();
                String errorMessage = "Can not update the metadata for " + featureName + ", example " + (i + 1) +
                                      ", since its module context " + moduleContext + " is not in the workspace.";
               
                // Add a warning.
                // Unfortunately, warnings are ignored. 
                // However, throwing a RenamingException will cause renaming to fail, which is not what we want.
                status.add(new Status(Status.Severity.WARNING, errorMessage));
                continue;
               
//                throw new RenamingException(errorMessage);
            }
           
            ModuleNameResolver oldExpressionContextModuleNameResolver = moduleTypeInfo.getModuleNameResolver();
            String newExpressionString = typeChecker.calculateUpdatedCodeExpression(oldExpression.getExpressionText(), oldExpression.getModuleContext(), oldExpressionContextModuleNameResolver, oldExpression.getQualificationMap(), oldName, newName, category, null);
           
            CodeAnalyser codeAnalyser = new CodeAnalyser(typeChecker, moduleTypeInfo, false, false);
            MessageLogger logger = new MessageLogger();
            QualificationResults qualificationResults = codeAnalyser.qualifyExpression(newExpressionString, null, oldExpression.getQualificationMap(), logger);
View Full Code Here

             * Returns a list of the names of the gems which have the specified return type and no inputs.
             */
            private List <String> fetchGemsOfType(final TypeExpr returnTypeExpr) {
                GemViewer gemViewer = new GemViewer();
               
                final ModuleTypeInfo moduleTypeInfo = perspective.getWorkingModuleTypeInfo();

                // Create a filter which will find all gems which return the specified type
                // and take no inputs.
                // TODO: add support for gems which do take inputs...
                GemFilter filter = new GemFilter() {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public String getTypeString(final TypeExpr typeExpr) {
        final ScopedEntityNamingPolicy namingPolicy;
        final ModuleTypeInfo currentModuleTypeInfo = getCurrentModuleTypeInfo();
        if (currentModuleTypeInfo == null) {
            namingPolicy = ScopedEntityNamingPolicy.FULLY_QUALIFIED;
        } else {
            namingPolicy = new ScopedEntityNamingPolicy.UnqualifiedUnlessAmbiguous(currentModuleTypeInfo);
        }
View Full Code Here

        String[] nameFragments = javaTypeName.split("\\.");
       
        // By default the type name is simply "J" plus the unqualified class name.
        String typeName = "J" + nameFragments[nameFragments.length - 1] + arrayNameSuffix;

        ModuleTypeInfo workingModuleTypeInfo = perspective.getWorkingModuleTypeInfo();
        boolean outOfFragments = false;
        int fragmentIndex = 2;
       
        while (workingModuleTypeInfo.getTypeConstructor(typeName) != null) {

            // Disambiguate the name by adding additional fragments.

            if (fragmentIndex > nameFragments.length) {
                outOfFragments = true;
                break;
            }
           
            String newFragment = nameFragments[nameFragments.length - fragmentIndex];
            newFragment = newFragment.substring(0, 1).toUpperCase() + newFragment.substring(1);
           
            typeName = "J" + newFragment + typeName.substring(1);
           
            fragmentIndex++;
        }
       
        if (outOfFragments) {
           
            // If we're out of fragments, then disambiguate by adding number suffixes.
           
            int i = 1;
            String basicTypeName = typeName;
            while (workingModuleTypeInfo.getTypeConstructor(typeName) != null) {
                typeName = basicTypeName + "_" + i;
                i++;
            }           
        }
       
View Full Code Here

            statusLabel.setIcon(ERROR_ICON);
            okButton.setEnabled(false);
            return false;
        }
       
        ModuleTypeInfo typeInfo = null;
        if (category != SourceIdentifier.Category.MODULE_NAME) {
            typeInfo = perspective.getMetaModule((ModuleName)sourceModuleList.getSelectedItem()).getTypeInfo();
        }
       
        boolean entityExists;
        if (category == SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD) {
            entityExists = typeInfo.getFunctionOrClassMethod(fromName) != null;
           
        } else if (category == SourceIdentifier.Category.DATA_CONSTRUCTOR) {
            entityExists = typeInfo.getDataConstructor(fromName) != null;
           
        } else if (category == SourceIdentifier.Category.TYPE_CONSTRUCTOR) {
            entityExists = typeInfo.getTypeConstructor(fromName) != null;
           
        } else if (category == SourceIdentifier.Category.TYPE_CLASS) {
            entityExists = typeInfo.getTypeClass(fromName) != null;
           
        } else if (category == SourceIdentifier.Category.MODULE_NAME) {
            entityExists = (perspective.getMetaModule(ModuleName.make(fromName)) != null);
           
            if (fromName.equals(CAL_Prelude.MODULE_NAME) && !allowPreludeRenaming) {
View Full Code Here

            statusLabel.setText(GemCutter.getResourceString("RNRD_SpecifyNewName"));
            statusLabel.setIcon(ERROR_ICON);
            okButton.setEnabled(false);
        }
      
        ModuleTypeInfo typeInfo = null;
        if (category != SourceIdentifier.Category.MODULE_NAME) {
            typeInfo = perspective.getMetaModule((ModuleName)sourceModuleList.getSelectedItem()).getTypeInfo();
        }
       
        boolean entityExists;
        IdentifierUtils.ValidatedIdentifier validatedIdentifier;
        if (category == SourceIdentifier.Category.TYPE_CONSTRUCTOR) {
            validatedIdentifier = IdentifierUtils.makeValidTypeConstructorName(toName);
            entityExists = typeInfo.getTypeConstructor(toName) != null;
        } else if (category == SourceIdentifier.Category.TYPE_CLASS) {
            validatedIdentifier = IdentifierUtils.makeValidTypeClassName(toName);
            entityExists = typeInfo.getTypeClass(toName) != null;
        } else if (category == SourceIdentifier.Category.DATA_CONSTRUCTOR) {
            validatedIdentifier = IdentifierUtils.makeValidDataConstructorName(toName);
            entityExists = typeInfo.getDataConstructor(toName) != null;
        } else if (category == SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD) {
            validatedIdentifier = IdentifierUtils.makeValidFunctionName(toName);
            entityExists = typeInfo.getFunctionOrClassMethod(toName) != null;
        } else if (category == SourceIdentifier.Category.MODULE_NAME) {
            validatedIdentifier = IdentifierUtils.makeValidModuleName(toName);
            ModuleName maybeModuleName = ModuleName.maybeMake(toName);
            entityExists = maybeModuleName != null && perspective.getMetaModule(maybeModuleName) != null;
        } else {
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.