Exemple #1
0
        //
        // ФУНКЦІЇ
        //

        /// <summary>
        /// Встановлює Активний набір умов та Активний стан
        /// </summary>
        /// <param name="state">Активний стан</param>
        private void SetCurrentStateCondition(string state)
        {
            //Якщо стан ще не загружений в память, тоді його потрібно загрузити
            if (!StateConditionsCollection.ContainsKey(state))
            {
                StateConditions StateConditionItem = new StateConditions();
                StateConditionItem.State = state;

                string statePath = (state == "" ? "" : state + "/");

                XPathNodeIterator ifList = NamespaceNode.Select(statePath + "if");
                while (ifList.MoveNext())
                {
                    StateConditionItem.ConditionsIf.Add(new StateIf(ifList.Current));
                }

                XPathNodeIterator elseList = NamespaceNode.Select(statePath + "else");
                while (elseList.MoveNext())
                {
                    StateConditionItem.ConditionsElse.Add(new StateElse(elseList.Current));
                }

                StateConditionsCollection.Add(state, StateConditionItem);
            }

            //Активний набір умов
            CurrentStateCondition = StateConditionsCollection[state];

            //Активний стан
            CurrentState = state;
        }
Exemple #2
0
        void NamespaceMemberDeclaration(ref NamespaceNode namespace_node)
        {
            printDebug("Namespace Member Declaration");
            if (Match(TokenType.NAMESPACE_KEYWORD))
            {
                var new_namespace = new NamespaceNode();
                new_namespace.using_array.AddRange(namespace_node.using_array);
                // new_namespace.using_array.Add(new UsingNode(namespace_node.identifier));
                // var new_using_nodes = new List<UsingNode>();
                // var new_namespaces_nodes = new List<NamespaceNode>();
                // var new_types_nodes = new List<TypeDeclarationNode>();
                // new_namespace.namespace_node = new_namespaces_nodes;
                // new_namespace.using_node = new_using_nodes;
                // new_namespace.types_declaration_node = new_types_nodes;

                NamespaceDeclaration(ref new_namespace);
                OptionalNamespaceMemberDeclaration(ref namespace_node);

                namespace_node.namespace_array.Insert(0, new_namespace);
            }
            else
            {
                namespace_node.types_declaration_array.AddRange(TypeDeclarationList());
                OptionalNamespaceMemberDeclaration(ref namespace_node);
            }
        }
Exemple #3
0
        public BaseNode AddNamespace(string id, string name)
        {
            NamespaceNode nsnode = new NamespaceNode(id, name);

            nodemap.Add(id, nsnode);
            return(nsnode);
        }
        public override void ProcessNode(NamespaceNode node)
        {
            m_state.Namespace = node;

            m_output.Append("namespace ");
            m_output.Append(node.Name);

            BeginBlock();

            foreach (VariableNode v in node.GlobalsNode.Children)
            {
                v.VisitThis(this);
                NewLine();
            }

            NewLine();

            foreach (ScriptNode s in node.ScriptsNode.Children)
            {
                NewLine(0, 1);
                s.VisitThis(this);
            }

            EndBlock();

            m_state.Namespace = null;
        }
        private void checkMethods(API api, NamespaceNode myNs)
        {
            //Console.WriteLine("evaluating: checkMethods");
            var path       = api.getDeclarationPathForType(this);
            var my_methods = api.getMethodsForType(this, path + " " + Identifier.token.getLine());

            foreach (var method in my_methods)
            {
                if (Identifier.Name == "GetRandomGrumpiness")
                {
                    Console.Write("");
                }
                var childMethodName = Identifier.Name + "." + api.buildMethodName(method.Value.methodHeaderNode);
                if (!method.Value.evaluated)
                {
                    if ((method.Value.Modifier == null || api.validateModifier(method.Value.Modifier, TokenType.RW_VIRTUAL, TokenType.RW_STATIC)) && method.Value.statemetBlock == null)
                    {
                        Utils.ThrowError("'" + childMethodName + "' must declare a body because it is not marked abstract ["
                                         + myNs.Identifier.Name + "] " + method.Value.token.getLine());
                    }

                    if (api.validateModifier(method.Value.Modifier, TokenType.RW_ABSTRACT))
                    {
                        if (method.Value.statemetBlock != null)
                        {
                            Utils.ThrowError("'" + childMethodName + "' cannot declare a body because it is marked abstract ["
                                             + myNs.Identifier.Name + "] " + method.Value.token.getLine());
                        }
                        if (Utils.isValidEncapsulationForClass(method.Value.encapsulation, TokenType.RW_PRIVATE))
                        {
                            Utils.ThrowError("'" + childMethodName + "' virtual or abstract members cannot be private ["
                                             + myNs.Identifier.Name + "] " + method.Value.token.getLine());
                        }
                        if (!IsAbstract)
                        {
                            Utils.ThrowError("'" + childMethodName + "' is abstract but it is contained in non-abstract class '"
                                             + Identifier.Name + "' [" + myNs.Identifier.Name + "] " + method.Value.token.getLine());
                        }
                    }
                    else if (api.validateModifier(method.Value.Modifier, TokenType.RW_VIRTUAL))
                    {
                        if (Utils.isValidEncapsulationForClass(method.Value.encapsulation, TokenType.RW_PRIVATE))
                        {
                            Utils.ThrowError("'" + childMethodName + "' virtual or abstract members cannot be private ["
                                             + myNs.Identifier.Name + "] " + method.Value.token.getLine());
                        }
                    }
                    else if (api.validateModifier(method.Value.Modifier, TokenType.RW_OVERRIDE))
                    {
                        if (api.contextManager.findFunction(api.buildMethodName(method.Value.methodHeaderNode)) == null)
                        {
                            Utils.ThrowError("Modifier 'override' can't be aplied to the method " + childMethodName + " " + method.Value.token.getLine());
                        }
                    }
                    method.Value.evaluated = true;
                }
                api.checkFixedParametersForMethod(method.Value.methodHeaderNode, myNs);
            }
            checkMethodsBody(api, my_methods, myNs);
        }
