Skip to content

Commit

Permalink
Merge pull request #4702 from AlexanderSher/master
Browse files Browse the repository at this point in the history
Remove most of the internal dependencies on the Analysis and Analyzer
  • Loading branch information
AlexanderSher authored Sep 6, 2018
2 parents c895312 + 1b3c3b6 commit e3daf08
Show file tree
Hide file tree
Showing 81 changed files with 1,154 additions and 1,667 deletions.
13 changes: 0 additions & 13 deletions Python/Product/Analysis/Analysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,10 @@
<Compile Include="Infrastructure\TaskCompletionSourceExtensions.cs" />
<Compile Include="Infrastructure\TaskExtensions.cs" />
<Compile Include="Infrastructure\TestEnvironment.cs" />
<Compile Include="Infrastructure\UriEqualityComparer.cs" />
<Compile Include="Infrastructure\UriExtensions.cs" />
<Compile Include="Intellisense\AnalysisPriority.cs" />
<Compile Include="Intellisense\AnalysisQueue.cs" />
<Compile Include="Intellisense\AssignmentWalker.cs" />
<Compile Include="DocumentChange.cs" />
<Compile Include="Intellisense\ClassifierWalker.cs" />
<Compile Include="Intellisense\DetectSideEffectsWalker.cs" />
<Compile Include="Intellisense\EnclosingNodeWalker.cs" />
<Compile Include="Intellisense\ExtractedMethodCreator.cs" />
Expand All @@ -99,11 +96,8 @@
<Compile Include="Intellisense\LineInfo.cs" />
<Compile Include="Intellisense\LinePreservingCodeReplacer.cs" />
<Compile Include="Intellisense\LongestCommonSequence.cs" />
<Compile Include="Intellisense\OutliningWalker.cs" />
<Compile Include="Intellisense\ProjectEntryExtensions.cs" />
<Compile Include="Intellisense\ProximityExpressionWalker.cs" />
<Compile Include="Intellisense\SelectionTarget.cs" />
<Compile Include="Intellisense\TaggedSpan.cs" />
<Compile Include="Intellisense\VersionCookie.cs" />
<Compile Include="Interpreter\AnalysisOnlyInterpreterFactory.cs" />
<Compile Include="Interpreter\Ast\AstCachedPythonModule.cs" />
Expand Down Expand Up @@ -210,13 +204,8 @@
<Compile Include="LockedEnumerable.cs" />
<Compile Include="ModulePath.cs" />
<Compile Include="Parsing\Ast\AwaitExpression.cs" />
<Compile Include="Parsing\CodeFormattingCategoryAttribute.cs" />
<Compile Include="Parsing\CodeFormattingDefaultSettingAttribute.cs" />
<Compile Include="Parsing\CodeFormattingDescriptionAttribute.cs" />
<Compile Include="Parsing\CodeFormattingExampleAttribute.cs" />
<Compile Include="Parsing\CodeFormattingOptions.cs" />
<Compile Include="IdDispenser.cs" />
<Compile Include="Interpreter\ProjectAssemblyReference.cs" />
<Compile Include="Interpreter\CannotAnalyzeExtensionException.cs" />
<Compile Include="Interpreter\ProjectReference.cs" />
<Compile Include="Interpreter\ProjectReferenceKind.cs" />
Expand All @@ -230,15 +219,13 @@
<Compile Include="Projects\PythonProject.cs" />
<Compile Include="PythonAnalyzer.Specializations.cs" />
<Compile Include="PythonKeywords.cs" />
<Compile Include="QualifiedFunctionNameWalker.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ReadOnlyWrapper.cs" />
<Compile Include="ExportedMemberInfo.cs" />
<Compile Include="EmptyBuiltinModule.cs" />
<Compile Include="GetMemberOptions.cs" />
<Compile Include="ILocationResolver.cs" />
<Compile Include="Interpreter\ILocatedMember.cs" />
Expand Down
124 changes: 0 additions & 124 deletions Python/Product/Analysis/AnalysisLimits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,89 +51,8 @@ public static AnalysisLimits GetStandardLibraryLimits() {
return limits;
}

