Skip to content

Commit f40011a

Browse files
committed
- Merge changes from
- Make EncodedLocation struct public to avoid boxing/unboxing through interfaces
1 parent 60e7c98 commit f40011a

File tree

20 files changed

+37
-532
lines changed

20 files changed

+37
-532
lines changed

src/Analysis/Engine/Impl/AnalysisLimits.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ public static AnalysisLimits GetStandardLibraryLimits() {
5151
return limits;
5252
}
5353

54-
#if DESKTOP
55-
56-
#endif
57-
5854
/// <summary>
5955
/// The key to use with ProjectEntry.Properties to override the call
6056
/// depth for functions in that module.

src/Analysis/Engine/Impl/AnalysisUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ internal ModuleInfo DeclaringModule {
104104

105105
public PythonAnalyzer State => DeclaringModule.ProjectEntry.ProjectState;
106106

107-
internal AnalysisUnit CopyForEval() {
107+
public AnalysisUnit CopyForEval() {
108108
return new AnalysisUnit(Ast, Tree, _scope, true);
109109
}
110110

src/Analysis/Engine/Impl/Analyzer/DependencyInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public IAnalysisSet Types {
144144
}
145145

146146
internal class ReferenceableDependencyInfo : TypedDependencyInfo {
147-
public SmallSetWithExpiry<IEncodedLocation> _references, _assignments;
147+
public SmallSetWithExpiry<EncodedLocation> _references, _assignments;
148148

149149
public ReferenceableDependencyInfo(int version)
150150
: base(version) { }
@@ -153,9 +153,9 @@ public ReferenceableDependencyInfo(int version, IAnalysisSet emptySet)
153153
: base(version, emptySet) {
154154
}
155155

156-
public bool AddReference(IEncodedLocation location) => _references.Add(location);
157-
public IEnumerable<IEncodedLocation> References => _references;
158-
public bool AddAssignment(IEncodedLocation location) => _assignments.Add(location);
159-
public IEnumerable<IEncodedLocation> Assignments => _assignments;
156+
public bool AddReference(EncodedLocation location) => _references.Add(location);
157+
public IEnumerable<EncodedLocation> References => _references;
158+
public bool AddAssignment(EncodedLocation location) => _assignments.Add(location);
159+
public IEnumerable<EncodedLocation> Assignments => _assignments;
160160
}
161161
}

src/Analysis/Engine/Impl/Definitions/ILocatedVariableDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ namespace Microsoft.PythonTools.Analysis {
1818
public interface ILocatedVariableDefinition: IVariableDefinition {
1919
int DeclaringVersion { get; set; }
2020
IPythonProjectEntry Entry { get; }
21-
IEncodedLocation Location { get; set; }
21+
EncodedLocation Location { get; set; }
2222
}
2323
}

src/Analysis/Engine/Impl/Definitions/IPythonAnalyzer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public interface IPythonAnalyzer: IGroupableAnalysisProject {
7070
/// </param>
7171
IEnumerable<IPythonProjectEntry> GetEntriesThatImportModule(string moduleName, bool includeUnresolved);
7272

73+
AnalysisValue GetAnalysisValueFromObjects(object attr);
74+
7375
/// <summary>
7476
/// Returns true if a module has been imported.
7577
/// </summary>

src/Analysis/Engine/Impl/Definitions/IReferenceable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public interface IReferenceableContainer {
2222
}
2323

2424
public interface IReferenceable {
25-
IEnumerable<IEncodedLocation> Definitions {
25+
IEnumerable<EncodedLocation> Definitions {
2626
get;
2727
}
28-
IEnumerable<IEncodedLocation> References {
28+
IEnumerable<EncodedLocation> References {
2929
get;
3030
}
3131
}

src/Analysis/Engine/Impl/Definitions/IVariableDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace Microsoft.PythonTools.Analysis {
2020
public interface IVariableDefinition: IReferenceable {
2121
bool VariableStillExists { get; }
2222
bool AddReference(Node node, AnalysisUnit unit);
23-
bool AddReference(IEncodedLocation location, IVersioned module);
24-
bool AddAssignment(IEncodedLocation location, IVersioned entry);
23+
bool AddReference(EncodedLocation location, IVersioned module);
24+
bool AddAssignment(EncodedLocation location, IVersioned entry);
2525
bool AddAssignment(Node node, AnalysisUnit unit);
2626
bool IsAssigned { get; }
2727
bool HasTypes { get; }

src/Analysis/Engine/Impl/EncodedLocation.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Microsoft.PythonTools.Analysis {
3535
/// storing the line/column info directly while still allowing multiple schemes
3636
/// to be used.
3737
/// </summary>
38-
struct EncodedLocation : IEncodedLocation, IEquatable<EncodedLocation> {
38+
public struct EncodedLocation : IEquatable<EncodedLocation>, ICanExpire {
3939
public EncodedLocation(ILocationResolver resolver, object location) {
4040
if (resolver == null && !(location is LocationInfo)) {
4141
throw new ArgumentNullException(nameof(resolver));
@@ -60,10 +60,7 @@ public override int GetHashCode() {
6060
}
6161

6262
public override bool Equals(object obj) {
63-
if (obj is EncodedLocation) {
64-
return Equals((EncodedLocation)obj);
65-
}
66-
return false;
63+
return obj is EncodedLocation location && Equals(location);
6764
}
6865

6966
#region IEquatable<EncodedLocation> Members
@@ -74,13 +71,6 @@ public bool Equals(EncodedLocation other) {
7471

7572
#endregion
7673

77-
#region IEquatable<IEncodedLocation> Members
78-
79-
public bool Equals(IEncodedLocation other) {
80-
return Location == other.Location;
81-
}
82-
83-
#endregion
8474
public ILocationInfo GetLocationInfo() {
8575
if (Resolver == null) {
8676
return Location as ILocationInfo;

src/Analysis/Engine/Impl/Infrastructure/Extensions/UriExtensions.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using System;
1818
using System.Net;
19+
using System.Runtime.InteropServices;
1920

2021
namespace Microsoft.PythonTools.Analysis.Infrastructure {
2122
internal static class UriExtensions {
@@ -34,13 +35,7 @@ public static string ToAbsolutePath(this Uri uri) {
3435
return uri.LocalPath;
3536
}
3637

37-
private static bool IsWindows() {
38-
#if DESKTOP
39-
return true;
40-
#else
41-
return System.Runtime.InteropServices.RuntimeInformation
42-
.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows);
43-
#endif
44-
}
38+
private static bool IsWindows()
39+
=> RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
4540
}
4641
}

src/Analysis/Engine/Impl/Intellisense/FileExtensionAttribute.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)