Skip to content

Commit 9a65fa0

Browse files
authored
Merge pull request #1624 from paulvanbrenk/ctiIssues
Cti issues
2 parents 9bd8694 + f2cb36d commit 9a65fa0

File tree

15 files changed

+237
-253
lines changed

15 files changed

+237
-253
lines changed

Nodejs/Product/Nodejs/Debugger/DebugEngine/AD7Engine.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Microsoft.NodejsTools.Debugger.Remote;
1414
using Microsoft.NodejsTools.Logging;
1515
using Microsoft.NodejsTools.Project;
16+
using Microsoft.NodejsTools.TypeScript;
1617
using Microsoft.VisualStudio;
1718
using Microsoft.VisualStudio.Debugger.Interop;
1819
using Microsoft.VisualStudio.Shell;
@@ -1370,7 +1371,7 @@ private void OnDocumentSaved(Document document)
13701371
}
13711372

13721373
// For .ts files, we need to build the project to regenerate .js code.
1373-
if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(module.FileName), NodejsConstants.TypeScriptExtension))
1374+
if (TypeScriptHelpers.IsTypeScriptFile(module.FileName))
13741375
{
13751376
if (document.ProjectItem.ContainingProject.GetNodeProject().Build(null, null) != MSBuildResult.Successful)
13761377
{
@@ -1395,7 +1396,7 @@ private void OnDocumentSaved(Document document)
13951396

13961397
internal static void MapLanguageInfo(string filename, out string pbstrLanguage, out Guid pguidLanguage)
13971398
{
1398-
if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(filename), NodejsConstants.TypeScriptExtension))
1399+
if (TypeScriptHelpers.IsTypeScriptFile(filename))
13991400
{
14001401
pbstrLanguage = NodejsConstants.TypeScript;
14011402
pguidLanguage = Guids.TypeScriptDebugLanguage;

Nodejs/Product/Nodejs/NodejsConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace Microsoft.NodejsTools
88
internal static class NodejsConstants
99
{
1010
internal const string JavaScriptExtension = ".js";
11+
internal const string JavaScriptJsxExtension = ".jsx";
1112
internal const string TypeScriptExtension = ".ts";
13+
internal const string TypeScriptJsxExtension = ".tsx";
1214
internal const string TypeScriptDeclarationExtension = ".d.ts";
1315
internal const string MapExtension = ".map";
1416
internal const string NodejsProjectExtension = ".njsproj";

Nodejs/Product/Nodejs/Project/NodejsProjectNode.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Threading.Tasks;
1414
using Microsoft.NodejsTools.Npm;
1515
using Microsoft.NodejsTools.ProjectWizard;
16+
using Microsoft.NodejsTools.TypeScript;
1617
using Microsoft.VisualStudio;
1718
using Microsoft.VisualStudio.Imaging;
1819
using Microsoft.VisualStudio.Imaging.Interop;
@@ -188,7 +189,7 @@ protected override void AddNewFileNodeToHierarchy(HierarchyNode parentNode, stri
188189

189190
private static bool IsProjectTypeScriptSourceFile(string path)
190191
{
191-
return StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(path), NodejsConstants.TypeScriptExtension)
192+
return TypeScriptHelpers.IsTypeScriptFile(path)
192193
&& !StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(path), NodejsConstants.TypeScriptDeclarationExtension)
193194
&& !NodejsConstants.ContainsNodeModulesOrBowerComponentsFolder(path);
194195
}
@@ -197,7 +198,8 @@ internal static bool IsNodejsFile(string strFileName)
197198
{
198199
var ext = Path.GetExtension(strFileName);
199200

200-
return StringComparer.OrdinalIgnoreCase.Equals(ext, NodejsConstants.JavaScriptExtension);
201+
return StringComparer.OrdinalIgnoreCase.Equals(ext, NodejsConstants.JavaScriptExtension) ||
202+
StringComparer.OrdinalIgnoreCase.Equals(ext, NodejsConstants.JavaScriptJsxExtension);
201203
}
202204

203205
internal override string GetItemType(string filename)
@@ -208,13 +210,12 @@ internal override string GetItemType(string filename)
208210
Path.Combine(this.ProjectHome, filename);
209211

210212
var node = this.FindNodeByFullPath(absFileName) as NodejsFileNode;
211-
if (node != null && node.ItemNode.ItemTypeName != null)
213+
if (node?.ItemNode?.ItemTypeName != null)
212214
{
213215
return node.ItemNode.ItemTypeName;
214216
}
215217

216-
// TODO: make sure this also works for .tsx
217-
if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(filename), NodejsConstants.TypeScriptExtension))
218+
if (TypeScriptHelpers.IsTypeScriptFile(filename))
218219
{
219220
return NodejsConstants.TypeScriptCompileItemType;
220221
}
@@ -271,7 +272,14 @@ protected override bool DisableCmdInCurrentMode(Guid commandGroup, uint command)
271272
return false;
272273
}
273274

