Skip to content

Commit 8e1699d

Browse files
committed
run TypeScript analyzer with node
1 parent 9a85d3b commit 8e1699d

18 files changed

+55688
-38191
lines changed

Diff for: SourceBrowser.sln

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceIndexServer.Tests", "
1313
EndProject
1414
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildLogParser", "src\BuildLogParser\BuildLogParser.csproj", "{57002F26-8D15-4CF7-A53D-61AE8CC5E836}"
1515
EndProject
16-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypeScriptAnalyzer", "src\TypeScriptAnalyzer\TypeScriptAnalyzer.csproj", "{85E7C8FC-1CAB-41EB-8631-6CD4260A4EC9}"
17-
EndProject
1816
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "src\Common\Common.csproj", "{F13CD277-E86B-4BC6-9E93-39ED055A46DB}"
1917
EndProject
2018
Global

Diff for: src/HtmlGenerator.Tests/HtmlGenerator.Tests.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@
8989
<Project>{1ae38cc6-18c6-4ab7-8fe3-feeb33329952}</Project>
9090
<Name>SourceIndexServer</Name>
9191
</ProjectReference>
92-
<ProjectReference Include="..\TypeScriptAnalyzer\TypeScriptAnalyzer.csproj">
93-
<Project>{85E7C8FC-1CAB-41EB-8631-6CD4260A4EC9}</Project>
94-
<Name>TypeScriptAnalyzer</Name>
95-
</ProjectReference>
9692
</ItemGroup>
9793
<ItemGroup>
9894
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

Diff for: src/HtmlGenerator/HtmlGenerator.csproj