// We use string literals here rather than nameof() to ensure back-compat
// (though we need to preserve the names of the properties as well for
// the same reason, so just don't change anything :) )
private const string CrossModuleId = "CrossModule";
private const string CallDepthId = "CallDepth";
private const string DecreaseCallDepthId = "DecreaseCallDepth";
private const string NormalArgumentTypesId = "NormalArgumentTypes";
private const string ListArgumentTypesId = "ListArgumentTypes";
private const string DictArgumentTypesId = "DictArgumentTypes";
private const string ReturnTypesId = "ReturnTypes";
private const string YieldTypesId = "YieldTypes";
private const string InstanceMembersId = "InstanceMembers";
private const string DictKeyTypesId = "DictKeyTypes";
private const string DictValueTypesId = "DictValueTypes";
private const string IndexTypesId = "IndexTypes";
private const string AssignedTypesId = "AssignedTypes";
private const string UnifyCallsToNewId = "UnifyCallsToNew";
private const string ProcessCustomDecoratorsId = "ProcessCustomDecorators";
private const string UseTypeStubPackagesId = "UseTypeStubPackages";
private const string UseTypeStubPackagesExclusivelyId = "UseTypeStubPackagesExclusively";

#if DESKTOP
/// <summary>
/// Loads a new instance from the specified registry key.
/// </summary>
/// <param name="key">
/// The key to load settings from. Each setting is a DWORD value. If
/// null, all settings are assumed to be unspecified and the default
/// values are used.
/// </param>
/// <param name="defaultToStdLib">
/// If True, unspecified settings are taken from the defaults for
/// standard library analysis. Otherwise, they are taken from the
/// usual defaults.
/// </param>
internal static AnalysisLimits LoadFromStorage(RegistryKey key, bool defaultToStdLib = false) {
var limits = defaultToStdLib ? GetStandardLibraryLimits() : new AnalysisLimits();

if (key != null) {
limits.CrossModule = (key.GetValue(CrossModuleId) as int?) ?? limits.CrossModule;
limits.CallDepth = (key.GetValue(CallDepthId) as int?) ?? limits.CallDepth;
limits.DecreaseCallDepth = (key.GetValue(DecreaseCallDepthId) as int?) ?? limits.DecreaseCallDepth;
limits.NormalArgumentTypes = (key.GetValue(NormalArgumentTypesId) as int?) ?? limits.NormalArgumentTypes;
limits.ListArgumentTypes = (key.GetValue(ListArgumentTypesId) as int?) ?? limits.ListArgumentTypes;
limits.DictArgumentTypes = (key.GetValue(DictArgumentTypesId) as int?) ?? limits.DictArgumentTypes;
limits.ReturnTypes = (key.GetValue(ReturnTypesId) as int?) ?? limits.ReturnTypes;
limits.YieldTypes = (key.GetValue(YieldTypesId) as int?) ?? limits.YieldTypes;
limits.InstanceMembers = (key.GetValue(InstanceMembersId) as int?) ?? limits.InstanceMembers;
limits.DictKeyTypes = (key.GetValue(DictKeyTypesId) as int?) ?? limits.DictKeyTypes;
limits.DictValueTypes = (key.GetValue(DictValueTypesId) as int?) ?? limits.DictValueTypes;
limits.IndexTypes = (key.GetValue(IndexTypesId) as int?) ?? limits.IndexTypes;
limits.AssignedTypes = (key.GetValue(AssignedTypesId) as int?) ?? limits.AssignedTypes;
limits.UnifyCallsToNew = ((key.GetValue(UnifyCallsToNewId) as int?) ?? (limits.UnifyCallsToNew ? 1 : 0)) != 0;
limits.ProcessCustomDecorators = ((key.GetValue(ProcessCustomDecoratorsId) as int?) ?? (limits.ProcessCustomDecorators ? 1 : 0)) != 0;
limits.UseTypeStubPackages = ((key.GetValue(UseTypeStubPackagesId) as int?) ?? (limits.UseTypeStubPackages ? 1 : 0)) != 0;
limits.UseTypeStubPackagesExclusively = ((key.GetValue(UseTypeStubPackagesExclusivelyId) as int?) ?? (limits.UseTypeStubPackagesExclusively ? 1 : 0)) != 0;
}

return limits;
}

/// <summary>
/// Saves the current instance's settings to the specified registry key.
/// </summary>
internal void SaveToStorage(RegistryKey key) {
key.SetValue(CrossModuleId, CrossModule, RegistryValueKind.DWord);
key.SetValue(CallDepthId, CallDepth, RegistryValueKind.DWord);
key.SetValue(DecreaseCallDepthId, DecreaseCallDepth, RegistryValueKind.DWord);
key.SetValue(NormalArgumentTypesId, NormalArgumentTypes, RegistryValueKind.DWord);
key.SetValue(ListArgumentTypesId, ListArgumentTypes, RegistryValueKind.DWord);
key.SetValue(DictArgumentTypesId, DictArgumentTypes, RegistryValueKind.DWord);
key.SetValue(ReturnTypesId, ReturnTypes, RegistryValueKind.DWord);
key.SetValue(YieldTypesId, YieldTypes, RegistryValueKind.DWord);
key.SetValue(InstanceMembersId, InstanceMembers, RegistryValueKind.DWord);
key.SetValue(DictKeyTypesId, DictKeyTypes, RegistryValueKind.DWord);
key.SetValue(DictValueTypesId, DictValueTypes, RegistryValueKind.DWord);
key.SetValue(IndexTypesId, IndexTypes, RegistryValueKind.DWord);
key.SetValue(AssignedTypesId, AssignedTypes, RegistryValueKind.DWord);
key.SetValue(UnifyCallsToNewId, UnifyCallsToNew ? 1 : 0, RegistryValueKind.DWord);
key.SetValue(ProcessCustomDecoratorsId, ProcessCustomDecorators ? 1 : 0, RegistryValueKind.DWord);
key.SetValue(UseTypeStubPackagesId, UseTypeStubPackages ? 1 : 0, RegistryValueKind.DWord);
key.SetValue(UseTypeStubPackagesExclusivelyId, UseTypeStubPackagesExclusively ? 1 : 0, RegistryValueKind.DWord);
}
#endif