Exemple #6
0
        /// <summary>
        /// 根据namespace聚合
        /// </summary>
        /// <param name="types"></param>
        /// <returns></returns>
        private static ObservableCollection <Node> Transform(Type[] types, XmlMember[] xmlMembers, TransConfig transConfig)
        {
            var returnValue = new ObservableCollection <Node>();

            if (types != null && types.Length > 0)
            {
                var groups = types.ToLookup(v => v.Namespace);

                foreach (var group in groups)
                {
                    var ns = new NamespaceNode {
                        Name = group.Key
                    };

                    ns.Items = new ObservableCollection <Node>();

                    //Class
                    var classes    = group.Where(v => v.IsClass).ToArray();
                    var classNodes = LoadClasses(classes, xmlMembers, transConfig);
                    foreach (var item in classNodes)
                    {
                        ns.Items.Add(item);
                    }

                    returnValue.Add(ns);
                }
            }

            return(returnValue);
        }
        /*namespace-body:
         | '{' optional-using-directive optional-namespace-member-declaration '}' */
        private void namespace_body(ref CompilationUnitNode compilation, ref NamespaceNode currentNamespace)
        {
            printIfDebug("namespace_body");
            if (!pass(TokenType.PUNT_CURLY_BRACKET_OPEN))
            {
                throwError("'{' expected");
            }
            consumeToken();

            if (pass(TokenType.RW_USING))
            {
                var usingDirectives = optional_using_directive();
                currentNamespace.setUsings(usingDirectives);
            }
            if (pass(namespaceOption, encapsulationOptions, typesDeclarationOptions))
            {
                optional_namespace_or_type_member_declaration(ref compilation, ref currentNamespace);
            }
            else
            {
                //EPSILON
            }
            if (!pass(TokenType.PUNT_CURLY_BRACKET_CLOSE))
            {
                throwError("'}' expected");
            }
            consumeToken();
        }
 public virtual AstNode VisitNamespace(NamespaceNode n)
 {
     Visit(n.Attributes);
     Visit(n.Name);
     Visit(n.Declarations);
     return(n);
 }
        private void AddNamespace(TreeNode parentNode, CodeNamespace cmNamespace)
        {
            if (Filter((CodeElement)cmNamespace))
            {
                return;
            }
            TreeNode namespaceNode = null;
            String   name          = cmNamespace.Name;

            if (flattenNameSpaces.Checked)
            {
                name = cmNamespace.FullName;
            }
            TreeNode[] namespaceNodes = parentNode.Nodes.Find(name, false);
            if (namespaceNodes.Length == 1)
            {
                namespaceNode = namespaceNodes[0];
            }
            else
            {
                namespaceNode = new NamespaceNode(name, this);
                AddNodeWithChilds(parentNode.Nodes, namespaceNode);
            }
            ((List <CodeNamespace>)namespaceNode.Tag).Add(cmNamespace);
        }
