Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 6df890b

Browse files
author
MikhailArkhipov
committed
Formatting
1 parent 9d47343 commit 6df890b

1 file changed

Lines changed: 12 additions & 25 deletions

File tree

src/Analysis/Engine/Impl/OverloadResult.cs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616

1717
using System;
1818
using System.Collections.Generic;
19-
using System.Diagnostics;
2019
using System.Linq;
2120
using System.Text;
2221
using System.Threading.Tasks;
2322
using Microsoft.PythonTools.Analysis.Infrastructure;
24-
using Microsoft.PythonTools.Analysis.Values;
2523
using Microsoft.PythonTools.Interpreter;
2624

2725
namespace Microsoft.PythonTools.Analysis {
@@ -63,7 +61,7 @@ private static IEnumerable<string> CommaSplit(string x) {
6361
}
6462

6563
var sb = new StringBuilder();
66-
int nestCount = 0;
64+
var nestCount = 0;
6765
foreach (var c in x) {
6866
if (c == ',' && nestCount == 0) {
6967
yield return sb.ToString().Trim();
@@ -95,7 +93,7 @@ public static OverloadResult Merge(IEnumerable<OverloadResult> overloads) {
9593
var parameters = overloads.Select(o => o.Parameters).Aggregate(Array.Empty<ParameterResult>(), (all, pms) => {
9694
var res = all.Concat(pms.Skip(all.Length)).ToArray();
9795

98-
for (int i = 0; i < res.Length; ++i) {
96+
for (var i = 0; i < res.Length; ++i) {
9997
if (res[i] == null) {
10098
res[i] = pms[i];
10199
} else {
@@ -179,16 +177,6 @@ private string ChooseBest(string x, string y) {
179177
return x.Length >= y.Length ? x : y;
180178
}
181179

182-
private IAnalysisSet ChooseBest(IAnalysisSet x, IAnalysisSet y) {
183-
if (x == null || x.IsObjectOrUnknown()) {
184-
return (y == null || y.IsObjectOrUnknown()) ? AnalysisSet.Empty : y;
185-
}
186-
if (y == null || y.IsObjectOrUnknown()) {
187-
return AnalysisSet.Empty;
188-
}
189-
return x.Union(y);
190-
}
191-
192180
public bool TryAddOverload(string name, string documentation, string[] names, string[] types, string[] defaults, IEnumerable<string> returnTypes) {
193181
if (names.Length != _pnames.Length || types.Length != _ptypes.Length) {
194182
return false;
@@ -225,7 +213,7 @@ public bool TryAddOverload(string name, string documentation, string[] names, st
225213

226214
public OverloadResult ToOverloadResult() {
227215
var parameters = new ParameterResult[_pnames.Length];
228-
for (int i = 0; i < parameters.Length; ++i) {
216+
for (var i = 0; i < parameters.Length; ++i) {
229217
if (string.IsNullOrEmpty(_pnames[i])) {
230218
return null;
231219
}
@@ -328,15 +316,15 @@ private void DocCalculator() {
328316
}
329317

330318
foreach (var param in _overload.GetParameters()) {
331-
if (!String.IsNullOrEmpty(param.Documentation)) {
319+
if (!string.IsNullOrEmpty(param.Documentation)) {
332320
doc.AppendLine();
333321
doc.Append(param.Name);
334322
doc.Append(": ");
335323
doc.Append(param.Documentation);
336324
}
337325
}
338326

339-
if (!String.IsNullOrEmpty(_overload.ReturnDocumentation)) {
327+
if (!string.IsNullOrEmpty(_overload.ReturnDocumentation)) {
340328
doc.AppendLine();
341329
doc.AppendLine();
342330
doc.Append("Returns: ");
@@ -359,7 +347,7 @@ public override ParameterResult[] Parameters {
359347

360348
var pinfo = _overload.GetParameters();
361349
var result = new List<ParameterResult>(pinfo.Length + _extraParameters.Length);
362-
int ignored = 0;
350+
var ignored = 0;
363351
ParameterResult kwDict = null;
364352
foreach (var param in pinfo) {
365353
if (ignored < _removedParams) {
@@ -392,7 +380,7 @@ public override ParameterResult[] Parameters {
392380
}
393381

394382
internal ParameterResult GetParameterResultFromParameterInfo(IParameterInfo param) {
395-
string name = param.Name;
383+
var name = param.Name;
396384

397385
string typeName;
398386
if (param.ParameterTypes != null) {
@@ -402,8 +390,7 @@ internal ParameterResult GetParameterResultFromParameterInfo(IParameterInfo para
402390
}
403391
if (param.IsParamArray) {
404392
name = "*" + name;
405-
var advType = param.ParameterTypes as IAdvancedPythonType;
406-
if (advType != null && advType.IsArray) {
393+
if (param.ParameterTypes is IAdvancedPythonType advType && advType.IsArray) {
407394
var elemType = advType.GetElementType();
408395
if (elemType == _projectState.Types[BuiltinTypeId.Object]) {
409396
typeName = "sequence";
@@ -416,8 +403,8 @@ internal ParameterResult GetParameterResultFromParameterInfo(IParameterInfo para
416403
typeName = "object";
417404
}
418405

419-
bool isOptional = false;
420-
string defaultValue = param.DefaultValue;
406+
var isOptional = false;
407+
var defaultValue = param.DefaultValue;
421408
if (defaultValue != null && defaultValue.Length == 0) {
422409
isOptional = true;
423410
defaultValue = null;
@@ -456,7 +443,7 @@ public override bool Equals(OverloadResult x, OverloadResult y) {
456443
return false;
457444
}
458445

459-
for (int i = 0; i < x.Parameters.Length; ++i) {
446+
for (var i = 0; i < x.Parameters.Length; ++i) {
460447
if (_weak) {
461448
if (!x.Parameters[i].Name.Equals(y.Parameters[i].Name)) {
462449
return false;
@@ -474,7 +461,7 @@ public override bool Equals(OverloadResult x, OverloadResult y) {
474461
public override int GetHashCode(OverloadResult obj) {
475462
// Don't use Documentation for hash code, since it changes over time
476463
// in some implementations of IOverloadResult.
477-
int hc = 552127 ^ obj.Name.GetHashCode();
464+
var hc = 552127 ^ obj.Name.GetHashCode();
478465
if (obj.Parameters != null) {
479466
foreach (var p in obj.Parameters) {
480467
hc ^= _weak ? p.Name.GetHashCode() : p.GetHashCode();

0 commit comments

Comments
 (0)