void UpdatePath (object sender, Mono.TextEditor.DocumentLocationEventArgs e)
		{
			var parsedDocument = Document.ParsedDocument;
			if (parsedDocument == null || parsedDocument.ParsedFile == null)
				return;
			amb = new AstAmbience (document.GetFormattingOptions ());
			
			var unit = parsedDocument.GetAst<SyntaxTree> ();
			if (unit == null)
				return;

			var loc = Document.Editor.Caret.Location;
			var compExt = Document.GetContent<CSharpCompletionTextEditorExtension> ();
			var caretOffset = Document.Editor.Caret.Offset;
			var segType = compExt.GetTypeAt (caretOffset);
			if (segType != null)
				loc = segType.Region.Begin;

			var curType = (EntityDeclaration)unit.GetNodeAt (loc, n => n is TypeDeclaration || n is DelegateDeclaration);

			var curProject = ownerProjects.Count > 1 ? Document.Project : null;

			var segMember = compExt.GetMemberAt (caretOffset);
			if (segMember != null) {
				loc = segMember.Region.Begin;
			} else {
				loc = Document.Editor.Caret.Location;
			}

			var curMember = unit.GetNodeAt<EntityDeclaration> (loc);
			if (curType == curMember || curType is DelegateDeclaration)
				curMember = null;
			if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject)
				return;

			var curTypeMakeup = GetEntityMarkup (curType);
			var curMemberMarkup = GetEntityMarkup (curMember);
			if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
				curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup && curProject == lastProject)
				return;

			lastType = curType;
			lastTypeMarkup = curTypeMakeup;

			lastMember = curMember;
			lastMemberMarkup = curMemberMarkup;

			lastProject = curProject;

			var result = new List<PathEntry> ();

			if (ownerProjects.Count > 1) {
				// Current project if there is more than one
				result.Add (new PathEntry (ImageService.GetIcon (Document.Project.StockIcon), GLib.Markup.EscapeText (Document.Project.Name)) { Tag = Document.Project });
			}

			if (curType == null) {
				if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
					return;
				if (CurrentPath != null && CurrentPath.Length == 2 && CurrentPath [1].Tag is IUnresolvedFile)
					return;
				var prevPath = CurrentPath;
				result.Add (new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit });
				CurrentPath = result.ToArray ();
				OnPathChanged (new DocumentPathChangedEventArgs (prevPath));	
				return;
			}

			if (curType != null) {
				var type = curType;
				var pos = result.Count;
				while (type != null) {
					var declaringType = type.Parent as TypeDeclaration;
					result.Insert (pos, new PathEntry (ImageService.GetIcon (type.GetStockIcon (), Gtk.IconSize.Menu), GetEntityMarkup (type)) { Tag = (AstNode)declaringType ?? unit });
					type = declaringType;
				}
			}
				
			if (curMember != null) {
				result.Add (new PathEntry (ImageService.GetIcon (curMember.GetStockIcon (), Gtk.IconSize.Menu), curMemberMarkup) { Tag = curMember });
				if (curMember is Accessor) {
					var parent = curMember.Parent as EntityDeclaration;
					if (parent != null)
						result.Insert (result.Count - 1, new PathEntry (ImageService.GetIcon (parent.GetStockIcon (), Gtk.IconSize.Menu), GetEntityMarkup (parent)) { Tag = parent });
				}
			}
				
			var entry = GetRegionEntry (parsedDocument, loc);
			if (entry != null)
				result.Add (entry);
				
			PathEntry noSelection = null;
			if (curType == null) {
				noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit };
			} else if (curMember == null && !(curType is DelegateDeclaration)) { 
				noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = curType };
			}

			if (noSelection != null)
				result.Add (noSelection);

			var prev = CurrentPath;
			if (prev != null && prev.Length == result.Count) {
				bool equals = true;
				for (int i = 0; i < prev.Length; i++) {
					if (prev [i].Markup != result [i].Markup) {
						equals = false;
						break;
					}
				}
				if (equals)
					return;
			}
			//		Gtk.Application.Invoke (delegate {
			CurrentPath = result.ToArray ();
			OnPathChanged (new DocumentPathChangedEventArgs (prev));	
			//		});
			//	});
		}