Exemple #10
0
        public void Namespace(AST.Namespace ns, bool abi, Action content)
        {
            NamespaceNode prev = null;

            if (Index > 0)
            {
                prev = Target.Children[Index - 1] as NamespaceNode;
            }

            if (prev != null && prev.Namespace == ns && prev.Abi == abi)
            {
                _ancestors.Add(Target);
                Target = prev;
                Index  = Target.Children.Count;
                content();
                PopTarget();
            }
            else if (prev != null && prev.Abi == abi && ns.IsWithin(prev.Namespace))
            {
                _ancestors.Add(Target);
                Target = prev;
                Index  = Target.Children.Count;
                Namespace(ns, abi, content);
                PopTarget();
            }
            else
            {
                InsertAndPushTarget(new NamespaceNode(ns, abi));
                content();
                PopTarget();
            }
        }
Exemple #11
0
        RenameNamespaceCommand(string newName, NamespaceNode nsNode)
        {
            this.newName   = newName;
            origName       = nsNode.Name;
            this.nsNode    = nsNode;
            existingNsNode = (NamespaceNode)nsNode.TreeNode.Parent.DataChildren.FirstOrDefault(a => a is NamespaceNode && newName == ((NamespaceNode)a).Name);

            var module = nsNode.GetModule();

            Debug.Assert(module != null);
            if (module == null)
            {
                throw new InvalidOperationException();
            }

            origParentNode       = (DocumentTreeNodeData)nsNode.TreeNode.Parent.Data;
            origParentChildIndex = origParentNode.TreeNode.Children.IndexOf(nsNode.TreeNode);
            Debug.Assert(origParentChildIndex >= 0);
            if (origParentChildIndex < 0)
            {
                throw new InvalidOperationException();
            }

            // Make sure the exact same namespace names are restored if we undo. The names are UTF8
            // strings, but not necessarily canonicalized if it's an obfuscated assembly.
            nsNode.TreeNode.EnsureChildrenLoaded();
            origChildren   = nsNode.TreeNode.DataChildren.Cast <TypeNode>().ToArray();
            typeNamespaces = new UTF8String[nsNode.TreeNode.Children.Count];
            for (int i = 0; i < typeNamespaces.Length; i++)
            {
                typeNamespaces[i] = origChildren[i].TypeDef.Namespace;
            }

            typeRefInfos = GetTypeRefInfos(module, new[] { nsNode });
        }
        private void checkInheritance(API api, NamespaceNode myNs)
        {
            var thisDeclarationPath = api.getDeclarationPathForType(this);

            if (inheritanceses != null)
            {
                foreach (var parent in inheritanceses)
                {
                    TypeNode parentTypeNode = api.getTypeForIdentifier(parent.Name);
                    if (parentTypeNode == null)
                    {
                        Utils.ThrowError("The type or namespace name '" + parent.Name
                                         + "' could not be found (are you missing a using directive or an assembly reference?) ["
                                         + myNs.Identifier.Name + "]");
                    }
                    if (!(parentTypeNode is InterfaceTypeNode))
                    {
                        Utils.ThrowError("Type '" + parentTypeNode.Identifier.Name
                                         + "' in interface list is not an interface [" + myNs.Identifier.Name + "]("
                                         + thisDeclarationPath + ")");
                    }
                    if (parents.ContainsKey(parentTypeNode.Identifier.Name))
                    {
                        Utils.ThrowError("Redundant Inheritance. " + parentTypeNode.Identifier.Name
                                         + " was found twice as inheritance in "
                                         + "[" + Identifier.Name + "] " + thisDeclarationPath);
                    }
                    this.parents[parentTypeNode.Identifier.Name] = parentTypeNode;
                }
            }
        }
        public override void Evaluate(API api)
        {
            if (evaluated)
            {
                return;
            }
            //Console.WriteLine("evaluating: "+ToString());
            if (ToString() == "Rectangulo")
            {
                Console.Write("");
            }
            var           thisDeclarationPath = api.getDeclarationPathForType(this);
            NamespaceNode myNs = api.getNamespaceForType(this);

            if (!Utils.isValidEncapsulationForClass(this.encapsulation, TokenType.RW_PUBLIC))
            {
                Utils.ThrowError("Elements defined in a namespace cannot be declared as private or protected; Interface: "
                                 + this.Identifier.Name + " (" + thisDeclarationPath + ") ");
            }
            checkInheritance(api, myNs);
            verifyCycleInheritance(api, myNs);
            checkParents(api, myNs);
            api.contextManager.pushContext(api.buildContextForTypeDeclaration(this));
            checkFields(api, myNs);
            checkConstructors(api, myNs);
            checkMethods(api, myNs);
            api.contextManager.backContextToObject();
            this.evaluated = true;
        }
