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

Commit 0dbaf33

Browse files
author
MikhailArkhipov
committed
PR feedback
1 parent b5beb30 commit 0dbaf33

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ public ExtractMethodResult GetExtractionResult() {
6060
bool isStaticMethod = false, isClassMethod = false;
6161
var parameters = new List<Parameter>();
6262
NameExpression selfParam = null;
63-
if (_targetScope is ClassDefinition) {
64-
var fromScope = _scopes[_scopes.Count - 1] as FunctionDefinition;
65-
Debug.Assert(fromScope != null); // we don't allow extracting from classes, so we have to be coming from a function
63+
if (_targetScope is ClassDefinition && _scopes[_scopes.Count - 1] is FunctionDefinition fromScope) {
6664
foreach (var name in (fromScope?.Decorators?.Decorators).MaybeEnumerate().ExcludeDefault().OfType<NameExpression>()) {
6765
if (name.Name == "staticmethod") {
6866
isStaticMethod = true;
@@ -230,15 +228,12 @@ public ExtractMethodResult GetExtractionResult() {
230228
newCall.Append("await ");
231229
}
232230

233-
if (_targetScope is ClassDefinition) {
234-
var fromScope = _scopes[_scopes.Count - 1] as FunctionDefinition;
235-
Debug.Assert(fromScope != null); // we don't allow extracting from classes, so we have to be coming from a function
236-
231+
if (_targetScope is ClassDefinition && _scopes[_scopes.Count - 1] is FunctionDefinition fromScope2) {
237232
if (isStaticMethod) {
238233
newCall.Append(_targetScope.Name);
239234
newCall.Append('.');
240-
} else if (fromScope != null && fromScope.Parameters.Length > 0) {
241-
newCall.Append(fromScope.Parameters[0].Name);
235+
} else if (fromScope2 != null && fromScope2.Parameters.Length > 0) {
236+
newCall.Append(fromScope2.Parameters[0].Name);
242237
newCall.Append('.');
243238
}
244239
}

0 commit comments

Comments
 (0)