public NavigationBarItem()
 {
     text = "";
     kind = "";
     kindModifiers = "";
     spans = new TextSpan[0];
     childItems = new NavigationBarItem[0];
 }
        DefaultClass AddClass(NavigationBarItem item, IDocument document)
        {
            var defaultClass = new DefaultClass(this, item.text);
            defaultClass.BodyRegion = item.ToRegionStartingFromOpeningCurlyBrace(document);
            defaultClass.Region = defaultClass.BodyRegion;

            IClass parentClass = FindParentClass(defaultClass);
            if (parentClass != null) {
                defaultClass.FullyQualifiedName = parentClass.FullyQualifiedName + "." + defaultClass.FullyQualifiedName;
                parentClass.InnerClasses.Add(defaultClass);
            } else {
                Classes.Add(defaultClass);
            }
            AddMethods(defaultClass, item.childItems, document);
            return defaultClass;
        }
		public void AddNavigationInfo(NavigationBarItem[] navigation, IDocument document)
		{
			foreach (NavigationBarItem item in navigation) {
				switch (item.kind) {
					case "class":
						AddClass(item, document);
						break;
					case "interface":
						AddInterface(item, document);
						break;
					case "module":
						AddModule(item, document);
						break;
				}
			}
		}
		public void AddNavigation(NavigationBarItem[] navigation, ITextSource textSource)
		{
			IDocument document = new TextDocument(textSource);
			AddNavigationInfo(navigation, document);
		}
		void UpdateMethodRegions(DefaultUnresolvedMethod method, NavigationBarItem item, IDocument document)
		{
			DomRegion region = item.ToRegionStartingFromOpeningCurlyBrace(document);
			method.Region = new DomRegion(
				region.BeginLine,
				region.BeginColumn,
				region.BeginLine,
				region.BeginColumn);
			method.BodyRegion = region;
		}
		void AddMethod(TypeScriptUnresolvedTypeDefinition parent, NavigationBarItem item, IDocument document)
		{
			var method = new DefaultUnresolvedMethod(parent, item.text);
			UpdateMethodRegions(method, item, document);
			parent.Members.Add(method);
		}
		static bool IsGlobalModule(NavigationBarItem item)
		{
			return item.text == "<global>";
		}
		void AddModule(NavigationBarItem item, IDocument document)
		{
			if (IsGlobalModule(item)) {
				return;
			}
			
			TypeScriptUnresolvedTypeDefinition c = AddClass(item, document);
			c.Kind = TypeKind.Module;
		}
		void AddInterface(NavigationBarItem item, IDocument document)
		{
			TypeScriptUnresolvedTypeDefinition c = AddClass(item, document);
			c.Kind = TypeKind.Interface;
		}
		void AddMethods(TypeScriptUnresolvedTypeDefinition parent, NavigationBarItem[] childItems, IDocument document)
		{
			foreach (NavigationBarItem item in childItems) {
				switch (item.kind) {
					case "method":
					case "constructor":
						AddMethod(parent, item, document);
						break;
				}
			}
		}
		TypeScriptUnresolvedTypeDefinition AddClass(NavigationBarItem item, IDocument document)
		{
			var defaultClass = new TypeScriptUnresolvedTypeDefinition(item.text) {
				UnresolvedFile = this
			};
			defaultClass.BodyRegion = item.ToRegionStartingFromOpeningCurlyBrace(document);
			defaultClass.Region = defaultClass.BodyRegion;
			
			TypeScriptUnresolvedTypeDefinition parentClass = FindParentClass(defaultClass);
			if (parentClass != null) {
				defaultClass.Namespace = parentClass.FullName;
				parentClass.NestedTypes.Add(defaultClass);
			} else {
				typeDefinitions.Add(defaultClass);
			}
			AddMethods(defaultClass, item.childItems, document);
			return defaultClass;
		}
 public void AddNavigation(NavigationBarItem[] navigation, ITextBuffer textBuffer)
 {
     IDocument document = DocumentUtilitites.LoadReadOnlyDocumentFromBuffer(textBuffer);
     AddNavigationInfo(navigation, document);
 }
        void AddModule(NavigationBarItem item, IDocument document)
        {
            if (IsGlobalModule(item)) {
                return;
            }

            DefaultClass c = AddClass(item, document);
            c.ClassType = ClassType.Module;
        }
 void AddMethods(IClass parent, NavigationBarItem[] childItems, IDocument document)
 {
     foreach (NavigationBarItem item in childItems) {
         switch (item.kind) {
             case "method":
             case "constructor":
                 AddMethod(parent, item, document);
                 break;
         }
     }
 }
 void AddMethod(IClass parent, NavigationBarItem item, IDocument document)
 {
     var method = new DefaultMethod(parent, item.text);
     UpdateMethodRegions(method, item, document);
     parent.Methods.Add(method);
 }
 void AddInterface(NavigationBarItem item, IDocument document)
 {
     DefaultClass c = AddClass(item, document);
     c.ClassType = ClassType.Interface;
 }