Exemple #14
0
        public override void Perform()
        {
            NamespaceNode rootNamespace = m_assembly.Namespaces[0];

            m_assembly.Namespaces[0] = new NamespaceNode("Campaign." + m_mapName.ToUpper(), rootNamespace.GlobalsNode, rootNamespace.ScriptsNode);
            base.Perform();
        }
        private void mainTreeView_TreeNodePopulate(object sender, TreeViewEventArgs e)
        {
            TreeNode node = e.Node;
            object   obj  = e.Node.Tag;

            if (obj is AssemblyNode)
            {
                AssemblyNode asm = (AssemblyNode)obj;
                foreach (NamespaceNode space in asm.Namespaces)
                {
                    space.SortTypes();
                    TreeNode spaceNode = new TreeNode(space.Name);
                    spaceNode.ImageKey         = "namespace";
                    spaceNode.SelectedImageKey = spaceNode.ImageKey;
                    spaceNode.Tag = space;
                    spaceNode.Nodes.Add(String.Empty);
                    node.Nodes.Add(spaceNode);
                }
            }
            else if (obj is NamespaceNode)
            {
                NamespaceNode space = (NamespaceNode)obj;
                foreach (TypeNode type in space.Types)
                {
                    TreeNode typeNode = new TreeNode(type.Name);
                    typeNode.ImageKey         = GetImageKey(type);
                    typeNode.SelectedImageKey = typeNode.ImageKey;
                    typeNode.Tag = type;
                    node.Nodes.Add(typeNode);
                }
            }
        }
        public void NestedDeclarations()
        {
            String contents =
                "namespace My \r\n" +
                "  namespace Nested \r\n" +
                "    namespace Declaration \r\n" +
                "    end \r\n" +
                "  end \r\n" +
                "end \r\n";

            CompilationUnitNode unit = RookParser.ParseContents(contents);

            Assert.IsNotNull(unit);
            Assert.AreEqual(1, unit.Namespaces.Count);

            NamespaceNode ns = unit.Namespaces[0] as NamespaceNode;

            Assert.IsNotNull(ns);
            Assert.AreEqual("My", ns.Identifier.Name);
            Assert.AreEqual(1, ns.Namespaces.Count);

            ns = ns.Namespaces[0] as NamespaceNode;
            Assert.IsNotNull(ns);
            Assert.AreEqual("Nested", ns.Identifier.Name);
            Assert.AreEqual(1, ns.Namespaces.Count);

            ns = ns.Namespaces[0] as NamespaceNode;
            Assert.IsNotNull(ns);
            Assert.AreEqual("Declaration", ns.Identifier.Name);
            Assert.AreEqual(0, ns.Namespaces.Count);
        }
Exemple #17
0
 public static void addNamespace(string name, NamespaceNode ns)
 {
     if (!namespacesTable.ContainsKey(name))
     {
         namespacesTable[name] = new List <NamespaceNode>();
     }
     namespacesTable[name].Add(ns);
 }
Exemple #18
0
        private List <NamespaceNode> GetNamespaces(NamespaceNode tree)
        {
            var ret = new List <NamespaceNode>();

            GetNamespaces(ref ret, tree, new IdentifierNode());

            return(ret);
        }
        private void OnBeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            HybridDictionary namespaces = new HybridDictionary();

            if (e.Node is AssemblyNode && e.Node.Tag != null)
            {
                tvBrowser.SuspendLayout();

                e.Node.Nodes.Clear();
                Assembly asm = (Assembly)e.Node.Tag;
                e.Node.Tag = null;

                foreach (Type t in this.types)
                {
                    if (t.Assembly == asm)
                    {
                        TreeNode ns = null;
                        // Non-namespaced types go directly under the assembly node.
                        if (t.Namespace == null)
                        {
                            ns = e.Node;
                        }
                        else
                        {
                            // Check if have already created the namespace node.
                            object key = String.Intern(t.Namespace);
                            ns = (TreeNode)namespaces[key];
                            if (ns == null)
                            {
                                ns = new NamespaceNode(t);
                                e.Node.Nodes.Add(ns);
                                namespaces.Add(key, ns);
                            }
                        }

                        if (t.IsClass)
                        {
                            ns.Nodes.Add(new ClassNode(t));
                        }
                        else if (t.IsAnsiClass)
                        {
                            ns.Nodes.Add(new ClassNode(t));
                        }
                        else if (t.IsInterface)
                        {
                            ns.Nodes.Add(new InterfaceNode(t));
                        }
                        else if (t.IsEnum)
                        {
                            ns.Nodes.Add(new EnumNode(t));
                        }
                    }
                }

                tvBrowser.ResumeLayout();
            }
        }
        protected void WalkNamespaceNode(NamespaceNode node)
        {
            if (node == null)
            {
                return;
            }

            node.Types?.ForEach(t => VisitTypeNode(t));
            node.Namespaces?.ForEach(n => VisitNamespaceNode(n));
        }
