Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
ee1b741e
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,发现更多精彩内容 >>
提交
ee1b741e
编写于
12月 19, 2016
作者:
M
Mikhail Glukhikh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More accurate handling of Elvis in areParenthesesNecessary #KT-15227 Fixed
上级
6d6a16f3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
1 deletion
+36
-1
compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java
...iler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java
+4
-1
idea/testData/intentions/branched/ifThenToElvis/comparisonInElse.kt
...ata/intentions/branched/ifThenToElvis/comparisonInElse.kt
+9
-0
idea/testData/intentions/branched/ifThenToElvis/comparisonInElse.kt.after
...tentions/branched/ifThenToElvis/comparisonInElse.kt.after
+9
-0
idea/testData/intentions/branched/ifThenToElvis/inspectionData/expected.xml
...ntions/branched/ifThenToElvis/inspectionData/expected.xml
+8
-0
idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
...brains/kotlin/idea/intentions/IntentionTestGenerated.java
+6
-0
未找到文件。
compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java
浏览文件 @
ee1b741e
...
...
@@ -503,7 +503,10 @@ public class KtPsiUtil {
if
(
parentElement
instanceof
KtLabeledExpression
)
return
false
;
// 'x ?: ...' case
if
(
parentElement
instanceof
KtBinaryExpression
&&
parentOperation
==
KtTokens
.
ELVIS
&&
currentInner
==
((
KtBinaryExpression
)
parentElement
).
getRight
())
{
if
(
parentElement
instanceof
KtBinaryExpression
&&
parentOperation
==
KtTokens
.
ELVIS
&&
!(
innerExpression
instanceof
KtBinaryExpression
)
&&
currentInner
==
((
KtBinaryExpression
)
parentElement
).
getRight
())
{
return
false
;
}
...
...
idea/testData/intentions/branched/ifThenToElvis/comparisonInElse.kt
0 → 100644
浏览文件 @
ee1b741e
// See KT-15227
class
My
(
val
local
:
Boolean
)
class
Your
(
val
my
:
My
?,
val
parent
:
Any
?)
fun
foo
(
your
:
Your
):
Boolean
{
val
my
=
your
.
my
return
<
caret
>
if
(
my
!=
null
)
my
.
local
else
your
.
parent
!=
null
}
\ No newline at end of file
idea/testData/intentions/branched/ifThenToElvis/comparisonInElse.kt.after
0 → 100644
浏览文件 @
ee1b741e
// See KT-15227
class My(val local: Boolean)
class Your(val my: My?, val parent: Any?)
fun foo(your: Your): Boolean {
val my = your.my
return my?.local ?: (your.parent != null)
}
\ No newline at end of file
idea/testData/intentions/branched/ifThenToElvis/inspectionData/expected.xml
浏览文件 @
ee1b741e
...
...
@@ -87,4 +87,12 @@
<problem_class
severity=
"WARNING"
attribute_key=
"WARNING_ATTRIBUTES"
>
If-Then foldable to '?:'
</problem_class>
<description>
Replace 'if' expression with elvis expression
</description>
</problem>
<problem>
<file>
comparisonInElse.kt
</file>
<line>
8
</line>
<module>
light_idea_test_case
</module>
<entry_point
TYPE=
"file"
FQNAME=
"temp:///src/comparisonInElse.kt"
/>
<problem_class
severity=
"WARNING"
attribute_key=
"WARNING_ATTRIBUTES"
>
If-Then foldable to '?:'
</problem_class>
<description>
Replace 'if' expression with elvis expression
</description>
</problem>
</problems>
idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
浏览文件 @
ee1b741e
...
...
@@ -1294,6 +1294,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("comparisonInElse.kt")
public void testComparisonInElse() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/ifThenToElvis/comparisonInElse.kt");
doTest(fileName);
}
@TestMetadata("conditionComparesNullWithNull.kt")
public void testConditionComparesNullWithNull() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/ifThenToElvis/conditionComparesNullWithNull.kt");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录