/// <summary>
Expand Down Expand Up @@ -162,49 +81,6 @@ public AnalysisLimits() {
UseTypeStubPackagesExclusively = false;
}

internal AnalysisLimits(Dictionary<string, int> limits) : this() {
int i;
if (limits.TryGetValue(CrossModuleId, out i)) CrossModule = i;
if (limits.TryGetValue(CallDepthId, out i)) CallDepth = i;
if (limits.TryGetValue(DecreaseCallDepthId, out i)) DecreaseCallDepth = i;
if (limits.TryGetValue(NormalArgumentTypesId, out i)) NormalArgumentTypes = i;
if (limits.TryGetValue(ListArgumentTypesId, out i)) ListArgumentTypes = i;
if (limits.TryGetValue(DictArgumentTypesId, out i)) DictArgumentTypes = i;
if (limits.TryGetValue(ReturnTypesId, out i)) ReturnTypes = i;
if (limits.TryGetValue(YieldTypesId, out i)) YieldTypes = i;
if (limits.TryGetValue(InstanceMembersId, out i)) InstanceMembers = i;
if (limits.TryGetValue(DictKeyTypesId, out i)) DictKeyTypes = i;
if (limits.TryGetValue(DictValueTypesId, out i)) DictValueTypes = i;
if (limits.TryGetValue(IndexTypesId, out i)) IndexTypes = i;
if (limits.TryGetValue(AssignedTypesId, out i)) AssignedTypes = i;
if (limits.TryGetValue(UnifyCallsToNewId, out i)) UnifyCallsToNew = i != 0;
if (limits.TryGetValue(ProcessCustomDecoratorsId, out i)) ProcessCustomDecorators = i != 0;
if (limits.TryGetValue(UseTypeStubPackagesId, out i)) UseTypeStubPackages = i != 0;
if (limits.TryGetValue(UseTypeStubPackagesExclusivelyId, out i)) UseTypeStubPackagesExclusively = i != 0;
}

internal Dictionary<string, int> ToDictionary() {
return new Dictionary<string, int> {
{ CrossModuleId, CrossModule },
{ CallDepthId, CallDepth },
{ DecreaseCallDepthId, DecreaseCallDepth },
{ NormalArgumentTypesId, NormalArgumentTypes },
{ ListArgumentTypesId, ListArgumentTypes },
{ DictArgumentTypesId, DictArgumentTypes },
{ ReturnTypesId, ReturnTypes },
{ YieldTypesId, YieldTypes },
{ InstanceMembersId, InstanceMembers },
{ DictKeyTypesId, DictKeyTypes },
{ DictValueTypesId, DictValueTypes },
{ IndexTypesId, IndexTypes },
{ AssignedTypesId, AssignedTypes },
{ UnifyCallsToNewId, UnifyCallsToNew ? 1 : 0 },
{ ProcessCustomDecoratorsId, ProcessCustomDecorators ? 1 : 0 },
{ UseTypeStubPackagesId, UseTypeStubPackages ? 1 : 0 },
{ UseTypeStubPackagesExclusivelyId, UseTypeStubPackagesExclusively ? 1 : 0 }
};
}

/// <summary>
/// The maximum number of files which will be used for cross module
/// analysis.
Expand Down
2 changes: 1 addition & 1 deletion Python/Product/Analysis/AnalysisLogWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using Microsoft.PythonTools.Analysis.Infrastructure;

namespace Microsoft.PythonTools.Analysis {
class AnalysisLogWriter : IDisposable {
public class AnalysisLogWriter : IDisposable {
private readonly DateTime _startTime;
private readonly string _outputFile;
private List<LogItem> _items;
Expand Down
Loading

0 comments on commit e3daf08

Please sign in to comment.