Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 3 additions & 31 deletions Nodejs/Product/Nodejs/Project/NewFileMenuGroup/NewFileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,12 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using Microsoft.VisualStudio.Shell.Interop;

namespace Microsoft.NodejsTools.Project.NewFileMenuGroup {
internal static class NewFileUtilities {
public static string GetTemplateFile(string fileType) {
string templateFileName = null;

switch (fileType) {
case NodejsConstants.JavaScript:
templateFileName = "EmptyJs.js";
break;
case NodejsConstants.TypeScript:
templateFileName = "EmptyTs.ts";
break;
case NodejsConstants.HTML:
templateFileName = "EmptyHTML.html";
break;
case NodejsConstants.CSS:
templateFileName = "EmptyCSS.css";
break;
}

if (templateFileName == null) {
Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Invalid file type: {0}", fileType));
}

return NodejsToolsInstallPath.GetFile("FileTemplates\\NewItem\\" + templateFileName);
}

private static string GetInitialName(string fileType) {

switch (fileType) {
case NodejsConstants.JavaScript:
return "JavaScript.js";
Expand All @@ -74,12 +49,9 @@ private static void CreateNewFile(NodejsProjectNode projectNode, uint containerI
VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE, // Indicate that we want to create this new file by cloning a template file.
itemName,
1, // Number of templates in the next parameter. Must be 1 if using VSADDITEMOP_CLONEFILE.
new string[] { GetTemplateFile(fileType) }, // Array contains the template file path.
new string[] { Path.GetTempFileName() }, // Array contains the template file path.
IntPtr.Zero, // Handle to the Add Item dialog box. Must be Zero if using VSADDITEMOP_CLONEFILE.
pResult
);

// TODO: Do we need to check if result[0] = VSADDRESULT.ADDRESULT_Success here?
pResult);
}
}
}
Expand Down