Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
c876759e
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,发现更多精彩内容 >>
提交
c876759e
编写于
10月 06, 2015
作者:
V
Valentin Kipyatkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Insert ']' instead of ')'
上级
fa51ca57
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
52 addition
and
11 deletion
+52
-11
idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt
...src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt
+8
-6
idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/MultipleArgumentsItemProvider.kt
...in/idea/completion/smart/MultipleArgumentsItemProvider.kt
+11
-5
idea/idea-completion/testData/handlers/smart/MultipleArgsIntoBrackets.kt
...etion/testData/handlers/smart/MultipleArgsIntoBrackets.kt
+7
-0
idea/idea-completion/testData/handlers/smart/MultipleArgsIntoBrackets.kt.after
...testData/handlers/smart/MultipleArgsIntoBrackets.kt.after
+7
-0
idea/idea-completion/testData/smart/multipleArgsItem/CallWithBrackets.kt
...etion/testData/smart/multipleArgsItem/CallWithBrackets.kt
+7
-0
idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java
...idea/completion/test/JvmSmartCompletionTestGenerated.java
+6
-0
idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java
...on/test/handlers/SmartCompletionHandlerTestGenerated.java
+6
-0
未找到文件。
idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt
浏览文件 @
c876759e
...
...
@@ -133,15 +133,16 @@ class ExpectedInfo(
val
ExpectedInfo
.
fuzzyType
:
FuzzyType
?
get
()
=
(
this
.
filter
as
?
ByExpectedTypeFilter
)
?.
fuzzyType
sealed
class
ArgumentPositionData
(
val
function
:
FunctionDescriptor
)
:
ExpectedInfo
.
AdditionalData
{
sealed
class
ArgumentPositionData
(
val
function
:
FunctionDescriptor
,
val
callType
:
Call
.
CallType
)
:
ExpectedInfo
.
AdditionalData
{
class
Positional
(
function
:
FunctionDescriptor
,
callType
:
Call
.
CallType
,
val
argumentIndex
:
Int
,
val
isFunctionLiteralArgument
:
Boolean
,
val
namedArgumentCandidates
:
Collection
<
ParameterDescriptor
>
)
:
ArgumentPositionData
(
function
)
)
:
ArgumentPositionData
(
function
,
callType
)
class
Named
(
function
:
FunctionDescriptor
,
val
argumentName
:
Name
)
:
ArgumentPositionData
(
function
)
class
Named
(
function
:
FunctionDescriptor
,
callType
:
Call
.
CallType
,
val
argumentName
:
Name
)
:
ArgumentPositionData
(
function
,
callType
)
}
class
ReturnValueAdditionalData
(
val
callable
:
CallableDescriptor
)
:
ExpectedInfo
.
AdditionalData
...
...
@@ -309,8 +310,10 @@ class ExpectedInfos(
val
argumentName
=
argument
.
getArgumentName
()
?.
asName
val
isFunctionLiteralArgument
=
argument
is
FunctionLiteralArgument
val
callType
=
call
.
callType
val
argumentPositionData
=
if
(
argumentName
!=
null
)
{
ArgumentPositionData
.
Named
(
descriptor
,
argumentName
)
ArgumentPositionData
.
Named
(
descriptor
,
callType
,
argumentName
)
}
else
{
val
namedArgumentCandidates
=
if
(!
isFunctionLiteralArgument
&&
descriptor
.
hasStableParameterNames
())
{
...
...
@@ -320,10 +323,9 @@ class ExpectedInfos(
else
{
emptyList
()
}
ArgumentPositionData
.
Positional
(
descriptor
,
argumentIndex
,
isFunctionLiteralArgument
,
namedArgumentCandidates
)
ArgumentPositionData
.
Positional
(
descriptor
,
callType
,
argumentIndex
,
isFunctionLiteralArgument
,
namedArgumentCandidates
)
}
val
callType
=
call
.
callType
val
isArrayAccess
=
callType
==
Call
.
CallType
.
ARRAY_GET_METHOD
||
callType
==
Call
.
CallType
.
ARRAY_SET_METHOD
val
rparenthTail
=
if
(
isArrayAccess
)
Tail
.
RBRACKET
else
Tail
.
RPARENTH
...
...
idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/MultipleArgumentsItemProvider.kt
浏览文件 @
c876759e
...
...
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.idea.completion.SmartCastCalculator
import
org.jetbrains.kotlin.idea.completion.Tail
import
org.jetbrains.kotlin.idea.util.getVariableFromImplicitReceivers
import
org.jetbrains.kotlin.incremental.components.NoLookupLocation
import
org.jetbrains.kotlin.psi.Call
import
org.jetbrains.kotlin.psi.JetExpression
import
org.jetbrains.kotlin.renderer.render
import
org.jetbrains.kotlin.resolve.BindingContext
...
...
@@ -47,16 +48,21 @@ class MultipleArgumentsItemProvider(val bindingContext: BindingContext,
val
added
=
HashSet
<
String
>()
for
(
expectedInfo
in
expectedInfos
)
{
if
(
expectedInfo
.
additionalData
is
ArgumentPositionData
.
Positional
&&
expectedInfo
.
additionalData
.
argumentIndex
==
0
)
{
val
parameters
=
expectedInfo
.
additionalData
.
function
.
valueParameters
val
additionalData
=
expectedInfo
.
additionalData
if
(
additionalData
is
ArgumentPositionData
.
Positional
&&
additionalData
.
argumentIndex
==
0
)
{
val
parameters
=
additionalData
.
function
.
valueParameters
if
(
parameters
.
size
()
>
1
)
{
val
tail
=
when
(
additionalData
.
callType
)
{
Call
.
CallType
.
ARRAY_GET_METHOD
,
Call
.
CallType
.
ARRAY_SET_METHOD
->
Tail
.
RBRACKET
else
->
Tail
.
RPARENTH
}
val
variables
=
ArrayList
<
VariableDescriptor
>()
for
((
i
,
parameter
)
in
parameters
.
withIndex
())
{
val
variable
=
variableInScope
(
parameter
,
resolutionScope
)
?:
break
variables
.
add
(
variable
)
// TODO: cannot inline variable because of KT-5890
if
(
i
>
0
&&
parameters
.
asSequence
().
drop
(
i
+
1
).
all
{
it
.
hasDefaultValue
()
})
{
// this is the last parameter or all others have default values
val
lookupElement
=
createParametersLookupElement
(
variables
)
val
lookupElement
=
createParametersLookupElement
(
variables
,
tail
)
if
(
added
.
add
(
lookupElement
.
getLookupString
()))
{
// check that we don't already have item with the same text
collection
.
add
(
lookupElement
)
}
...
...
@@ -67,7 +73,7 @@ class MultipleArgumentsItemProvider(val bindingContext: BindingContext,
}
}
private
fun
createParametersLookupElement
(
variables
:
List
<
VariableDescriptor
>):
LookupElement
{
private
fun
createParametersLookupElement
(
variables
:
List
<
VariableDescriptor
>
,
tail
:
Tail
):
LookupElement
{
val
compoundIcon
=
LayeredIcon
(
2
)
val
firstIcon
=
JetDescriptorIconProvider
.
getIcon
(
variables
.
first
(),
null
,
0
)
val
lastIcon
=
JetDescriptorIconProvider
.
getIcon
(
variables
.
last
(),
null
,
0
)
...
...
@@ -86,7 +92,7 @@ class MultipleArgumentsItemProvider(val bindingContext: BindingContext,
}
.
withIcon
(
compoundIcon
)
.
addTail
(
Tail
.
RPARENTH
)
//TODO: support square brackets
.
addTail
(
tail
)
.
assignSmartCompletionPriority
(
SmartCompletionItemPriority
.
MULTIPLE_ARGUMENTS_ITEM
)
}
...
...
idea/idea-completion/testData/handlers/smart/MultipleArgsIntoBrackets.kt
0 → 100644
浏览文件 @
c876759e
operator
fun
String
.
get
(
a
:
Int
,
b
:
String
,
c
:
String
):
Int
=
0
fun
bar
(
b
:
String
,
a
:
Int
,
c
:
String
)
{
""
[<
caret
>]
}
// ELEMENT: "a, b, c"
idea/idea-completion/testData/handlers/smart/MultipleArgsIntoBrackets.kt.after
0 → 100644
浏览文件 @
c876759e
operator fun String.get(a: Int, b: String, c: String): Int = 0
fun bar(b: String, a: Int, c: String) {
""[a, b, c]<caret>
}
// ELEMENT: "a, b, c"
idea/idea-completion/testData/smart/multipleArgsItem/CallWithBrackets.kt
0 → 100644
浏览文件 @
c876759e
operator
fun
String
.
get
(
a
:
Int
,
b
:
String
,
c
:
String
):
Int
=
0
fun
bar
(
b
:
String
,
a
:
Int
,
c
:
String
)
{
""
[<
caret
>]
}
// EXIST: "a, b, c"
idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java
浏览文件 @
c876759e
...
...
@@ -1356,6 +1356,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
public
void
testAllFilesPresentInMultipleArgsItem
()
throws
Exception
{
JetTestUtils
.
assertAllTestsPresentByMetadata
(
this
.
getClass
(),
new
File
(
"idea/idea-completion/testData/smart/multipleArgsItem"
),
Pattern
.
compile
(
"^(.+)\\.kt$"
),
true
);
}
@TestMetadata
(
"CallWithBrackets.kt"
)
public
void
testCallWithBrackets
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"idea/idea-completion/testData/smart/multipleArgsItem/CallWithBrackets.kt"
);
doTest
(
fileName
);
}
}
@TestMetadata
(
"idea/idea-completion/testData/smart/smartCasts"
)
...
...
idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java
浏览文件 @
c876759e
...
...
@@ -569,6 +569,12 @@ public class SmartCompletionHandlerTestGenerated extends AbstractSmartCompletion
doTest
(
fileName
);
}
@TestMetadata
(
"MultipleArgsIntoBrackets.kt"
)
public
void
testMultipleArgsIntoBrackets
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"idea/idea-completion/testData/handlers/smart/MultipleArgsIntoBrackets.kt"
);
doTest
(
fileName
);
}
@TestMetadata
(
"MultipleArgsItem.kt"
)
public
void
testMultipleArgsItem
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"idea/idea-completion/testData/handlers/smart/MultipleArgsItem.kt"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录