You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
|
|
|
using System; |
|
using System.IO; |
|
using ICSharpCode.Core; |
|
using ICSharpCode.NRefactory.Semantics; |
|
using ICSharpCode.NRefactory.TypeSystem; |
|
using ICSharpCode.SharpDevelop.Gui; |
|
using ICSharpCode.SharpDevelop.Project; |
|
using Mono.Cecil; |
|
|
|
namespace ICSharpCode.SharpDevelop.Editor.Commands |
|
{ |
|
public class GoToDefinition : ResolveResultMenuCommand |
|
{ |
|
public override void Run(ResolveResult symbol) |
|
{ |
|
if (symbol == null) |
|
return; |
|
|
|
DomRegion pos = symbol.GetDefinitionRegion(); |
|
if (string.IsNullOrEmpty(pos.FileName)) { |
|
IEntity entity = GetEntity(symbol); |
|
if (entity != null) { |
|
NavigationService.NavigateTo(entity); |
|
} |
|
} else { |
|
try { |
|
if (pos.Begin.IsEmpty) |
|
FileService.OpenFile(pos.FileName); |
|
else |
|
FileService.JumpToFilePosition(pos.FileName, pos.BeginLine, pos.BeginColumn); |
|
} catch (Exception ex) { |
|
MessageService.ShowException(ex, "Error jumping to '" + pos.FileName + "'."); |
|
} |
|
} |
|
} |
|
} |
|
}
|
|
|