+14-4
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@
156156
<Compile Include="Pass1-Generation\ProjectGenerator.References.Pass1.cs" />
157157
<Compile Include="Pass1-Generation\SolutionGenerator.cs" />
158158
<Compile Include="Pass1-Generation\SolutionGenerator.SolutionExplorer.cs" />
159+
<Compile Include="Pass1-Generation\TypeScriptSupport.AnalysisError.cs" />
160+
<Compile Include="Pass1-Generation\TypeScriptSupport.AnalyzedFile.cs" />
161+
<Compile Include="Pass1-Generation\TypeScriptSupport.ClassifiedRange.cs" />
159162
<Compile Include="Pass1-Generation\TypeScriptSupport.cs" />
163+
<Compile Include="Pass1-Generation\TypeScriptSupport.Hyperlink.cs" />
160164
<Compile Include="Pass1-Generation\XamlSupport.cs" />
161165
<Compile Include="Pass1-Generation\XmlSupport.cs" />
162166
<Compile Include="Pass2-Finalization\NamespaceExplorer.cs" />
@@ -197,10 +201,6 @@
197201
<Project>{1ae38cc6-18c6-4ab7-8fe3-feeb33329952}</Project>
198202
<Name>SourceIndexServer</Name>
199203
</ProjectReference>
200-
<ProjectReference Include="..\TypeScriptAnalyzer\TypeScriptAnalyzer.csproj">
201-
<Project>{85e7c8fc-1cab-41eb-8631-6cd4260a4ec9}</Project>
202-
<Name>TypeScriptAnalyzer</Name>
203-
</ProjectReference>
204204
</ItemGroup>
205205
<ItemGroup>
206206
<None Include="..\SourceIndexServer\content\icons\0.png">
@@ -1243,5 +1243,15 @@
12431243
<SubType>Designer</SubType>
12441244
</None>
12451245
</ItemGroup>
1246+
<ItemGroup>
1247+
<Content Include="TypeScriptSupport\analyzer.js">
1248+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1249+
</Content>
1250+
</ItemGroup>
1251+
<ItemGroup>
1252+
<Content Include="TypeScriptSupport\lib.d.ts">
1253+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1254+
</Content>
1255+
</ItemGroup>
12461256
<Import Project="..\..\Common.targets" />
12471257
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Microsoft.SourceBrowser.HtmlGenerator
2+
{
3+
public class AnalysisError
4+
{
5+
public string message { get; set; }
6+
public string stack { get; set; }
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Microsoft.SourceBrowser.HtmlGenerator
2+
{
3+
public class AnalyzedFile
4+
{
5+
public string fileName { get; set; }
6+
public ClassifiedRange[] syntacticClassifications { get; set; }
7+
public ClassifiedRange[] semanticClassifications { get; set; }
8+
public string fileSymbolId { get; set; }
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace Microsoft.SourceBrowser.HtmlGenerator
2+
{
3+
public class ClassifiedRange
4+
{
5+
// deserialization
6+
public ClassifiedRange()
7+
{
8+
}
9+
10+
public ClassifiedRange(string text, int start, int length, ClassifiedRange enclosingRange = null)
11+
{
12+
this.text = text.Substring(start, length);
13+
14+
this.start = start;
15+
this.length = length;
16+
17+
if (enclosingRange != null)
18+
{
19+
classification = enclosingRange.classification;
20+
hyperlinks = enclosingRange.hyperlinks;
21+
definitionSymbolId = enclosingRange.definitionSymbolId;
22+
definitionKind = enclosingRange.definitionKind;
23+
searchString = enclosingRange.searchString;
24+
fullName = enclosingRange.fullName;
25+
}
26+
}
27+
28+
public string classification { get; set; }
29+
public int start { get; set; }
30+
public int length { get; set; }
31+
public int end { get { return start + length; } }
32+
public Hyperlink[] hyperlinks { get; set; }
33+
public string definitionSymbolId { get; set; }
34+
public string definitionKind { get; set; }
35+
public string searchString { get; set; }
36+
public string fullName { get; set; }
37+
38+
public bool IsSemantic { get; set; }
39+
40+
public string text { get; set; }
41+
public int lineNumber { get; set; }
42+
public int column { get; set; }
43+
public string lineText { get; set; }
44+
45+
public bool IsSymbolLocalOnly()
46+
{
47+
return
48+
definitionKind == "variable" ||
49+
definitionKind == "parameter";
50+
}
51+
52+
public override string ToString()
53+
{
54+
return string.Format("{0} ({1};{2}) {3}", text, start, length, classification);
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Microsoft.SourceBrowser.HtmlGenerator
2+
{
3+
public class Hyperlink
4+
{
5+
public string sourceFile { get; set; }
6+
public int start { get; set; }
7+
public string symbolId { get; set; }
8+
}
9+
}

Diff for: src/HtmlGenerator/Pass1-Generation/TypeScriptSupport.cs

+20-15
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,34 @@ public void Generate(IEnumerable<string> typeScriptFiles)
2323
return;
2424
}
2525

26-
var libdts = Path.Combine(Common.Paths.BaseAppFolder, "TypeScript", "lib.d.ts");
27-
2826
declarations = new List<string>();
2927
references = new Dictionary<string, List<Reference>>(StringComparer.OrdinalIgnoreCase);
3028
SymbolIDToListOfLocationsMap = new Dictionary<string, List<Tuple<string, long>>>();
3129

3230
var list = new List<string>();
31+
string libFile = null;
3332

34-
if (!typeScriptFiles.Any(f => string.Equals(Path.GetFileName(f), "lib.d.ts", StringComparison.OrdinalIgnoreCase)))
35-
{
36-
list.Add(libdts);
37-
}
38-
39-
foreach (var file in typeScriptFiles)
33+
foreach(var file in typeScriptFiles)
4034
{
4135
if (!alreadyProcessed.Contains(file))
4236
{
43-
list.Add(file);
37+
if (libFile == null && string.Equals(Path.GetFileName(file), "lib.d.ts", StringComparison.OrdinalIgnoreCase))
38+
{
39+
libFile = file;
40+
}
41+
else
42+
{
43+
list.Add(file);
44+
}
4445
}
4546
}
4647

47-
GenerateCore(list);
48+
if (libFile == null)
49+
{
50+
libFile = Path.Combine(Common.Paths.BaseAppFolder, "TypeScriptSupport", "lib.d.ts");
51+
}
52+
53+
GenerateCore(list, libFile);
4854

4955
ProjectGenerator.GenerateReferencesDataFilesToAssembly(
5056
Paths.SolutionDestinationFolder,
@@ -62,21 +68,20 @@ public void Generate(IEnumerable<string> typeScriptFiles)
6268
SymbolIDToListOfLocationsMap);
6369
}
6470

65-
private void GenerateCore(IEnumerable<string> typeScriptFiles)
71+
private void GenerateCore(IEnumerable<string> fileNames, string libFile)
6672
{
6773
var output = Path.Combine(Common.Paths.BaseAppFolder, "output");
6874
if (Directory.Exists(output))
6975
{
7076
Directory.Delete(output, recursive: true);
7177
}
7278

73-
var json = JsonConvert.SerializeObject(typeScriptFiles);
79+
var json = JsonConvert.SerializeObject(new { fileNames, libFile });
7480
var argumentsJson = Path.Combine(Common.Paths.BaseAppFolder, "TypeScriptAnalyzerArguments.json");
7581
File.WriteAllText(argumentsJson, json);
7682

77-
var analyzerJs = Path.Combine(Common.Paths.BaseAppFolder, @"TypeScript\analyzer.js");
78-
79-
var result = new ProcessLaunchService().RunAndRedirectOutput("Microsoft.SourceBrowser.TypeScriptAnalyzer.exe", argumentsJson);
83+
var analyzerJs = Path.Combine(Common.Paths.BaseAppFolder, @"TypeScriptSupport\analyzer.js");
84+
var result = new ProcessLaunchService().RunAndRedirectOutput("node", string.Format("\"{0}\" {1}", analyzerJs, argumentsJson));
8085

8186
foreach (var file in Directory.GetFiles(output))
8287
{

0 commit comments

Comments
 (0)