diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs')
-rw-r--r-- | main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs b/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs index 67c80ed920..fb944f910e 100644 --- a/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs +++ b/main/src/addins/AspNet/Commands/GoToControllerCommandHandler.cs @@ -26,15 +26,16 @@ using System;
using System.Linq;
-using ICSharpCode.NRefactory.TypeSystem;
+using ICSharpCode.NRefactory6.CSharp;
+using Microsoft.CodeAnalysis;
+using MonoDevelop.AspNet.Projects;
using MonoDevelop.Components.Commands;
using MonoDevelop.Core;
using MonoDevelop.Ide;
-using MonoDevelop.AspNet.Projects;
+using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.AspNet.Commands
{
-
class GoToControllerCommandHandler : CommandHandler
{
protected override void Update (CommandInfo info)
@@ -58,13 +59,22 @@ namespace MonoDevelop.AspNet.Commands {
var doc = IdeApp.Workbench.ActiveDocument;
var name = doc.FileName.ParentDirectory.FileName;
- var controller = doc.ProjectContent.GetAllTypeDefinitions ().FirstOrDefault (t => t.Name == name + "Controller");
+ var controller = FindController (doc.Project, name);
if (controller != null)
- IdeApp.Workbench.OpenDocument (controller.UnresolvedFile.FileName, doc.Project);
+ IdeApp.ProjectOperations.JumpToDeclaration (controller, doc.Project);
else
MessageService.ShowError ("Matching controller cannot be found.");
}
+
+ INamedTypeSymbol FindController (MonoDevelop.Projects.Project project, string name)
+ {
+ var compilation = TypeSystemService.GetCompilationAsync (project).Result;
+ if (compilation == null)
+ return null;
+
+ return compilation.GetAllTypesInMainAssembly ()
+ .FirstOrDefault (symbol => symbol.Name == name + "Controller");
+ }
}
-
}
|