Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Do not normalize line endings from CR LF to LF, regardless of core.autocrlf.
* -text
* -text

# Normalize C# source files to use CR LF line endings.
*.cs text eol=crlf
48 changes: 24 additions & 24 deletions Nodejs/Common/Telemetry/TelemetryEvents.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//
namespace Microsoft.NodejsTools.Telemetry {
/// <summary>
/// Telemetry event names
/// </summary>
internal static class TelemetryEvents {
public const string ProjectImported = "ProjectImported";
}
}
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//

namespace Microsoft.NodejsTools.Telemetry {
/// <summary>
/// Telemetry event names
/// </summary>
internal static class TelemetryEvents {
public const string ProjectImported = "ProjectImported";
}
}
48 changes: 24 additions & 24 deletions Nodejs/Common/Telemetry/TelemetryProperties.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//
namespace Microsoft.NodejsTools.Telemetry {
/// <summary>
/// Property names for telemetry events
/// </summary>
internal static class TelemetryProperties {
public const string ProjectGuid = "ProjectGuid";
}
}
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//

namespace Microsoft.NodejsTools.Telemetry {
/// <summary>
/// Property names for telemetry events
/// </summary>
internal static class TelemetryProperties {
public const string ProjectGuid = "ProjectGuid";
}
}
4 changes: 3 additions & 1 deletion Nodejs/NodejsTools.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">250</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/IndentSubtags/@EntryValue">ZeroIndent</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/XmlDocFormatter/IndentTagContent/@EntryValue">ZeroIndent</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
6 changes: 3 additions & 3 deletions Nodejs/Product/Analysis/Analysis/AnalysisLimits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public static AnalysisLimits MakeLowAnalysisLimits() {
/// <summary>
/// Gets the maximum number of types which can be merged at once.
/// </summary>
public int MaxMergeTypes { get; set; }
public int MaxMergeTypes { get; set; }

/// <summary>
/// Gets the maximum number of events which can be emitted at once.
/// </summary>
Expand All @@ -165,7 +165,7 @@ public static AnalysisLimits MakeLowAnalysisLimits() {
/// </summary>
/// <param name="nestedModulesDepth">Depth of module file which has to be checked for depth limit.</param>
/// <returns>True if path too deep in nesting tree; false overwise.</returns>
public bool IsPathExceedNestingLimit(int nestedModulesDepth) {
public bool IsPathExceedNestingLimit(int nestedModulesDepth) {
return nestedModulesDepth > NestedModulesLimit;
}

Expand Down
2 changes: 1 addition & 1 deletion Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ internal void Analyze(DDG ddg, CancellationToken cancel) {
long endTime = _sw.ElapsedMilliseconds;
var thisTime = endTime - startTime;
_analysisTime += thisTime;
if (thisTime >= 500 || (_analysisTime / _analysisCount) > 500) {
if (thisTime >= 500 || (_analysisTime / _analysisCount) > 500) {
Trace.TraceWarning("Analyzed: {0} {1} ({2} count, {3}ms total, {4}ms mean)", this, thisTime, _analysisCount, _analysisTime, (double)_analysisTime / _analysisCount);
}
}
Expand Down
88 changes: 44 additions & 44 deletions Nodejs/Product/Analysis/Analysis/Analyzer/RequireAnalysisUnit.cs
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//
using System.Diagnostics;
using System.Threading;
namespace Microsoft.NodejsTools.Analysis.Analyzer {
class RequireAnalysisUnit : AnalysisUnit {
private string _dependency;
private ModuleTree _tree;
private ModuleTable _table;
internal RequireAnalysisUnit(ModuleTree tree, ModuleTable table, ProjectEntry entry, string dependency) : base (entry.Tree, entry.EnvironmentRecord) {
_tree = tree;
_table = table;
_dependency = dependency;
}
internal override void AnalyzeWorker(DDG ddg, CancellationToken cancel) {
ModuleTree module = _table.RequireModule(this, _dependency, _tree);
if (module == null) {
return;
}
AddChildVisibilitiesExcludingNodeModules(module);
}
private void AddChildVisibilitiesExcludingNodeModules(ModuleTree moduleTree) {
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//

using System.Diagnostics;
using System.Threading;

namespace Microsoft.NodejsTools.Analysis.Analyzer {
class RequireAnalysisUnit : AnalysisUnit {
private string _dependency;
private ModuleTree _tree;
private ModuleTable _table;

internal RequireAnalysisUnit(ModuleTree tree, ModuleTable table, ProjectEntry entry, string dependency) : base (entry.Tree, entry.EnvironmentRecord) {
_tree = tree;
_table = table;
_dependency = dependency;
}

internal override void AnalyzeWorker(DDG ddg, CancellationToken cancel) {
ModuleTree module = _table.RequireModule(this, _dependency, _tree);
if (module == null) {
return;
}

AddChildVisibilitiesExcludingNodeModules(module);
}

private void AddChildVisibilitiesExcludingNodeModules(ModuleTree moduleTree) {
foreach (var childTree in moduleTree.GetChildrenExcludingNodeModules()) {
Debug.Assert(childTree.Name != AnalysisConstants.NodeModulesFolder);
if (childTree.ProjectEntry == null) {
AddChildVisibilitiesExcludingNodeModules(childTree);
} else {
_table.AddVisibility(_tree, childTree.ProjectEntry);
}
}
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions Nodejs/Product/Analysis/Analysis/GlobalBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,9 +1342,9 @@ private static IAnalysisSet DefineProperties(FunctionValue func, Node node, Anal
}

private static IAnalysisSet Require(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) {
IAnalysisSet res = AnalysisSet.Empty;
if (node.GetType() != typeof(CallNode)) {
IAnalysisSet res = AnalysisSet.Empty;

if (node.GetType() != typeof(CallNode)) {
return res;
}

Expand Down
26 changes: 13 additions & 13 deletions Nodejs/Product/Analysis/Analysis/JsAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public IAnalyzable AddPackageJson(string filePath, string entryPoint, List<strin

var tree = Modules.GetModuleTree(Path.GetDirectoryName(filePath));

tree.DefaultPackage = entryPoint;
tree.DefaultPackage = entryPoint;

ProjectEntry projectEntry = null;
if (dependencies != null) {
projectEntry = new ProjectEntry(this, filePath, null);
Expand Down Expand Up @@ -175,17 +175,17 @@ public void Analyze(CancellationToken cancel) {
_tree.EnqueueDependents();
}

if (_dependencies != null) {
var requireAnalysisUnits = new List<RequireAnalysisUnit>();
requireAnalysisUnits.AddRange(_dependencies.Select(
dependency => {
return new RequireAnalysisUnit(_tree, _modules, _projectEntry, dependency);
}));
foreach (var unit in requireAnalysisUnits) {
unit.AnalyzeWorker(null, cancel);
}
}
if (_dependencies != null) {
var requireAnalysisUnits = new List<RequireAnalysisUnit>();
requireAnalysisUnits.AddRange(_dependencies.Select(
dependency => {
return new RequireAnalysisUnit(_tree, _modules, _projectEntry, dependency);
}));

foreach (var unit in requireAnalysisUnits) {
unit.AnalyzeWorker(null, cancel);
}
}
}
}

Expand Down
68 changes: 34 additions & 34 deletions Nodejs/Product/Analysis/Analysis/ModuleTreeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.NodejsTools.Analysis {
internal static class ModuleTreeExtensions {
internal static IEnumerable<ModuleTree> GetChildrenExcludingNodeModules(this ModuleTree moduleTree) {
if (moduleTree == null) {
return Enumerable.Empty<ModuleTree>();
}
// Children.Values returns an IEnumerable
// The process of resolving modules can lead us to add entries into the underlying array
// doing so results in exceptions b/c the array has changed under the enumerable
// To avoid this, we call .ToArray() to create a copy of the array locally which we then Enumerate
return moduleTree.Children.Values.ToArray().Where(mod => mod != null && !String.Equals(mod.Name, AnalysisConstants.NodeModulesFolder, StringComparison.OrdinalIgnoreCase));
}
}
}
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************//

using System;
using System.Collections.Generic;
using System.Linq;

namespace Microsoft.NodejsTools.Analysis {
internal static class ModuleTreeExtensions {
internal static IEnumerable<ModuleTree> GetChildrenExcludingNodeModules(this ModuleTree moduleTree) {
if (moduleTree == null) {
return Enumerable.Empty<ModuleTree>();
}
// Children.Values returns an IEnumerable
// The process of resolving modules can lead us to add entries into the underlying array
// doing so results in exceptions b/c the array has changed under the enumerable
// To avoid this, we call .ToArray() to create a copy of the array locally which we then Enumerate
return moduleTree.Children.Values.ToArray().Where(mod => mod != null && !String.Equals(mod.Name, AnalysisConstants.NodeModulesFolder, StringComparison.OrdinalIgnoreCase));
}
}
}
Loading