Exemple #21
0
        public void NamespaceNodeIsInitialized()
        {
            var node = new NamespaceNode("test");

            Assert.AreEqual("test", node.DisplayName);
            CollectionAssert.AreEqual(new TypeNode[0], node.Types);
            Assert.AreEqual(Visibility.Visible, node.Visibility);
            Assert.IsFalse(node.IsExpanded);
            Assert.IsFalse(node.IsSelected);
        }
Exemple #22
0
 public NamespaceNodeCreator(string ns, ModuleDocumentNode modNode)
 {
     this.modNode = modNode;
     nsNode       = modNode.FindNode(ns);
     if (nsNode == null)
     {
         nsNode        = modNode.Create(ns);
         nsNodeCreated = true;
     }
 }
        private void verifyCycleInheritance(API api, NamespaceNode myNs)
        {
            var thisDeclarationPath = api.getDeclarationPathForType(this);

            try{
                api.hasCycleInheritance(Identifier.Name, parents);
            }catch (SemanticException ex) {
                Utils.ThrowError(thisDeclarationPath + " -> " + ex.Message + " [" + myNs.Identifier.Name + "] " + Identifier.token.getLine());
            }
        }
        private void checkParents(API api, NamespaceNode myNs)
        {
            //Console.WriteLine("evaluating: checkParents");
            var path       = api.getDeclarationPathForType(this);
            var my_methods = api.getMethodsForType(this, path + " " + Identifier.token.getLine());

            foreach (var parent in parents)
            {
                checkParentMethods(api, parent.Value, my_methods);
            }
        }
Exemple #25
0
            public NamespaceNode GetNamespace(string @namespace)
            {
                NamespaceNode result;

                if (!namespaces.TryGetValue(@namespace, out result))
                {
                    result = new NamespaceNode();
                    namespaces.Add(@namespace, result);
                }
                return(result);
            }
Exemple #26
0
        private void BuilderNameSpace(NamespaceNode cn, CompilationUnitNode unit)
        {
            NamespaceNode nspace = new NamespaceNode(new Token(TokenID.Namespace));

            nspace.Name = cn.Name;
            mEntityUnit.Namespaces.Add(nspace);
            foreach (InterfaceNode item in cn.Interfaces)
            {
                BuilderType(item, nspace);
            }
        }
        protected void PrepareUsings(NamespaceNode node)
        {
            if (node == null)
            {
                return;
            }

            node.UsingCache.Clear();
            node.Usings?.ForEach(u => PrepareUsings(node.UsingCache, u));
            node.Types?.ForEach(t => PrepareUsings(node.UsingCache, t));
        }
Exemple #28
0
 void OptionalNamespaceMemberDeclaration(ref NamespaceNode namespace_node)
 {
     printDebug("Optional Namespace Member Declaration");
     if (MatchAny(this.encapsulation_modifiers.Concat(new TokenType[] { TokenType.NAMESPACE_KEYWORD, TokenType.ENUM_KEYWORD, TokenType.CLASS_KEYWORD, TokenType.INTERFACE_KEYWORD, TokenType.ABSTRACT_KEYWORD }).ToArray()))
     {
         NamespaceMemberDeclaration(ref namespace_node);
     }
     else
     {
         //EPSILON
     }
 }
Exemple #29
0
        public void Visit(NamespaceNode namespaceNode)
        {
            var count = _table.EnterNamespace(namespaceNode.Name);

            foreach (var element in namespaceNode.Declarations)
            {
                element.Parent = namespaceNode;
                element.Accept(this);
            }

            _table.Exit(count);
        }
