Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
09ae1f1a
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,发现更多精彩内容 >>
提交
09ae1f1a
编写于
11月 14, 2016
作者:
M
Mikhail Glukhikh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
False positive removed in replace single line let intention #KT-14791 Fixed
上级
61da8be2
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
72 addition
and
1 deletion
+72
-1
idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt
...s/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt
+2
-1
idea/testData/intentions/replaceSingleLineLetIntention/assignment.kt
...ta/intentions/replaceSingleLineLetIntention/assignment.kt
+8
-0
idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt
...a/intentions/replaceSingleLineLetIntention/comparisons.kt
+4
-0
idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt
.../intentions/replaceSingleLineLetIntention/plusNullable.kt
+4
-0
idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt
...tentions/replaceSingleLineLetIntention/smartCastInBody.kt
+15
-0
idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt
...ta/intentions/replaceSingleLineLetIntention/typeChecks.kt
+9
-0
idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
...brains/kotlin/idea/intentions/IntentionTestGenerated.java
+30
-0
未找到文件。
idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt
浏览文件 @
09ae1f1a
...
...
@@ -94,7 +94,7 @@ class ReplaceSingleLineLetIntention : SelfTargetingOffsetIndependentIntention<Kt
val
bodyExpression
=
lambdaExpression
.
bodyExpression
?.
children
?.
singleOrNull
()
?:
return
false
return
when
(
bodyExpression
)
{
is
KtBinaryExpression
->
bodyExpression
.
isApplicable
(
parameterName
)
is
KtBinaryExpression
->
element
.
parent
!
is
KtSafeQualifiedExpression
&&
bodyExpression
.
isApplicable
(
parameterName
)
is
KtDotQualifiedExpression
->
bodyExpression
.
isApplicable
(
parameterName
)
else
->
false
}
...
...
@@ -105,6 +105,7 @@ class ReplaceSingleLineLetIntention : SelfTargetingOffsetIndependentIntention<Kt
when
(
left
)
{
is
KtNameReferenceExpression
->
if
(
left
.
text
!=
parameterName
)
return
false
is
KtDotQualifiedExpression
->
if
(!
left
.
isApplicable
(
parameterName
))
return
false
else
->
return
false
}
val
right
=
right
?:
return
false
...
...
idea/testData/intentions/replaceSingleLineLetIntention/assignment.kt
0 → 100644
浏览文件 @
09ae1f1a
// IS_APPLICABLE: false
// WITH_RUNTIME
fun
withAssign
(
arg
:
String
?):
String
{
var
result
:
String
=
""
arg
?.
let
<
caret
>
{
result
=
it
}
return
result
}
\ No newline at end of file
idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt
0 → 100644
浏览文件 @
09ae1f1a
// IS_APPLICABLE: false
// WITH_RUNTIME
fun
isAlphaOrBeta
(
str
:
String
)
=
str
.
let
<
caret
>
{
it
==
"Alpha"
||
it
==
"Beta"
}
idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt
0 → 100644
浏览文件 @
09ae1f1a
// IS_APPLICABLE: false
// WITH_RUNTIME
fun
plusNullable
(
arg
:
String
?)
=
arg
?.
let
<
caret
>
{
it
+
"#"
}
?:
""
\ No newline at end of file
idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt
0 → 100644
浏览文件 @
09ae1f1a
// IS_APPLICABLE: false
// WITH_RUNTIME
interface
A
interface
B
:
A
{
val
bar
:
Any
?
}
class
Foo
{
private
val
a
:
A
=
object
:
A
{}
val
isB
:
Boolean
get
()
=
a
.
let
<
caret
>
{
it
is
B
&&
it
.
bar
!=
null
}
}
\ No newline at end of file
idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt
0 → 100644
浏览文件 @
09ae1f1a
// IS_APPLICABLE: false
// WITH_RUNTIME
interface
Base
class
A
:
Base
class
B
:
Base
fun
isAB
(
arg
:
Base
)
=
arg
.
let
<
caret
>
{
it
is
A
||
it
is
B
}
\ No newline at end of file
idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
浏览文件 @
09ae1f1a
...
...
@@ -11799,6 +11799,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/replaceSingleLineLetIntention"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("assignment.kt")
public void testAssignment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/assignment.kt");
doTest(fileName);
}
@TestMetadata("comparisons.kt")
public void testComparisons() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt");
doTest(fileName);
}
@TestMetadata("lambdaWithBinaryExpression.kt")
public void testLambdaWithBinaryExpression() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt");
...
...
@@ -11949,6 +11961,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("plusNullable.kt")
public void testPlusNullable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt");
doTest(fileName);
}
@TestMetadata("receiverWithLambda.kt")
public void testReceiverWithLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda.kt");
...
...
@@ -11967,6 +11985,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("smartCastInBody.kt")
public void testSmartCastInBody() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt");
doTest(fileName);
}
@TestMetadata("this.kt")
public void testThis() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/this.kt");
...
...
@@ -11978,6 +12002,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt");
doTest(fileName);
}
@TestMetadata("typeChecks.kt")
public void testTypeChecks() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/intentions/replaceSizeCheckWithIsNotEmpty")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录