コード例 #1
0
        //	private void getAllInvariants(Map allInvariants) {
        //		InvariantsCollector collector = new InvariantsCollector(this.getJmiClassifier(), allInvariants);
        //		collector.traverseAllAncestors();
        //	}
        public CoreModelElement addDefinedElement(
            string source,
            string name,
            CoreClassifier type)
        {
            List <object> allSubClasses = classifier.getAllSubClasses();

            foreach (CoreClassifier subClass in allSubClasses)
            {
                Environment env = subClass.getEnvironmentWithoutParents();

                if (env.lookup(name) != null)
                {
                    string errorMessage = "<{0}> already defined in a derived classifier";
                    throw new NameClashException(string.Format(errorMessage, new object[] { name }));
                }
            }

            CoreFeature element = createOclDefinedAttribute(source, name, type);

            element.setFeatureOwner(classifier);
            element.setElemOwner(classifier);

            this.definedFeatures.Add(name, element);
            addElementToDefinedFeaturesBySource(source, element);

            return(element);
        }
コード例 #2
0
        public CoreModelElement addDefinedOperation(
            string source,
            string name,
            List <object> paramNames,
            List <object> paramTypes,
            CoreClassifier returnType)
        {
            CoreFeature element = createOclDefinedOperation(source, name, paramNames, paramTypes, returnType);

            element.setFeatureOwner(classifier);
            element.setElemOwner(classifier);
            ModelElementNameGenerator nameGenerator = CoreModelElementNameGeneratorImpl.getInstance();

            string mangledName = nameGenerator.generateNameForOperation(name, paramTypes);

            this.definedFeatures.Add(mangledName, element);
            addElementToDefinedFeaturesBySource(source, element);

            return(element);
        }