Skip to content

ДЗ №13#7

Open
Kaizer22 wants to merge 2 commits intoOtus-Android:masterfrom
Kaizer22:master
Open

ДЗ №13#7
Kaizer22 wants to merge 2 commits intoOtus-Android:masterfrom
Kaizer22:master

Conversation

@Kaizer22
Copy link

No description provided.

// TODO
override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression) {
super.visitDotQualifiedExpression(expression)
val isGlobalScopeUsing = expression.firstChild.text == "GlobalScope"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вместо firstChild и lastChild более идиоматичным будет использование receiverExpression и selectorExpression

override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression) {
super.visitDotQualifiedExpression(expression)
val isGlobalScopeUsing = expression.firstChild.text == "GlobalScope"
if (isGlobalScopeUsing) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предпочитайте ранние возвраты из функций, чтобы не делать вложенные if

// TODO
override fun visitNamedFunction(function: KtNamedFunction) {
super.visitNamedFunction(function)
val isSuspend = function.firstChild.text == "suspend"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Модификатор suspend лучше проверять через список модификаторов: function.modifierList?.hasSuspendModifier()

]

// e.g. GlobalScope.launch {
val isCoroutineScopeClass = (descriptor as? DeserializedClassDescriptor)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом здесь можно было не разделять на разные дескрипторы, достаточно было получить тип у receiverExpression и проверить, что его fqName равен kotlinx.coroutines.CoroutineScope, но так тоже можно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants