void UpdatePath (object sender, Mono.TextEditor.DocumentLocationEventArgs e)
{
var unit = Document.CompilationUnit;
if (unit == null)
return;
var loc = textEditorData.Caret.Location;
IType type = unit.GetTypeAt (loc.Line, loc.Column);
IMember member = type != null && type.ClassType != ClassType.Delegate ? type.GetMemberAt (loc.Line, loc.Column) : null;
List<PathEntry> result = new List<PathEntry> ();
var amb = GetAmbience ();
INode node = member ?? type ?? (INode)unit;
while (node != null) {
PathEntry entry;
if (node is ICompilationUnit) {
if (!Document.ParsedDocument.UserRegions.Any ())
break;
FoldingRegion reg = Document.ParsedDocument.UserRegions.Where (r => r.Region.Contains (loc.Line, loc.Column)).LastOrDefault ();
if (reg == null) {
entry = new PathEntry (GettextCatalog.GetString ("No region"));
} else {
entry = new PathEntry (CompilationUnitDataProvider.Pixbuf,
reg.Name);
}
entry.Position = EntryPosition.Right;
} else {
entry = new PathEntry (ImageService.GetPixbuf (((IMember)node).StockIcon, IconSize.Menu), amb.GetString ((IMember)node, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates));
}
entry.Tag = node;
result.Insert (0, entry);
node = node.Parent;
}
PathEntry noSelection = null;
if (type == null) {
noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = new CustomNode (Document.CompilationUnit) };
} else if (member == null && type.ClassType != ClassType.Delegate)
noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = new CustomNode (type) };
if (noSelection != null) {
/* if (result.Count > 0 && result[result.Count - 1].Tag is ICompilationUnit) {
result.Insert (result.Count - 1, noSelection);
} else {*/
result.Add (noSelection);
// }
}
var prev = CurrentPath;
CurrentPath = result.ToArray ();
OnPathChanged (new DocumentPathChangedEventArgs (prev));
}
#endregion