PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElementsInNamespace.cs

https://github.com/ajadex/SharpDevelop
C# | 68 lines | 42 code | 9 blank | 17 comment | 0 complexity | 35c9a829a9aa480590861d92bb40ab3b MD5 | raw file
 1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
 2// 
 3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
 4// software and associated documentation files (the "Software"), to deal in the Software
 5// without restriction, including without limitation the rights to use, copy, modify, merge,
 6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 7// to whom the Software is furnished to do so, subject to the following conditions:
 8// 
 9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11// 
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using System.Collections;
21using System.Collections.Generic;
22using System.Linq;
23
24using ICSharpCode.NRefactory.TypeSystem;
25using ICSharpCode.SharpDevelop;
26using ICSharpCode.SharpDevelop.Dom;
27
28namespace ICSharpCode.PackageManagement.EnvDTE
29{
30	public class CodeElementsInNamespace : CodeElementsList<CodeElement>
31	{
32		CodeModelContext context;
33		INamespace ns;
34		
35		public CodeElementsInNamespace(CodeModelContext context)
36			: this(context, context.DteProject.GetCompilationUnit().RootNamespace)
37		{
38		}
39		
40		public CodeElementsInNamespace(CodeModelContext context, INamespace ns)
41		{
42			this.context = context;
43			this.ns = ns;
44			GetCodeElements();
45		}
46		
47		void GetCodeElements()
48		{
49			foreach (INamespace childNamespace in ns.ChildNamespaces) {
50				AddCodeNamespace(childNamespace);
51			}
52			
53			foreach (IType type in ns.Types) {
54				AddType(type);
55			}
56		}
57		
58		void AddCodeNamespace(INamespace ns)
59		{
60			Add(new CodeNamespace(context, ns));
61		}
62		
63		void AddType(IType type)
64		{
65			Add(CodeType.Create(context, type));
66		}
67	}
68}