-
Notifications
You must be signed in to change notification settings - Fork 133
Bug fixes #418
Bug fixes #418
Changes from 6 commits
719498d
213b842
beb6819
3e92388
81b5f04
1610e90
698043a
953b451
91532fd
992b5bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,17 +129,15 @@ public override PythonMemberType MemberType { | |
} | ||
|
||
|
||
internal override void AddReference(Node node, AnalysisUnit analysisUnit) { | ||
_references.GetReferences(analysisUnit.ProjectEntry as ProjectEntry)?.AddReference(new EncodedLocation(analysisUnit, node)); | ||
} | ||
internal override void AddReference(Node node, AnalysisUnit analysisUnit) | ||
=> _references.GetReferences(analysisUnit.ProjectEntry as ProjectEntry)?.AddReference(new EncodedLocation(analysisUnit, node)); | ||
|
||
public override IEnumerable<ILocationInfo> Locations { | ||
get { | ||
ReferenceList defns; | ||
if (!_references.TryGetValue(DeclaringModule, out defns)) { | ||
if (!_references.TryGetValue(DeclaringModule, out var defns)) { | ||
return Enumerable.Empty<ILocationInfo>(); | ||
} | ||
return defns.Definitions.Select(l => l.GetLocationInfo()).Where(l => l != null); | ||
return defns.Definitions.Select(l => l.GetLocationInfo()).ExcludeDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we have two almost identical methods: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
} | ||
} | ||
|
||
|
@@ -151,17 +149,14 @@ public override void AugmentAssign(AugmentedAssignStatement node, AnalysisUnit u | |
} | ||
} | ||
|
||
public override IAnalysisSet Await(Node node, AnalysisUnit unit) { | ||
return AnalysisSet.UnionAll(_protocols.Select(p => p.Await(node, unit))); | ||
} | ||
public override IAnalysisSet Await(Node node, AnalysisUnit unit) | ||
=> AnalysisSet.UnionAll(_protocols.Select(p => p.Await(node, unit))); | ||
|
||
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) { | ||
return AnalysisSet.UnionAll(_protocols.Select(p => p.BinaryOperation(node, unit, operation, rhs))); | ||
} | ||
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) | ||
=> AnalysisSet.UnionAll(_protocols.Select(p => p.BinaryOperation(node, unit, operation, rhs))); | ||
|
||
public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) { | ||
return AnalysisSet.UnionAll(_protocols.Select(p => p.Call(node, unit, args, keywordArgNames))); | ||
} | ||
public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) | ||
=> AnalysisSet.UnionAll(_protocols.Select(p => p.Call(node, unit, args, keywordArgNames))); | ||
|
||
public override void DeleteMember(Node node, AnalysisUnit unit, string name) { | ||
foreach (var p in _protocols) { | ||
|
@@ -273,22 +268,10 @@ public override bool Equals(object obj) { | |
|
||
public override int GetHashCode() => ObjectComparer.Instance.GetHashCode(_protocols); | ||
|
||
internal override bool UnionEquals(AnalysisValue av, int strength) { | ||
if (av is ProtocolInfo pi) { | ||
if (strength > 0) { | ||
return Name == pi.Name; | ||
} | ||
return ObjectComparer.Instance.Equals(_protocols, pi._protocols); | ||
} | ||
return false; | ||
} | ||
internal override bool UnionEquals(AnalysisValue av, int strength) | ||
MikhailArkhipov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
=> av is ProtocolInfo pi ? ObjectComparer.Instance.Equals(_protocols, pi._protocols) : false; | ||
|
||
internal override int UnionHashCode(int strength) { | ||
if (strength > 0) { | ||
return Name.GetHashCode(); | ||
} | ||
return GetHashCode(); | ||
} | ||
internal override int UnionHashCode(int strength) => strength > 0 ? Name.GetHashCode() : GetHashCode(); | ||
|
||
internal override AnalysisValue UnionMergeTypes(AnalysisValue av, int strength) { | ||
if (strength > 0 && av is ProtocolInfo pi && pi.Push()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,14 +9,15 @@ | |
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY | ||
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
// MERCHANTABLITY OR NON-INFRINGEMENT. | ||
// MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache Version 2.0 License for specific language governing | ||
// permissions and limitations under the License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.PythonTools.Analysis.Infrastructure; | ||
using Microsoft.PythonTools.Interpreter; | ||
using Microsoft.PythonTools.Parsing.Ast; | ||
|
||
|
@@ -208,52 +209,17 @@ public override bool IsOfType(IAnalysisSet klass) { | |
return _original.IsOfType(klass); | ||
} | ||
|
||
public override IEnumerable<ILocationInfo> Locations { | ||
get { | ||
if (_original == null) { | ||
return new LocationInfo[0]; | ||
} | ||
return _original.Locations; | ||
} | ||
} | ||
public override IEnumerable<ILocationInfo> Locations => _original.Locations?.MaybeEnumerate(); | ||
MikhailArkhipov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public override string Name => _original == null ? base.Name : this._original.Name; | ||
public override string Name => _original == null ? base.Name : _original.Name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why in this case we call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. No idea. |
||
|
||
public override IEnumerable<OverloadResult> Overloads { | ||
get { | ||
if (_original == null) { | ||
return new OverloadResult[0]; | ||
} | ||
return _original.Overloads; | ||
} | ||
} | ||
public override IEnumerable<OverloadResult> Overloads =>_original.Overloads.MaybeEnumerate(); | ||
|
||
public override IPythonType PythonType { | ||
get { | ||
if (_original == null) { | ||
return null; | ||
} | ||
return _original.PythonType; | ||
} | ||
} | ||
public override IPythonType PythonType => _original?.PythonType; | ||
|
||
internal override IEnumerable<ILocationInfo> References { | ||
get { | ||
if (_original == null) { | ||
return new LocationInfo[0]; | ||
} | ||
return _original.References; | ||
} | ||
} | ||
internal override IEnumerable<ILocationInfo> References => _original.References?.MaybeEnumerate(); | ||
|
||
public override PythonMemberType MemberType { | ||
get { | ||
if (_original == null) { | ||
return PythonMemberType.Unknown; | ||
} | ||
return _original.MemberType; | ||
} | ||
} | ||
public override PythonMemberType MemberType => _original == null ? PythonMemberType.Unknown : _original.MemberType; | ||
|
||
public override IAnalysisSet ReverseBinaryOperation(Node node, AnalysisUnit unit, Parsing.PythonOperator operation, IAnalysisSet rhs) { | ||
if (_original == null) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.