274-
public override string[] CodeFileExtensions => new[] { NodejsConstants.JavaScriptExtension };
275+
private static readonly string[] codeFileExtensions = new[] {
276+
NodejsConstants.JavaScriptExtension,
277+
NodejsConstants.JavaScriptJsxExtension,
278+
NodejsConstants.TypeScriptExtension,
279+
NodejsConstants.TypeScriptJsxExtension
280+
};
281+
282+
public override string[] CodeFileExtensions => codeFileExtensions;
275283

276284
protected internal override FolderNode CreateFolderNode(ProjectElement element)
277285
{
@@ -281,13 +289,11 @@ protected internal override FolderNode CreateFolderNode(ProjectElement element)
281289
public override CommonFileNode CreateCodeFileNode(ProjectElement item)
282290
{
283291
var fileName = item.Url;
284-
if (!string.IsNullOrWhiteSpace(fileName)
285-
&& Path.GetExtension(fileName).Equals(NodejsConstants.TypeScriptExtension, StringComparison.OrdinalIgnoreCase))
292+
if (!string.IsNullOrWhiteSpace(fileName) && TypeScriptHelpers.IsTypeScriptFile(fileName))
286293
{
287294
return new NodejsTypeScriptFileNode(this, item);
288295
}
289-
var res = new NodejsFileNode(this, item);
290-
return res;
296+
return new NodejsFileNode(this, item);
291297
}
292298

293299
public override string GetProjectName()
@@ -361,8 +367,9 @@ protected override NodeProperties CreatePropertiesObject()
361367
public override bool IsCodeFile(string fileName)
362368
{
363369
var ext = Path.GetExtension(fileName);
364-
return ext.Equals(NodejsConstants.JavaScriptExtension, StringComparison.OrdinalIgnoreCase) ||
365-
ext.Equals(NodejsConstants.TypeScriptExtension, StringComparison.OrdinalIgnoreCase);
370+
return StringComparer.OrdinalIgnoreCase.Equals(ext, NodejsConstants.JavaScriptExtension) ||
371+
StringComparer.OrdinalIgnoreCase.Equals(ext, NodejsConstants.JavaScriptJsxExtension) ||
372+
TypeScriptHelpers.IsTypeScriptFile(fileName);
366373
}
367374

368375
protected override void Reload()

Nodejs/Product/TestAdapter/RunFromContextFileExtensions.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ internal class RunFromContextFileExtensions : IRunFromContextFileExtensions
1111
{
1212
#region IRunFromContextFileExtensions Members
1313

14-
public IEnumerable<string> FileTypes
15-
{
16-
get
17-
{
18-
return new[] { NodejsConstants.JavaScriptExtension };
19-
}
20-
}
14+
private static readonly string[] fileTypes = new[] { NodejsConstants.JavaScriptExtension };
15+
16+
public IEnumerable<string> FileTypes => fileTypes;
2117

2218
#endregion
2319
}

0 commit comments

Comments
 (0)