Exemple #30
0
        public override void VisitNamespaceNode(NamespaceNode node)
        {
            if (node.DifferenceDecoration == DifferenceDecoration.NoDifferences)
            {
                return;
            }

            foreach (var module in node.Types)
            {
                module.Accept(this);
            }
        }
    public override object VisitNamespaceDeclaration(NamespaceNode namespaceDeclaration, object data)
    {
      if (namespaceDeclaration.Name == null)
        return null;

      builder.AppendLine("namespace " + namespaceDeclaration.Name.GenericIdentifier);
      builder.BeginScope();
      {
        
      }
      builder.EndScope();
      return base.VisitNamespaceDeclaration(namespaceDeclaration, data);
    }
Exemple #32
0
 private bool ClassType(NamespaceNode ns)
 {
     if (Keyword(ParserConstants.ClassKeyword))
     {
         var name = NameExpected();
         CheckDuplicateGlobalType(ns, name);
         Token abstractOrSealed;
         if (!Keyword(ParserConstants.AbstractKeyword, out abstractOrSealed))
         {
             Keyword(ParserConstants.SealedKeyword, out abstractOrSealed);
         }
         var baseClassQName = default(QualifiableNameNode);
         if (Keyword(ParserConstants.ExtendsKeyword))
         {
             baseClassQName = QualifiableNameExpected();
         }
         List<KeyNode> keyList = null;
         if (Keyword(ParserConstants.KeyKeyword))
         {
             keyList = new List<KeyNode>();
             while (true)
             {
                 var key = new KeyNode { NameExpected() };
                 while (true)
                 {
                     if (Token('.'))
                     {
                         key.Add(NameExpected());
                     }
                     else
                     {
                         break;
                     }
                 }
                 keyList.Add(key);
                 if (!Token(','))
                 {
                     break;
                 }
             }
         }
         TokenExpected('{');
         var cls = new ClassTypeNode(ns, name, abstractOrSealed, baseClassQName, keyList);
         while (Property(ns, cls)) ;
         TokenExpected('}');
         ns.GlobalTypeMap.Add(name, cls);
         return true;
     }
     return false;
 }
Exemple #33
0
 private bool EnumType(NamespaceNode ns)
 {
     if (Keyword(ParserConstants.EnumKeyword))
     {
         var name = NameExpected();
         CheckDuplicateGlobalType(ns, name);
         KeywordExpected(ParserConstants.AsKeyword);
         var atomQName = QualifiableNameExpected();
         TokenExpected('{');
         var en = new EnumTypeNode(ns, name, atomQName);
         while (EnumTypeMember(en)) ;
         TokenExpected('}');
         ns.GlobalTypeMap.Add(name, en);
         return true;
     }
     return false;
 }
Exemple #34
0
 private bool NullableType(NamespaceNode ns, out NullableTypeNode result)
 {
     Token tk;
     if (Keyword(ParserConstants.NullableKeyword, out tk))
     {
         TokenExpected('<');
         var element = (NonNullableTypeNode)LocalTypeExpected(ns, LocalTypeFlags.GlobalTypeRef | LocalTypeFlags.List | LocalTypeFlags.Set | LocalTypeFlags.Map);
         TokenExpected('>');
         result = new NullableTypeNode(ns, tk.TextSpan, element);
         return true;
     }
     result = null;
     return false;
 }
 public FullyQualifiedNamesCache()
 {
     this.root = new NamespaceNode("Root");
 }
            public NamespaceNode(string name, NamespaceNode parent)
                : this(name)
            {
                if (parent == null)
                {
                    throw new ArgumentException("parent");
                }

                Contract.EndContractBlock();

                parent.namespaceNodes.Add(this.GetCanonicalName(), this);

                this.parent = parent;
            }
         // Constructor
         public ClassNode(NamespaceNode parent, BplClass bplClass) {
            Parent = parent;
            Class = bplClass;
            Name = bplClass.Name;
            Index.Add(this);

            _isSelected = Explorer.Shell.SelectedClasses.Contains(Class);
         }