Esempio n. 2
0
        void Update()
        {
            if (DocumentContext == null)
            {
                return;
            }
            var parsedDocument = DocumentContext.ParsedDocument;

            if (parsedDocument == null)
            {
                return;
            }
            var caretOffset = Editor.CaretOffset;
            var model       = parsedDocument.GetAst <SemanticModel>();

            if (model == null)
            {
                return;
            }
            CancelUpdatePath();
            var cancellationToken = src.Token;

            amb = new AstAmbience(TypeSystemService.Workspace.Options);
            var loc = Editor.CaretLocation;

            Task.Run(async delegate {
                var unit = model.SyntaxTree;
                SyntaxNode root;
                SyntaxNode node;
                try {
                    root = await unit.GetRootAsync(cancellationToken).ConfigureAwait(false);
                    if (root.FullSpan.Length <= caretOffset)
                    {
                        return;
                    }
                    node = root.FindNode(TextSpan.FromBounds(caretOffset, caretOffset));
                    if (node.SpanStart != caretOffset)
                    {
                        node = root.SyntaxTree.FindTokenOnLeftOfPosition(caretOffset, cancellationToken).Parent;
                    }
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                    return;
                }

                var curMember = node != null ? node.AncestorsAndSelf().FirstOrDefault(m => m is VariableDeclaratorSyntax && m.Parent != null && !(m.Parent.Parent is LocalDeclarationStatementSyntax) || (m is MemberDeclarationSyntax && !(m is NamespaceDeclarationSyntax))) : null;
                var curType   = node != null ? node.AncestorsAndSelf().FirstOrDefault(IsType) : null;

                var curProject = ownerProjects != null && ownerProjects.Count > 1 ? DocumentContext.Project : null;

                if (curType == curMember || curType is DelegateDeclarationSyntax)
                {
                    curMember = null;
                }
                if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject)
                {
                    return;
                }
                var curTypeMakeup   = GetEntityMarkup(curType);
                var curMemberMarkup = GetEntityMarkup(curMember);
                if (isPathSet && curType != null && lastType != null && curTypeMakeup == lastTypeMarkup &&
                    curMember != null && lastMember != null && curMemberMarkup == lastMemberMarkup && curProject == lastProject)
                {
                    return;
                }


                var result = new List <PathEntry>();

                if (curProject != null)
                {
                    // Current project if there is more than one
                    result.Add(new PathEntry(ImageService.GetIcon(curProject.StockIcon, Gtk.IconSize.Menu), GLib.Markup.EscapeText(curProject.Name))
                    {
                        Tag = curProject
                    });
                }

                if (curType == null)
                {
                    if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0]?.Tag is CSharpSyntaxTree)
                    {
                        return;
                    }
                    if (CurrentPath != null && CurrentPath.Length == 2 && CurrentPath [1]?.Tag is CSharpSyntaxTree)
                    {
                        return;
                    }
                    var prevPath = CurrentPath;
                    result.Add(new PathEntry(GettextCatalog.GetString("No selection"))
                    {
                        Tag = unit
                    });
                    Gtk.Application.Invoke(delegate {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            return;
                        }

                        CurrentPath    = result.ToArray();
                        lastType       = curType;
                        lastTypeMarkup = curTypeMakeup;

                        lastMember       = curMember;
                        lastMemberMarkup = curMemberMarkup;

                        lastProject = curProject;
                        OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                    });
                    return;
                }
                var regionEntry = await GetRegionEntry(DocumentContext.ParsedDocument, loc).ConfigureAwait(false);

                Gtk.Application.Invoke(delegate {
                    if (curType != null)
                    {
                        var type = curType;
                        var pos  = result.Count;
                        while (type != null)
                        {
                            if (!(type is BaseTypeDeclarationSyntax))
                            {
                                break;
                            }
                            var tag = (object)type.Ancestors().FirstOrDefault(IsType) ?? unit;
                            result.Insert(pos, new PathEntry(ImageService.GetIcon(type.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(type))
                            {
                                Tag = tag
                            });
                            type = type.Parent;
                        }
                    }
                    if (curMember != null)
                    {
                        result.Add(new PathEntry(ImageService.GetIcon(curMember.GetStockIcon(), Gtk.IconSize.Menu), curMemberMarkup)
                        {
                            Tag = curMember
                        });
                        if (curMember.Kind() == SyntaxKind.GetAccessorDeclaration ||
                            curMember.Kind() == SyntaxKind.SetAccessorDeclaration ||
                            curMember.Kind() == SyntaxKind.AddAccessorDeclaration ||
                            curMember.Kind() == SyntaxKind.RemoveAccessorDeclaration)
                        {
                            var parent = curMember.Parent;
                            if (parent != null)
                            {
                                result.Insert(result.Count - 1, new PathEntry(ImageService.GetIcon(parent.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                                {
                                    Tag = parent
                                });
                            }
                        }
                    }

                    if (regionEntry != null)
                    {
                        result.Add(regionEntry);
                    }

                    PathEntry noSelection = null;
                    if (curType == null)
                    {
                        noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                        {
                            Tag = unit
                        };
                    }
                    else if (curMember == null && !(curType is DelegateDeclarationSyntax))
                    {
                        noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                        {
                            Tag = curType
                        };
                    }

                    if (noSelection != null)
                    {
                        result.Add(noSelection);
                    }
                    var prev = CurrentPath;
                    if (prev != null && prev.Length == result.Count)
                    {
                        bool equals = true;
                        for (int i = 0; i < prev.Length; i++)
                        {
                            if (prev [i].Markup != result [i].Markup)
                            {
                                equals = false;
                                break;
                            }
                        }
                        if (equals)
                        {
                            return;
                        }
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    CurrentPath    = result.ToArray();
                    lastType       = curType;
                    lastTypeMarkup = curTypeMakeup;

                    lastMember       = curMember;
                    lastMemberMarkup = curMemberMarkup;

                    lastProject = curProject;

                    OnPathChanged(new DocumentPathChangedEventArgs(prev));
                });
            });
        }
Esempio n. 3
0
        void UpdatePath(object sender, Mono.TextEditor.DocumentLocationEventArgs e)
        {
            var parsedDocument = Document.ParsedDocument;

            if (parsedDocument == null || parsedDocument.ParsedFile == null)
            {
                return;
            }
            amb = new AstAmbience(document.GetFormattingOptions());

            var unit = parsedDocument.GetAst <SyntaxTree> ();

            if (unit == null)
            {
                return;
            }

            var loc         = Document.Editor.Caret.Location;
            var compExt     = Document.GetContent <CSharpCompletionTextEditorExtension> ();
            var caretOffset = Document.Editor.Caret.Offset;
            var segType     = compExt.GetTypeAt(caretOffset);

            if (segType != null)
            {
                loc = segType.Region.Begin;
            }

            var curType = (EntityDeclaration)unit.GetNodeAt(loc, n => n is TypeDeclaration || n is DelegateDeclaration);

            var curProject = ownerProjects.Count > 1 ? Document.Project : null;

            var segMember = compExt.GetMemberAt(caretOffset);

            if (segMember != null)
            {
                loc = segMember.Region.Begin;
            }
            else
            {
                loc = Document.Editor.Caret.Location;
            }

            var curMember = unit.GetNodeAt <EntityDeclaration> (loc);

            if (curType == curMember || curType is DelegateDeclaration)
            {
                curMember = null;
            }
            if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject)
            {
                return;
            }

            var curTypeMakeup   = GetEntityMarkup(curType);
            var curMemberMarkup = GetEntityMarkup(curMember);

            if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
                curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup && curProject == lastProject)
            {
                return;
            }

            lastType       = curType;
            lastTypeMarkup = curTypeMakeup;

            lastMember       = curMember;
            lastMemberMarkup = curMemberMarkup;

            lastProject = curProject;

            var result = new List <PathEntry> ();

            if (ownerProjects.Count > 1)
            {
                // Current project if there is more than one
                result.Add(new PathEntry(ImageService.GetIcon(Document.Project.StockIcon, Gtk.IconSize.Menu), GLib.Markup.EscapeText(Document.Project.Name))
                {
                    Tag = Document.Project
                });
            }

            if (curType == null)
            {
                if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
                {
                    return;
                }
                if (CurrentPath != null && CurrentPath.Length == 2 && CurrentPath [1].Tag is IUnresolvedFile)
                {
                    return;
                }
                var prevPath = CurrentPath;
                result.Add(new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = unit
                });
                CurrentPath = result.ToArray();
                OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                return;
            }

            if (curType != null)
            {
                var type = curType;
                var pos  = result.Count;
                while (type != null)
                {
                    var declaringType = type.Parent as TypeDeclaration;
                    result.Insert(pos, new PathEntry(ImageService.GetIcon(type.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(type))
                    {
                        Tag = (AstNode)declaringType ?? unit
                    });
                    type = declaringType;
                }
            }

            if (curMember != null)
            {
                result.Add(new PathEntry(ImageService.GetIcon(curMember.GetStockIcon(), Gtk.IconSize.Menu), curMemberMarkup)
                {
                    Tag = curMember
                });
                if (curMember is Accessor)
                {
                    var parent = curMember.Parent as EntityDeclaration;
                    if (parent != null)
                    {
                        result.Insert(result.Count - 1, new PathEntry(ImageService.GetIcon(parent.GetStockIcon(), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                        {
                            Tag = parent
                        });
                    }
                }
            }

            var entry = GetRegionEntry(parsedDocument, loc);

            if (entry != null)
            {
                result.Add(entry);
            }

            PathEntry noSelection = null;

            if (curType == null)
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = unit
                };
            }
            else if (curMember == null && !(curType is DelegateDeclaration))
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = curType
                };
            }

            if (noSelection != null)
            {
                result.Add(noSelection);
            }

            var prev = CurrentPath;

            if (prev != null && prev.Length == result.Count)
            {
                bool equals = true;
                for (int i = 0; i < prev.Length; i++)
                {
                    if (prev [i].Markup != result [i].Markup)
                    {
                        equals = false;
                        break;
                    }
                }
                if (equals)
                {
                    return;
                }
            }
            //		Gtk.Application.Invoke (delegate {
            CurrentPath = result.ToArray();
            OnPathChanged(new DocumentPathChangedEventArgs(prev));
            //		});
            //	});
        }
		void Update()
		{
			if (DocumentContext == null)
				return;
			var parsedDocument = DocumentContext.ParsedDocument;
			if (parsedDocument == null)
				return;
			var caretOffset = Editor.CaretOffset;
			var model = parsedDocument.GetAst<SemanticModel>();
			if (model == null)
				return;
			CancelUpdatePath ();
			var cancellationToken = src.Token;
			amb = new AstAmbience(TypeSystemService.Workspace.Options);
			var loc = Editor.CaretLocation;
			Task.Run(async delegate {
				var unit = model.SyntaxTree;
				SyntaxNode root;
				SyntaxNode node;
				try {
					root = await unit.GetRootAsync(cancellationToken).ConfigureAwait(false);
					if (root.FullSpan.Length <= caretOffset) {
						return;
					}
					node = root.FindNode(TextSpan.FromBounds(caretOffset, caretOffset));
					if (node.SpanStart != caretOffset)
						node = root.SyntaxTree.FindTokenOnLeftOfPosition(caretOffset, cancellationToken).Parent;
				} catch (Exception ex ) {
					Console.WriteLine (ex);
					return;
				}

				var curMember = node != null ? node.AncestorsAndSelf ().FirstOrDefault (m => m is VariableDeclaratorSyntax && m.Parent != null && !(m.Parent.Parent is LocalDeclarationStatementSyntax) || (m is MemberDeclarationSyntax && !(m is NamespaceDeclarationSyntax))) : null;
				var curType = node != null ? node.AncestorsAndSelf ().FirstOrDefault (IsType) : null;

				var curProject = ownerProjects != null && ownerProjects.Count > 1 ? DocumentContext.Project : null;

				if (curType == curMember || curType is DelegateDeclarationSyntax)
					curMember = null;
				if (isPathSet && curType == lastType && curMember == lastMember && curProject == lastProject) {
					return;
				}
				var curTypeMakeup = GetEntityMarkup(curType);
				var curMemberMarkup = GetEntityMarkup(curMember);
				if (isPathSet && curType != null && lastType != null && curTypeMakeup == lastTypeMarkup &&
					curMember != null && lastMember != null && curMemberMarkup == lastMemberMarkup && curProject == lastProject) {
					return;
				}


				var result = new List<PathEntry>();

				if (ownerProjects != null && ownerProjects.Count > 1) {
					// Current project if there is more than one
					result.Add (new PathEntry (ImageService.GetIcon (DocumentContext.Project.StockIcon, Gtk.IconSize.Menu), GLib.Markup.EscapeText (DocumentContext.Project.Name)) { Tag = DocumentContext.Project });
				}
				if (curType == null) {
					if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is CSharpSyntaxTree)
						return;
					if (CurrentPath != null && CurrentPath.Length == 2 && CurrentPath [1].Tag is CSharpSyntaxTree)
						return;
					var prevPath = CurrentPath;
					result.Add (new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit });
					Gtk.Application.Invoke (delegate {
						if (cancellationToken.IsCancellationRequested)
							return;

						CurrentPath = result.ToArray ();
						lastType = curType;
						lastTypeMarkup = curTypeMakeup;

						lastMember = curMember;
						lastMemberMarkup = curMemberMarkup;

						lastProject = curProject;
						OnPathChanged (new DocumentPathChangedEventArgs (prevPath));
					});
					return;
				}
				var regionEntry = await GetRegionEntry (DocumentContext.ParsedDocument, loc).ConfigureAwait (false);

				Gtk.Application.Invoke(delegate {
					if (curType != null) {
						var type = curType;
						var pos = result.Count;
						while (type != null) {
							if (!(type is BaseTypeDeclarationSyntax))
								break;
							var tag = (object)type.Ancestors ().FirstOrDefault (IsType) ?? unit;
							result.Insert (pos, new PathEntry (ImageService.GetIcon (type.GetStockIcon (), Gtk.IconSize.Menu), GetEntityMarkup (type)) { Tag = tag });
							type = type.Parent;
						}
					}
					if (curMember != null) {
						result.Add (new PathEntry (ImageService.GetIcon (curMember.GetStockIcon (), Gtk.IconSize.Menu), curMemberMarkup) { Tag = curMember });
						if (curMember.Kind () == SyntaxKind.GetAccessorDeclaration ||
						curMember.Kind () == SyntaxKind.SetAccessorDeclaration ||
						curMember.Kind () == SyntaxKind.AddAccessorDeclaration ||
						curMember.Kind () == SyntaxKind.RemoveAccessorDeclaration) {
							var parent = curMember.Parent;
							if (parent != null)
								result.Insert (result.Count - 1, new PathEntry (ImageService.GetIcon (parent.GetStockIcon (), Gtk.IconSize.Menu), GetEntityMarkup (parent)) { Tag = parent });
						}
					}

					if (regionEntry != null)
						result.Add(regionEntry);

					PathEntry noSelection = null;
					if (curType == null) {
						noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit };
					} else if (curMember == null && !(curType is DelegateDeclarationSyntax)) {
						noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = curType };
					}

					if (noSelection != null)
						result.Add(noSelection);
					var prev = CurrentPath;
					if (prev != null && prev.Length == result.Count) {
						bool equals = true;
						for (int i = 0; i < prev.Length; i++) {
							if (prev [i].Markup != result [i].Markup) {
								equals = false;
								break;
							}
						}
						if (equals)
							return;
					}
					if (cancellationToken.IsCancellationRequested)
						return;
					CurrentPath = result.ToArray();
					lastType = curType;
					lastTypeMarkup = curTypeMakeup;

					lastMember = curMember;
					lastMemberMarkup = curMemberMarkup;

					lastProject = curProject;

					OnPathChanged (new DocumentPathChangedEventArgs(prev));
				});
			});
		}
Esempio n. 5
0
        void UpdatePath(object sender, Mono.TextEditor.DocumentLocationEventArgs e)
        {
            var parsedDocument = Document.ParsedDocument;

            if (parsedDocument == null || parsedDocument.ParsedFile == null)
            {
                return;
            }
            amb = new AstAmbience(document.GetFormattingOptions());

            var unit = parsedDocument.GetAst <SyntaxTree> ();

            if (unit == null)
            {
                return;
            }

            var loc = Document.Editor.Caret.Location;

            var curType   = (EntityDeclaration)unit.GetNodeAt(loc, n => n is TypeDeclaration || n is DelegateDeclaration);
            var curMember = unit.GetNodeAt <EntityDeclaration> (loc);

            if (curType == curMember)
            {
                curMember = null;
            }
            if (isPathSet && curType == lastType && lastMember == curMember)
            {
                return;
            }

            var curTypeMakeup   = GetEntityMarkup(curType);
            var curMemberMarkup = GetEntityMarkup(curMember);

            if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
                curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup)
            {
                return;
            }

            lastType       = curType;
            lastTypeMarkup = curTypeMakeup;

            lastMember       = curMember;
            lastMemberMarkup = curMemberMarkup;

            if (curType == null)
            {
                if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
                {
                    return;
                }
                var prevPath = CurrentPath;
                CurrentPath = new PathEntry[] { new PathEntry(GettextCatalog.GetString("No selection"))
                                                {
                                                    Tag = unit
                                                } };
                OnPathChanged(new DocumentPathChangedEventArgs(prevPath));
                return;
            }

            //	ThreadPool.QueueUserWorkItem (delegate {
            var result = new List <PathEntry> ();

            if (curType != null)
            {
                var type = curType;
                while (type != null)
                {
                    var declaringType = type.Parent as TypeDeclaration;
                    result.Insert(0, new PathEntry(ImageService.GetPixbuf(type.GetStockIcon(false), Gtk.IconSize.Menu), GetEntityMarkup(type))
                    {
                        Tag = (AstNode)declaringType ?? unit
                    });
                    type = declaringType;
                }
            }

            if (curMember != null)
            {
                result.Add(new PathEntry(ImageService.GetPixbuf(curMember.GetStockIcon(true), Gtk.IconSize.Menu), curMemberMarkup)
                {
                    Tag = curMember
                });
                if (curMember is Accessor)
                {
                    var parent = curMember.Parent as EntityDeclaration;
                    if (parent != null)
                    {
                        result.Insert(result.Count - 1, new PathEntry(ImageService.GetPixbuf(parent.GetStockIcon(true), Gtk.IconSize.Menu), GetEntityMarkup(parent))
                        {
                            Tag = parent
                        });
                    }
                }
            }

            var entry = GetRegionEntry(parsedDocument, loc);

            if (entry != null)
            {
                result.Add(entry);
            }

            PathEntry noSelection = null;

            if (curType == null)
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = unit
                };
            }
            else if (curMember == null && !(curType is DelegateDeclaration))
            {
                noSelection = new PathEntry(GettextCatalog.GetString("No selection"))
                {
                    Tag = curType
                };
            }

            if (noSelection != null)
            {
                result.Add(noSelection);
            }

            var prev = CurrentPath;

            if (prev != null && prev.Length == result.Count)
            {
                bool equals = true;
                for (int i = 0; i < prev.Length; i++)
                {
                    if (prev [i].Markup != result [i].Markup)
                    {
                        equals = false;
                        break;
                    }
                }
                if (equals)
                {
                    return;
                }
            }
            //		Gtk.Application.Invoke (delegate {
            CurrentPath = result.ToArray();
            OnPathChanged(new DocumentPathChangedEventArgs(prev));
            //		});
            //	});
        }
		void UpdatePath (object sender, Mono.TextEditor.DocumentLocationEventArgs e)
		{
			var parsedDocument = Document.ParsedDocument;
			if (parsedDocument == null || parsedDocument.ParsedFile == null)
				return;
			amb = new AstAmbience (document.GetFormattingOptions ());
			
			var unit = parsedDocument.GetAst<SyntaxTree> ();
			if (unit == null)
				return;

			var loc = Document.Editor.Caret.Location;

			var curType = (EntityDeclaration)unit.GetNodeAt (loc, n => n is TypeDeclaration || n is DelegateDeclaration);
			var curMember = unit.GetNodeAt<EntityDeclaration> (loc);
			if (curType == curMember)
				curMember = null;
			if (isPathSet && curType == lastType && lastMember == curMember)
				return;

			var curTypeMakeup = GetEntityMarkup (curType);
			var curMemberMarkup = GetEntityMarkup (curMember);
			if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
			    curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup)
				return;

			lastType = curType;
			lastTypeMarkup = curTypeMakeup;

			lastMember = curMember;
			lastMemberMarkup = curMemberMarkup;

			if (curType == null) {
				if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
					return;
				var prevPath = CurrentPath;
				CurrentPath = new PathEntry[] { new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit } };
				OnPathChanged (new DocumentPathChangedEventArgs (prevPath));	
				return;
			}
			
			//	ThreadPool.QueueUserWorkItem (delegate {
			var result = new List<PathEntry> ();

			if (curType != null) {
				var type = curType;
				while (type != null) {
					var declaringType = type.Parent as TypeDeclaration;
					result.Insert (0, new PathEntry (ImageService.GetPixbuf (type.GetStockIcon (false), Gtk.IconSize.Menu), GetEntityMarkup (type)) { Tag = (AstNode)declaringType ?? unit });
					type = declaringType;
				}
			}
				
			if (curMember != null) {
				result.Add (new PathEntry (ImageService.GetPixbuf (curMember.GetStockIcon (true), Gtk.IconSize.Menu), curMemberMarkup) { Tag = curMember });
				if (curMember is Accessor) {
					var parent = curMember.Parent as EntityDeclaration;
					if (parent != null)
						result.Insert (result.Count - 1, new PathEntry (ImageService.GetPixbuf (parent.GetStockIcon (true), Gtk.IconSize.Menu), GetEntityMarkup (parent)) { Tag = parent });
				}
			}
				
			var entry = GetRegionEntry (parsedDocument, loc);
			if (entry != null)
				result.Add (entry);
				
			PathEntry noSelection = null;
			if (curType == null) {
				noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit };
			} else if (curMember == null && !(curType is DelegateDeclaration)) { 
				noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = curType };
			}

			if (noSelection != null) 
				result.Add (noSelection);

			var prev = CurrentPath;
			if (prev != null && prev.Length == result.Count) {
				bool equals = true;
				for (int i = 0; i < prev.Length; i++) {
					if (prev [i].Markup != result [i].Markup) {
						equals = false;
						break;
					}
				}
				if (equals)
					return;
			}
			//		Gtk.Application.Invoke (delegate {
			CurrentPath = result.ToArray ();
			OnPathChanged (new DocumentPathChangedEventArgs (prev));	
			//		});
			//	});
		}