@@ -44,10 +44,7 @@ public boolean hasTypeParameterListBeforeFunctionName() {
44
44
if (stub != null ) {
45
45
return stub .getHasTypeParameterListBeforeFunctionName ();
46
46
}
47
- return hasTypeParameterListBeforeFunctionNameByTree ();
48
- }
49
47
50
- private boolean hasTypeParameterListBeforeFunctionNameByTree () {
51
48
KtTypeParameterList typeParameterList = getTypeParameterList ();
52
49
if (typeParameterList == null ) {
53
50
return false ;
@@ -69,7 +66,7 @@ public boolean hasBlockBody() {
69
66
}
70
67
71
68
@ Nullable
72
- @ IfNotParsed // "function" with no "fun" keyword is created by parser for "{...}" on top-level or in class body
69
+ @ IfNotParsed // "function" with no "fun" keyword is created by parser for "{...}" on top-level or in the class body
73
70
public PsiElement getFunKeyword () {
74
71
return findChildByType (KtTokens .FUN_KEYWORD );
75
72
}
@@ -113,10 +110,8 @@ public List<KtParameter> getValueParameters() {
113
110
@ Nullable
114
111
public KtExpression getBodyExpression () {
115
112
KotlinFunctionStub stub = getGreenStub ();
116
- if (stub != null ) {
117
- if (!stub .getHasBody ()) {
118
- return null ;
119
- }
113
+ if (stub != null && !stub .getHasBody ()) {
114
+ return null ;
120
115
}
121
116
122
117
return findChildByClass (KtExpression .class );
@@ -158,19 +153,20 @@ public boolean hasDeclaredReturnType() {
158
153
@ Nullable
159
154
public KtTypeReference getReceiverTypeReference () {
160
155
KotlinFunctionStub stub = getGreenStub ();
161
- if (stub != null ) {
162
- if (!stub .isExtension ()) {
163
- return null ;
164
- }
165
- List <KtTypeReference > childTypeReferences = getStubOrPsiChildrenAsList (KtStubBasedElementTypes .TYPE_REFERENCE );
166
- if (!childTypeReferences .isEmpty ()) {
167
- return childTypeReferences .get (0 );
168
- }
169
- else {
170
- return null ;
171
- }
156
+ if (stub == null ) {
157
+ return getReceiverTypeRefByTree ();
158
+ }
159
+
160
+ if (!stub .isExtension ()) {
161
+ return null ;
162
+ }
163
+ List <KtTypeReference > childTypeReferences = getStubOrPsiChildrenAsList (KtStubBasedElementTypes .TYPE_REFERENCE );
164
+ if (!childTypeReferences .isEmpty ()) {
165
+ return childTypeReferences .get (0 );
166
+ }
167
+ else {
168
+ return null ;
172
169
}
173
- return getReceiverTypeRefByTree ();
174
170
}
175
171
176
172
@ Nullable
@@ -204,15 +200,16 @@ public List<KtContextReceiver> getContextReceivers() {
204
200
@ Nullable
205
201
public KtTypeReference getTypeReference () {
206
202
KotlinFunctionStub stub = getGreenStub ();
207
- if (stub != null ) {
208
- List <KtTypeReference > typeReferences = getStubOrPsiChildrenAsList (KtStubBasedElementTypes .TYPE_REFERENCE );
209
- int returnTypeIndex = stub .isExtension () ? 1 : 0 ;
210
- if (returnTypeIndex >= typeReferences .size ()) {
211
- return null ;
212
- }
213
- return typeReferences .get (returnTypeIndex );
203
+ if (stub == null ) {
204
+ return TypeRefHelpersKt .getTypeReference (this );
205
+ }
206
+
207
+ List <KtTypeReference > typeReferences = getStubOrPsiChildrenAsList (KtStubBasedElementTypes .TYPE_REFERENCE );
208
+ int returnTypeIndex = stub .isExtension () ? 1 : 0 ;
209
+ if (returnTypeIndex >= typeReferences .size ()) {
210
+ return null ;
214
211
}
215
- return TypeRefHelpersKt . getTypeReference ( this );
212
+ return typeReferences . get ( returnTypeIndex );
216
213
}
217
214
218
215
@ Override
0 commit comments