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/AddViewFromControllerCommandHandler.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/AddViewFromControllerCommandHandler.cs')
-rw-r--r-- | main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs b/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs index 0d732c6f54..ed0bd44867 100644 --- a/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs +++ b/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs @@ -43,16 +43,12 @@ namespace MonoDevelop.AspNet.Commands {
var doc = IdeApp.Workbench.ActiveDocument;
var project = (DotNetProject)doc.Project;
- var currentLocation = doc.Editor.Caret.Location;
- string controllerName = doc.ParsedDocument.GetTopLevelTypeDefinition (currentLocation).Name;
- int pos = controllerName.LastIndexOf ("Controller", StringComparison.Ordinal);
- if (pos > 0)
- controllerName = controllerName.Remove (pos);
+ var method = MethodDeclarationAtCaret.Create (doc);
+ string controllerName = method.GetParentMvcControllerName ();
+ string path = doc.FileName.ParentDirectory.ParentDirectory.Combine ("Views", controllerName);
- string path = doc.FileName.ParentDirectory.ParentDirectory.Combine ("Views", controllerName); - string actionName = doc.ParsedDocument.GetMember (currentLocation).Name;
- AddView (project, path, actionName);
+ AddView (project, path, method.Name);
}
public static void AddView (DotNetProject project, string path, string name)
|