Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
076870ee
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
076870ee
编写于
6月 07, 2018
作者:
N
Nikolay Krasko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix double return hint in lambda for annotated expression (KT-23238)
#KT-23238 Fixed
上级
c5d5f0c2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
6 deletion
+43
-6
idea/src/org/jetbrains/kotlin/idea/parameterInfo/LambdaReturnValueHints.kt
...rains/kotlin/idea/parameterInfo/LambdaReturnValueHints.kt
+21
-6
idea/tests/org/jetbrains/kotlin/idea/parameterInfo/LambdaReturnValueHintsTest.kt
...s/kotlin/idea/parameterInfo/LambdaReturnValueHintsTest.kt
+22
-0
未找到文件。
idea/src/org/jetbrains/kotlin/idea/parameterInfo/LambdaReturnValueHints.kt
浏览文件 @
076870ee
...
...
@@ -6,6 +6,7 @@
package
org.jetbrains.kotlin.idea.parameterInfo
import
com.intellij.codeInsight.hints.InlayInfo
import
com.intellij.psi.PsiWhiteSpace
import
org.jetbrains.kotlin.idea.caches.resolve.analyze
import
org.jetbrains.kotlin.psi.*
import
org.jetbrains.kotlin.psi.psiUtil.getParentOfType
...
...
@@ -18,12 +19,11 @@ fun provideLambdaReturnValueHints(expression: KtExpression): List<InlayInfo> {
return
emptyList
()
}
val
parent
=
expression
.
parent
if
(
parent
is
KtDotQualifiedExpression
||
parent
is
KtSafeQualifiedExpression
||
parent
is
KtBinaryExpression
||
parent
is
KtUnaryExpression
)
{
if
(!
KtPsiUtil
.
isStatement
(
expression
))
{
if
(!
allowLabelOnExpressionPart
(
expression
))
{
return
emptyList
()
}
}
else
if
(
forceLabelOnExpressionPart
(
expression
))
{
return
emptyList
()
}
...
...
@@ -53,3 +53,18 @@ private fun getNameOfFunctionThatTakesLambda(expression: KtExpression): String?
}
return
null
}
private
fun
allowLabelOnExpressionPart
(
expression
:
KtExpression
):
Boolean
{
val
parent
=
expression
.
parent
return
parent
is
KtAnnotatedExpression
&&
parent
.
baseExpression
==
expression
&&
parent
.
lineSeparatorBeforeBase
()
}
private
fun
forceLabelOnExpressionPart
(
expression
:
KtExpression
):
Boolean
{
return
expression
is
KtAnnotatedExpression
&&
expression
.
lineSeparatorBeforeBase
()
}
private
fun
KtAnnotatedExpression
.
lineSeparatorBeforeBase
():
Boolean
{
val
base
=
baseExpression
?:
return
false
val
whiteSpace
=
base
.
node
.
treePrev
?.
psi
as
?
PsiWhiteSpace
?:
return
false
return
whiteSpace
.
text
.
contains
(
"\n"
)
}
idea/tests/org/jetbrains/kotlin/idea/parameterInfo/LambdaReturnValueHintsTest.kt
浏览文件 @
076870ee
...
...
@@ -136,4 +136,26 @@ class LambdaReturnValueHintsTest : KotlinLightCodeInsightFixtureTestCase() {
"""
)
}
fun
testAnnotatedStatement
()
{
check
(
"""
@Target(AnnotationTarget.EXPRESSION)
annotation class Some
fun test() {
run {
val files: Any? = null
@Some
<hint text="^run"/>12
}
run {
val files: Any? = null
<hint text="^run"/>@Some 12
}
}
"""
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录