diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates')
15 files changed, 41 insertions, 39 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeDomFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeDomFileDescriptionTemplate.cs index f4f064c1cd..3a57928536 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeDomFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeDomFileDescriptionTemplate.cs @@ -115,7 +115,7 @@ namespace MonoDevelop.Ide.Templates } } - int offset = doc.GetLine (realStartLine).Offset; + int offset = doc.GetLine (Math.Max(Mono.TextEditor.DocumentLocation.MinLine, realStartLine)).Offset; return doc.GetTextAt (offset, doc.TextLength - offset); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs index f641faee66..0a669a7b17 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs @@ -134,7 +134,7 @@ namespace MonoDevelop.Ide.Templates return txt.Substring (i+1); } - public override void ModifyTags (SolutionItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) + public override void ModifyTags (SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) { //prevent parser breakage from missing tags, which SingleFile only provides for DotNetProject //if ((project as DotNetProject) == null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/DirectoryTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/DirectoryTemplate.cs index 6f91811444..9992402f8c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/DirectoryTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/DirectoryTemplate.cs @@ -87,7 +87,7 @@ namespace MonoDevelop.Ide.Templates t.Show (); } - public override bool AddToProject (SolutionItem policyParent, Project project, + public override bool AddToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string name) { bool addedSomething = false; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs index 181afb93cf..bb103f722c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs @@ -75,7 +75,7 @@ namespace MonoDevelop.Ide.Templates public abstract string Name { get; } public abstract void Load (XmlElement filenode, FilePath baseDirectory); - public abstract bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name); + public abstract bool AddToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string name); public abstract void Show (); public virtual bool IsValidName (string name, string language) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs index dd3fc5d476..93ab834b62 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs @@ -294,7 +294,7 @@ namespace MonoDevelop.Ide.Templates return null; } - public virtual bool Create (SolutionItem policyParent, Project project, string directory, string language, string name) + public virtual bool Create (SolutionFolderItem policyParent, Project project, string directory, string language, string name) { if (!String.IsNullOrEmpty(WizardPath)) { //Properties customizer = new Properties(); @@ -342,7 +342,7 @@ namespace MonoDevelop.Ide.Templates return mimeType; } - public virtual bool CanCreateUnsavedFiles (FileDescriptionTemplate newfile, SolutionItem policyParent, Project project, string directory, string language, string name) + public virtual bool CanCreateUnsavedFiles (FileDescriptionTemplate newfile, SolutionFolderItem policyParent, Project project, string directory, string language, string name) { if (project != null) { return true; @@ -361,7 +361,7 @@ namespace MonoDevelop.Ide.Templates } } - protected virtual bool CreateFile (FileDescriptionTemplate newfile, SolutionItem policyParent, Project project, string directory, string language, string name) + protected virtual bool CreateFile (FileDescriptionTemplate newfile, SolutionFolderItem policyParent, Project project, string directory, string language, string name) { if (project != null) { if (newfile.AddToProject (policyParent, project, language, directory, name)) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs index 97dd1c0f92..0e09e343a9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs @@ -69,7 +69,7 @@ namespace MonoDevelop.Ide.Templates get { return name;} } - public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string entryName) + public override bool AddToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string entryName) { string[,] customTags = new string[,] { {"ProjectName", project.Name}, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemDescriptor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemDescriptor.cs index 9012f7b9ba..13d6804573 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemDescriptor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemDescriptor.cs @@ -34,7 +34,7 @@ namespace MonoDevelop.Ide.Templates { internal interface ISolutionItemDescriptor { - SolutionEntityItem CreateItem (ProjectCreateInformation projectCreateInformation, string defaultLanguage); - void InitializeItem (SolutionItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionEntityItem item); + SolutionItem CreateItem (ProjectCreateInformation projectCreateInformation, string defaultLanguage); + void InitializeItem (SolutionFolderItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionItem item); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemFeature.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemFeature.cs index dcd4ace676..f328a3472f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemFeature.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ISolutionItemFeature.cs @@ -75,7 +75,7 @@ namespace MonoDevelop.Ide.Templates /// The provided item, parent folder and parent solution may or may not have a file name, and even if they /// have, they may not be saved to disk. parentFolder can be null. /// </remarks> - FeatureSupportLevel GetSupportLevel (SolutionFolder parentFolder, SolutionItem item); + FeatureSupportLevel GetSupportLevel (SolutionFolder parentFolder, SolutionFolderItem item); /// <summary> /// Short title of the feature @@ -103,7 +103,7 @@ namespace MonoDevelop.Ide.Templates /// The provided item, parent folder and parent solution may or may not have a file name, and even if they /// have, they may not be saved to disk. /// </remarks> - Gtk.Widget CreateFeatureEditor (SolutionFolder parentFolder, SolutionItem entry); + Gtk.Widget CreateFeatureEditor (SolutionFolder parentFolder, SolutionFolderItem entry); /// <summary> /// Validates the configuration of the feature @@ -128,7 +128,7 @@ namespace MonoDevelop.Ide.Templates /// The provided item, parent folder and parent solution may or may not have a file name, and even if they /// have, they may not be saved to disk. /// </remarks> - string Validate (SolutionFolder parentFolder, SolutionItem entry, Gtk.Widget editor); + string Validate (SolutionFolder parentFolder, SolutionFolderItem entry, Gtk.Widget editor); /// <summary> /// Applies the feature to a project @@ -146,12 +146,12 @@ namespace MonoDevelop.Ide.Templates /// The provided item, parent folder and parent solution may or may not have a file name, and even if they /// have, they may not be saved to disk. /// </remarks> - void ApplyFeature (SolutionFolder parentFolder, SolutionItem entry, Gtk.Widget editor); + void ApplyFeature (SolutionFolder parentFolder, SolutionFolderItem entry, Gtk.Widget editor); } internal class SolutionItemFeatures { - public static ISolutionItemFeature[] GetFeatures (SolutionFolder parentCombine, SolutionItem entry) + public static ISolutionItemFeature[] GetFeatures (SolutionFolder parentCombine, SolutionFolderItem entry) { List<ISolutionItemFeature> list = new List<ISolutionItemFeature> (); foreach (ISolutionItemFeature e in AddinManager.GetExtensionObjects ("/MonoDevelop/Ide/ProjectFeatures", typeof(ISolutionItemFeature), true)) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectDescriptor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectDescriptor.cs index ce49a15daa..196289b82d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectDescriptor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectDescriptor.cs @@ -117,12 +117,12 @@ namespace MonoDevelop.Ide.Templates return projectDescriptor; } - public SolutionEntityItem CreateItem (ProjectCreateInformation projectCreateInformation, string defaultLanguage) + public SolutionItem CreateItem (ProjectCreateInformation projectCreateInformation, string defaultLanguage) { if (string.IsNullOrEmpty (projectOptions.GetAttribute ("language")) && !string.IsNullOrEmpty (defaultLanguage)) projectOptions.SetAttribute ("language", defaultLanguage); - if (!Services.ProjectService.CanCreateProject (type)) { + if (!Services.ProjectService.CanCreateProject (type, projectCreateInformation, projectOptions)) { LoggingService.LogError ("Could not create project of type '" + type + "'. Project skipped"); return null; } @@ -130,7 +130,7 @@ namespace MonoDevelop.Ide.Templates return project; } - public void InitializeItem (SolutionItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionEntityItem item) + public void InitializeItem (SolutionFolderItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionItem item) { MonoDevelop.Projects.Project project = item as MonoDevelop.Projects.Project; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs index 9640135723..796235af41 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs @@ -46,6 +46,7 @@ using MonoDevelop.Ide.Codons; using MonoDevelop.Projects; using MonoDevelop.Ide.Gui; using System.Linq; +using System.Threading.Tasks; namespace MonoDevelop.Ide.Templates { @@ -217,17 +218,18 @@ namespace MonoDevelop.Ide.Templates } //methods - public IAsyncOperation OpenCreatedSolution () + public Task<bool> OpenCreatedSolution () { - IAsyncOperation asyncOperation = IdeApp.Workspace.OpenWorkspaceItem (createdSolutionName); - asyncOperation.Completed += delegate { - if (asyncOperation.Success) { + var asyncOperation = IdeApp.Workspace.OpenWorkspaceItem (createdSolutionName); + return asyncOperation.ContinueWith (t => { + if (t.Result) { foreach (string action in actions) { IdeApp.Workbench.OpenDocument (Path.Combine (createdProjectInformation.ProjectBasePath, action)); } + return true; } - }; - return asyncOperation; + return false; + }); } public WorkspaceItem CreateWorkspaceItem (ProjectCreateInformation cInfo) @@ -241,13 +243,13 @@ namespace MonoDevelop.Ide.Templates return workspaceItemInfo.WorkspaceItem; } - public SolutionEntityItem CreateProject (SolutionItem policyParent, ProjectCreateInformation cInfo) + public SolutionItem CreateProject (SolutionFolderItem policyParent, ProjectCreateInformation cInfo) { if (solutionDescriptor.EntryDescriptors.Length == 0) throw new InvalidOperationException ("Solution template doesn't have any project templates"); ISolutionItemDescriptor descriptor = solutionDescriptor.EntryDescriptors [0]; - SolutionEntityItem solutionEntryItem = descriptor.CreateItem (cInfo, this.languagename); + SolutionItem solutionEntryItem = descriptor.CreateItem (cInfo, this.languagename); descriptor.InitializeItem (policyParent, cInfo, this.languagename, solutionEntryItem); SavePackageReferences (solutionEntryItem, descriptor); @@ -257,7 +259,7 @@ namespace MonoDevelop.Ide.Templates return solutionEntryItem; } - void SavePackageReferences (SolutionEntityItem solutionEntryItem, ISolutionItemDescriptor descriptor) + void SavePackageReferences (SolutionItem solutionEntryItem, ISolutionItemDescriptor descriptor) { packageReferencesForCreatedProjects = new List<PackageReferencesForCreatedProject> (); if ((solutionEntryItem is Project) && (descriptor is ProjectDescriptor)) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs index e2cb831041..b52003c6ca 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ResourceFileDescriptionTemplate.cs @@ -53,7 +53,7 @@ namespace MonoDevelop.Ide.Templates } } - public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name) + public override bool AddToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string name) { ProjectFile file = template.AddFileToProject (policyParent, project, language, directory, name); if (file != null) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs index b9a2a6ffa0..701850e4e7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs @@ -104,12 +104,12 @@ namespace MonoDevelop.Ide.Templates set { addStandardHeader = value; } } - public sealed override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name) + public sealed override bool AddToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string name) { return AddFileToProject (policyParent, project, language, directory, name) != null; } - public ProjectFile AddFileToProject (SolutionItem policyParent, Project project, string language, string directory, string name) + public ProjectFile AddFileToProject (SolutionFolderItem policyParent, Project project, string language, string directory, string name) { generatedFile = SaveFile (policyParent, project, language, directory, name); if (generatedFile != null) { @@ -187,7 +187,7 @@ namespace MonoDevelop.Ide.Templates // Creates a file and saves it to disk. Returns the path to the new file // All parameters are optional (can be null) - public string SaveFile (SolutionItem policyParent, Project project, string language, string baseDirectory, string entryName) + public string SaveFile (SolutionFolderItem policyParent, Project project, string language, string baseDirectory, string entryName) { string file = GetFileName (policyParent, project, language, baseDirectory, entryName); @@ -221,7 +221,7 @@ namespace MonoDevelop.Ide.Templates // Returns the name of the file that this template generates. // All parameters are optional (can be null) - public virtual string GetFileName (SolutionItem policyParent, Project project, string language, string baseDirectory, string entryName) + public virtual string GetFileName (SolutionFolderItem policyParent, Project project, string language, string baseDirectory, string entryName) { if (string.IsNullOrEmpty (entryName) && !string.IsNullOrEmpty (defaultName)) entryName = defaultName; @@ -257,7 +257,7 @@ namespace MonoDevelop.Ide.Templates // Returns a stream with the content of the file. // project and language parameters are optional - public virtual Stream CreateFileContent (SolutionItem policyParent, Project project, string language, string fileName, string identifier) + public virtual Stream CreateFileContent (SolutionFolderItem policyParent, Project project, string language, string fileName, string identifier) { Dictionary<string, string> tags = new Dictionary<string, string> (); ModifyTags (policyParent, project, language, identifier, fileName, ref tags); @@ -326,7 +326,7 @@ namespace MonoDevelop.Ide.Templates // We supply defaults whenever it is possible, to avoid having unsubstituted tags. However, // do not substitute blanks when a sensible default cannot be guessed, because they result //in less obvious errors. - public virtual void ModifyTags (SolutionItem policyParent, Project project, string language, + public virtual void ModifyTags (SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) { DotNetProject netProject = project as DotNetProject; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionDescriptor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionDescriptor.cs index 02c0eb2e38..e70f9e5f30 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionDescriptor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionDescriptor.cs @@ -151,7 +151,7 @@ namespace MonoDevelop.Ide.Templates var solutionItemDesc = entryDescriptors[i]; - SolutionEntityItem info = solutionItemDesc.CreateItem (entryProjectCI, defaultLanguage); + SolutionItem info = solutionItemDesc.CreateItem (entryProjectCI, defaultLanguage); if (info == null) continue; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionItemDescriptor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionItemDescriptor.cs index a0a04fc553..9a5eba1eeb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionItemDescriptor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionItemDescriptor.cs @@ -60,7 +60,7 @@ namespace MonoDevelop.Ide.Templates template = element; } - public SolutionEntityItem CreateItem (ProjectCreateInformation projectCreateInformation, string defaultLanguage) + public SolutionItem CreateItem (ProjectCreateInformation projectCreateInformation, string defaultLanguage) { Type type = addin.GetType (typeName, false); @@ -69,7 +69,7 @@ namespace MonoDevelop.Ide.Templates return null; } - SolutionEntityItem item = (SolutionEntityItem) Activator.CreateInstance (type); + SolutionItem item = (SolutionItem) Activator.CreateInstance (type); item.InitializeFromTemplate (template); string newProjectName = StringParserService.Parse (name, new string[,] { @@ -82,7 +82,7 @@ namespace MonoDevelop.Ide.Templates return item; } - public void InitializeItem (SolutionItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionEntityItem item) + public void InitializeItem (SolutionFolderItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionItem item) { } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs index 4092840eaf..eb56927303 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TextFileDescriptionTemplate.cs @@ -95,7 +95,7 @@ namespace MonoDevelop.Ide.Templates contentSrcFile = contentSrcFile.ToAbsolute (baseDirectory); } - public override Stream CreateFileContent (SolutionItem policyParent, Project project, string language, + public override Stream CreateFileContent (SolutionFolderItem policyParent, Project project, string language, string fileName, string identifier) { return File.OpenRead (contentSrcFile); |