Exemple #38
0
 private bool Import(NamespaceNode ns)
 {
     if (Keyword(ParserConstants.ImportKeyword))
     {
         var uri = UriExpected();
         var alias = default(Token);
         if (Keyword(ParserConstants.AsKeyword))
         {
             alias = NameExpected();
             if (alias.Value == "sys")
             {
                 ErrorAndThrow(new DiagMsgEx(DiagCodeEx.AliasSysReserved), alias.TextSpan);
             }
             if (ns.ImportList.Count > 0)
             {
                 foreach (var import in ns.ImportList)
                 {
                     if (import.Alias == alias)
                     {
                         ErrorAndThrow(new DiagMsgEx(DiagCodeEx.DuplicateNamespaceAlias, alias.Value), alias.TextSpan);
                     }
                 }
             }
         }
         ns.ImportList.Add(new ImportNode(uri, alias));
         return true;
     }
     return false;
 }
Exemple #39
0
 private bool LocalType(NamespaceNode ns, LocalTypeFlags flags, out LocalTypeNode result)
 {
     if ((flags & LocalTypeFlags.Nullable) != 0)
     {
         NullableTypeNode r;
         if (NullableType(ns, out r))
         {
             result = r;
             return true;
         }
     }
     if ((flags & LocalTypeFlags.List) != 0)
     {
         ListOrSetTypeNode r;
         if (ListType(ns, out r))
         {
             result = r;
             return true;
         }
     }
     if ((flags & LocalTypeFlags.Set) != 0)
     {
         ListOrSetTypeNode r;
         if (SetType(ns, out r))
         {
             result = r;
             return true;
         }
     }
     if ((flags & LocalTypeFlags.Map) != 0)
     {
         MapTypeNode r;
         if (MapType(ns, out r))
         {
             result = r;
             return true;
         }
     }
     if ((flags & LocalTypeFlags.GlobalTypeRef) != 0)
     {
         GlobalTypeRefNode r;
         if (GlobalTypeRef(ns, out r))
         {
             result = r;
             return true;
         }
     }
     result = null;
     return false;
 }
Exemple #40
0
 private bool MapType(NamespaceNode ns, out MapTypeNode result)
 {
     Token tk;
     if (Keyword(ParserConstants.MapKeyword, out tk))
     {
         TokenExpected('<');
         var key = (GlobalTypeRefNode)LocalTypeExpected(ns, LocalTypeFlags.GlobalTypeRef);
         TokenExpected(',');
         var value = LocalTypeExpected(ns, LocalTypeFlags.GlobalTypeRef | LocalTypeFlags.Nullable | LocalTypeFlags.List | LocalTypeFlags.Set | LocalTypeFlags.Map);
         TokenExpected('>');
         result = new MapTypeNode(ns, tk.TextSpan, key, value);
         return true;
     }
     result = null;
     return false;
 }
Exemple #41
0
 private void CheckDuplicateGlobalType(NamespaceNode ns, Token name)
 {
     if (ns.GlobalTypeMap.ContainsKey(name))
     {
         ErrorAndThrow(new DiagMsgEx(DiagCodeEx.DuplicateGlobalTypeName, name.Value), name.TextSpan);
     }
 }
Exemple #42
0
 private bool SetType(NamespaceNode ns, out ListOrSetTypeNode result)
 {
     Token tk;
     if (Keyword(ParserConstants.SetKeyword, out tk))
     {
         TokenExpected('<');
         var item = (GlobalTypeRefNode)LocalTypeExpected(ns, LocalTypeFlags.GlobalTypeRef);
         TokenExpected('>');
         result = new ListOrSetTypeNode(ns, tk.TextSpan, false, item);
         return true;
     }
     result = null;
     return false;
 }
