Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #138 Add medium level of IntelliSense / limit to the analysis depth (Related to #88). #146

Merged
merged 7 commits into from
Jun 26, 2015
Merged
Show file tree
Hide file tree
Changes from 4 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
25 changes: 22 additions & 3 deletions Nodejs/Product/Analysis/Analysis/AnalysisLimits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ public AnalysisLimits() {
MaxObjectLiteralProperties = 50;
MaxObjectKeysTypes = 5;
MaxMergeTypes = 5;
NestedModulesLimit = AnalysisConstants.MaxAnalysisDepthQualty;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of readability and consistency, let's not add this to AnalysisConstants, and instead just include the number. The comment about reasoning is very helpful, though, and should be included where the NestedModulesLimit property is defined.

}

/// <summary>
/// Creates instance of the <see cref="AnalysisLimits"/> for medium level of Intellisense support.
/// </summary>
/// <returns>An <see cref="AnalysisLimits"/> object representing medium level Initellisense settings.</returns>
public static AnalysisLimits MakeMediumAnalysisLimits() {
return new AnalysisLimits() {
NestedModulesLimit = AnalysisConstants.MaxAnalysisDepthFast
};
}

public static AnalysisLimits MakeLowAnalysisLimits() {
Expand All @@ -43,7 +54,8 @@ public static AnalysisLimits MakeLowAnalysisLimits() {
DictKeyTypes = 1,
DictValueTypes = 1,
IndexTypes = 1,
InstanceMembers = 1
InstanceMembers = 1,
NestedModulesLimit = 1
};
}

Expand Down Expand Up @@ -111,6 +123,11 @@ public static AnalysisLimits MakeLowAnalysisLimits() {
/// </summary>
public int MaxMergeTypes { get; set; }

/// <summary>
/// Gets the maximum levl of dependency modules which could be analyzed.
/// </summary>
public int NestedModulesLimit { get; set; }

public override bool Equals(object obj) {
AnalysisLimits other = obj as AnalysisLimits;
if (other != null) {
Expand All @@ -125,7 +142,8 @@ public override bool Equals(object obj) {
other.MaxArrayLiterals == MaxArrayLiterals &&
other.MaxObjectLiteralProperties == MaxObjectLiteralProperties &&
other.MaxObjectKeysTypes == MaxObjectKeysTypes &&
other.MaxMergeTypes == MaxMergeTypes;
other.MaxMergeTypes == MaxMergeTypes &&
other.NestedModulesLimit == NestedModulesLimit;
}
return false;
}
Expand All @@ -142,7 +160,8 @@ public override int GetHashCode() {
MaxArrayLiterals +
MaxObjectLiteralProperties +
MaxObjectKeysTypes +
MaxMergeTypes;
MaxMergeTypes +
NestedModulesLimit;
}
}
}
35 changes: 35 additions & 0 deletions Nodejs/Product/Analysis/AnalysisConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,40 @@
namespace Microsoft.NodejsTools {
internal sealed class AnalysisConstants {
internal const string NodeModulesFolder = "node_modules";

/// <summary>
/// Maximum practical limit for the dependencies analysis.
/// </summary>
/// <remarks>
/// There no practical reasons to go deeper in dependencies analysis.
/// Number 4 is very practical. Here the examples which hightlight idea.
///
/// Example 1
///
/// Level 0 - Large system. Some code should use properties of the object on level 4 here.
/// Level 1 - Subsystem - pass data from level 4
/// Level 2 - Internal dependency for company - Do some work and pass data to level 1
/// Level 3 - Framework on top of which created Internal dependency.
/// Level 4 - Dependency of the framework. Objects from here still should be available.
/// Level 5 - Dependency of the framework provide some usefull primitive which would be used very often on the level of whole system. Hmmm.
///
/// Example 2 (reason why I could increase to 5)
///
/// Level 0 - Large system. Some code should use properties of the object on level 4 here.
/// Level 1 - Subsystem - pass data from level 4
/// Level 2 - Internal dependency for company - Wrap access to internal library and perform business logic. Do some work and pass data to level 1
/// Level 3 - Internal library which wrap access to API.
/// Level 4 - Http library.
/// Level 5 - Promise Polyfill.
///
/// All these examples are highly speculative and I specifically try to create such deep level.
/// If you develop on windows with such deep level you already close to your limit, your maximum is probably 10.
/// </remarks>
internal const int MaxAnalysisDepthQualty = 4;

/// <summary>
/// Maximum practical limit for the dependencies analysis oriented on producing faster results.
/// </summary>
internal const int MaxAnalysisDepthFast = 2;
}
}
5 changes: 5 additions & 0 deletions Nodejs/Product/Nodejs/Intellisense/VsProjectAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,9 @@ private AnalysisLimits LoadLimits() {

if (NodejsPackage.Instance != null) {
switch (_analysisLevel) {
case Options.AnalysisLevel.Medium:
defaults = AnalysisLimits.MakeMediumAnalysisLimits();
break;
case Options.AnalysisLevel.Low:
defaults = _lowLimits;
break;
Expand Down Expand Up @@ -1500,6 +1503,7 @@ private static AnalysisLimits LoadLimitsFromStorage(RegistryKey key, AnalysisLim
limits.DictValueTypes = GetSetting(key, DictValueTypesId) ?? defaults.DictValueTypes;
limits.IndexTypes = GetSetting(key, IndexTypesId) ?? defaults.IndexTypes;
limits.AssignedTypes = GetSetting(key, AssignedTypesId) ?? defaults.AssignedTypes;
limits.NestedModulesLimit = GetSetting(key, NestedModulesLimitId) ?? defaults.NestedModulesLimit;

return limits;
}
Expand All @@ -1518,6 +1522,7 @@ private static AnalysisLimits LoadLimitsFromStorage(RegistryKey key, AnalysisLim
private const string DictValueTypesId = "DictValueTypes";
private const string IndexTypesId = "IndexTypes";
private const string AssignedTypesId = "AssignedTypes";
private const string NestedModulesLimitId = "NestedModulesLimit";

#endregion
}
Expand Down
1 change: 1 addition & 0 deletions Nodejs/Product/Nodejs/Options/AnalysisLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Microsoft.NodejsTools.Options {
enum AnalysisLevel {
None,
Low,
Medium,
High
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ internal AnalysisLevel AnalysisLevel {
get {
if (_fullIntelliSenseRadioButton.Checked) {
return AnalysisLevel.High;
} else if (_mediumIntelliSenseRadioButton.Checked) {
return AnalysisLevel.Medium;
} else {
return AnalysisLevel.None;
}
Expand All @@ -51,6 +53,9 @@ internal AnalysisLevel AnalysisLevel {
case AnalysisLevel.High:
_fullIntelliSenseRadioButton.Checked = true;
break;
case AnalysisLevel.Medium:
_mediumIntelliSenseRadioButton.Checked = true;
break;
case AnalysisLevel.None:
_noIntelliSenseRadioButton.Checked = true;
break;
Expand Down
Loading