Exemple #43
0
 private bool Property(NamespaceNode ns, ClassTypeNode cls)
 {
     Token name;
     if (Name(out name))
     {
         if (cls.PropertyMap.ContainsKey(name))
         {
             ErrorAndThrow(new DiagMsgEx(DiagCodeEx.DuplicatePropertyName, name.Value), name.TextSpan);
         }
         KeywordExpected(ParserConstants.AsKeyword);
         cls.PropertyMap.Add(name,
             LocalTypeExpected(ns, LocalTypeFlags.GlobalTypeRef | LocalTypeFlags.Nullable | LocalTypeFlags.List | LocalTypeFlags.Set | LocalTypeFlags.Map));
         return true;
     }
     return false;
 }
         // Constructor
         public ClassNode(NamespaceNode parent, BplClass bplClass) {
            Parent = parent;
            Class = bplClass;
            Name = (bplClass.Operation != null ? bplClass.Operation.Name : bplClass.Name);
            Index.Add(this);

            _isSelected = Explorer.Shell.SelectedClasses.Contains(Class);
         }
         // Constructor
         public LibraryNode(BplLibrary library, IEnumerable<BplNamespace> namespaces) {
            Library = library;
            Children = new List<NamespaceNode>();
            Name = library.Name;
            Index.Add(this);

            foreach (var ns in namespaces) {
               var node = new NamespaceNode(this, ns);
               if (node.Children.Count > 0) {
                  Children.Add(node);
               }
            }
            UpdateSelection(true);
         }
        private void OnBeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            HybridDictionary namespaces = new HybridDictionary();

            if(e.Node is AssemblyNode && e.Node.Tag != null)
            {
                tvBrowser.SuspendLayout();

                e.Node.Nodes.Clear();
                Assembly asm = (Assembly)e.Node.Tag;
                e.Node.Tag = null;

                foreach(Type t in this.types)
                {
                    if(t.Assembly == asm)
                    {
                        TreeNode ns = null;
                        // Non-namespaced types go directly under the assembly node.
                        if(t.Namespace == null)
                        {
                            ns = e.Node;
                        }
                        else
                        {
                            // Check if have already created the namespace node.
                            object key = String.Intern(t.Namespace);
                            ns = (TreeNode)namespaces[key];
                            if(ns == null)
                            {
                                ns = new NamespaceNode(t);
                                e.Node.Nodes.Add(ns);
                                namespaces.Add(key, ns);
                            }
                        }

                        if (t.IsClass)
                        {
                            ns.Nodes.Add(new ClassNode(t));
                        }
                        else if (t.IsAnsiClass)
                        {
                            ns.Nodes.Add(new ClassNode(t));
                        }
                        else if (t.IsInterface)
                        {
                            ns.Nodes.Add(new InterfaceNode(t));
                        }
                        else if (t.IsEnum)
                        {
                            ns.Nodes.Add(new EnumNode(t));
                        }
                    }
                }

                tvBrowser.ResumeLayout();
            }
        }
Exemple #47
0
        public BaseNode AddNamespace(string id, string name)
        {
            NamespaceNode nsnode = new NamespaceNode(id, name);

            nodemap.Add(id, nsnode);
            return nsnode;
        }
Exemple #48
0
 private bool GlobalTypeRef(NamespaceNode ns, out GlobalTypeRefNode result)
 {
     QualifiableNameNode qName;
     if (QualifiableName(out qName))
     {
         result = new GlobalTypeRefNode(ns, qName.TextSpan, qName);
         return true;
     }
     result = null;
     return false;
 }
            internal NamespaceNode FindSubNamespaceNode(string path, bool createIfEmpty)
            {
                if (string.IsNullOrEmpty(path))
                {
                    throw new ArgumentException("path");
                }

                Contract.EndContractBlock();

                string tailNames;
                var firstNameOriginal = NamespaceFuncs.GetFirstAndTail(path, out tailNames);
                var firstName = GetCanonicalName(firstNameOriginal);

                NamespaceNode foundNamespaceNode;
                if (!this.namespaceNodes.TryGetValue(firstName, out foundNamespaceNode))
                {
                    if (createIfEmpty)
                    {
                        foundNamespaceNode = new NamespaceNode(firstName, this);
                    }
                    else
                    {
                        return null;

                        ////if (firstName == "Deployment")
                        ////{
                        ////    return null;
                        ////}

                        ////throw new ArgumentOutOfRangeException("path");
                    }
                }

                if (string.IsNullOrEmpty(tailNames))
                {
                    return foundNamespaceNode;
                }

                return foundNamespaceNode.FindSubNamespaceNode(tailNames, createIfEmpty);
            }
Exemple #50
0
 private bool GlobalType(NamespaceNode ns)
 {
     if (ClassType(ns))
     {
         return true;
     }
     return EnumType(ns);
 }
Exemple #51
0
 private LocalTypeNode LocalTypeExpected(NamespaceNode ns, LocalTypeFlags flags)
 {
     LocalTypeNode type;
     if (!LocalType(ns, flags, out type))
     {
         ErrorAndThrow(new DiagMsgEx(DiagCodeEx.SpecificTypeExpected, flags.ToString()));
     }
     return type;
 }
Exemple #52
0
 private bool Namespace(CompilationUnitNode cu)
 {
     if (Keyword(ParserConstants.NamespaceKeyword))
     {
         var uri = UriExpected();
         TokenExpected('{');
         var ns = new NamespaceNode(uri);
         while (Import(ns)) ;
         while (GlobalType(ns)) ;
         TokenExpected('}');
         cu.NamespaceList.Add(ns);
         return true;
     }
     return false;
 }