Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
298d98ee
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,发现更多精彩内容 >>
提交
298d98ee
编写于
4月 25, 2012
作者:
E
Evgeny Gerashchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extracted generatedOverridingMembers() method in OverrideImplementMethodsHandler.
上级
97d96b48
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
20 deletion
+24
-20
idea/src/org/jetbrains/jet/plugin/codeInsight/OverrideImplementMethodsHandler.java
...t/plugin/codeInsight/OverrideImplementMethodsHandler.java
+22
-18
idea/tests/org/jetbrains/jet/plugin/codeInsight/OverrideImplementTest.java
...tbrains/jet/plugin/codeInsight/OverrideImplementTest.java
+2
-2
未找到文件。
idea/src/org/jetbrains/jet/plugin/codeInsight/OverrideImplementMethodsHandler.java
浏览文件 @
298d98ee
...
...
@@ -67,10 +67,9 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
protected
abstract
Set
<
CallableMemberDescriptor
>
collectMethodsToGenerate
(
MutableClassDescriptor
descriptor
);
public
static
void
generateMethods
(
Project
project
,
Editor
editor
,
JetClassOrObject
classOrObject
,
List
<
DescriptorClassMember
>
selectedElements
)
{
public
static
void
generateMethods
(
Editor
editor
,
JetClassOrObject
classOrObject
,
List
<
DescriptorClassMember
>
selectedElements
)
{
final
JetClassBody
body
=
classOrObject
.
getBody
();
if
(
body
==
null
)
{
return
;
...
...
@@ -82,17 +81,8 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
return
;
}
for
(
DescriptorClassMember
selectedElement
:
selectedElements
)
{
final
DeclarationDescriptor
descriptor
=
selectedElement
.
getDescriptor
();
JetFile
containingFile
=
(
JetFile
)
classOrObject
.
getContainingFile
();
if
(
descriptor
instanceof
SimpleFunctionDescriptor
)
{
JetElement
target
=
overrideFunction
(
project
,
containingFile
,
(
SimpleFunctionDescriptor
)
descriptor
);
afterAnchor
=
body
.
addAfter
(
target
,
afterAnchor
);
}
else
if
(
descriptor
instanceof
PropertyDescriptor
)
{
JetElement
target
=
overrideProperty
(
project
,
containingFile
,
(
PropertyDescriptor
)
descriptor
);
afterAnchor
=
body
.
addAfter
(
target
,
afterAnchor
);
}
for
(
JetElement
element
:
generateOverridingMembers
(
selectedElements
,
(
JetFile
)
classOrObject
.
getContainingFile
(),
false
))
{
afterAnchor
=
body
.
addAfter
(
element
,
afterAnchor
);
}
}
...
...
@@ -119,7 +109,21 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
return
afterAnchor
;
}
private
static
JetElement
overrideProperty
(
Project
project
,
JetFile
file
,
PropertyDescriptor
descriptor
)
{
private
static
List
<
JetElement
>
generateOverridingMembers
(
List
<
DescriptorClassMember
>
selectedElements
,
JetFile
file
,
boolean
fqNames
)
{
List
<
JetElement
>
overridingMembers
=
new
ArrayList
<
JetElement
>();
for
(
DescriptorClassMember
selectedElement
:
selectedElements
)
{
final
DeclarationDescriptor
descriptor
=
selectedElement
.
getDescriptor
();
if
(
descriptor
instanceof
SimpleFunctionDescriptor
)
{
overridingMembers
.
add
(
overrideFunction
(
file
.
getProject
(),
file
,
(
SimpleFunctionDescriptor
)
descriptor
,
fqNames
));
}
else
if
(
descriptor
instanceof
PropertyDescriptor
)
{
overridingMembers
.
add
(
overrideProperty
(
file
.
getProject
(),
file
,
(
PropertyDescriptor
)
descriptor
,
fqNames
));
}
}
return
overridingMembers
;
}
private
static
JetElement
overrideProperty
(
Project
project
,
JetFile
file
,
PropertyDescriptor
descriptor
,
boolean
fqNames
)
{
StringBuilder
bodyBuilder
=
new
StringBuilder
();
bodyBuilder
.
append
(
displayableVisibility
(
descriptor
)).
append
(
"override "
);
if
(
descriptor
.
isVar
())
{
...
...
@@ -141,7 +145,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
return
JetPsiFactory
.
createProperty
(
project
,
bodyBuilder
.
toString
());
}
private
static
JetElement
overrideFunction
(
Project
project
,
JetFile
file
,
SimpleFunctionDescriptor
descriptor
)
{
private
static
JetElement
overrideFunction
(
Project
project
,
JetFile
file
,
SimpleFunctionDescriptor
descriptor
,
boolean
fqNames
)
{
StringBuilder
bodyBuilder
=
new
StringBuilder
();
bodyBuilder
.
append
(
displayableVisibility
(
descriptor
));
bodyBuilder
.
append
(
"override fun "
);
...
...
@@ -303,7 +307,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
ApplicationManager
.
getApplication
().
runWriteAction
(
new
Runnable
()
{
@Override
public
void
run
()
{
generateMethods
(
project
,
editor
,
classOrObject
,
selectedElements
);
generateMethods
(
editor
,
classOrObject
,
selectedElements
);
}
});
}
...
...
idea/tests/org/jetbrains/jet/plugin/codeInsight/OverrideImplementTest.java
浏览文件 @
298d98ee
...
...
@@ -209,7 +209,7 @@ public class OverrideImplementTest extends LightCodeInsightFixtureTestCase {
@Override
protected
void
run
(
Result
result
)
throws
Throwable
{
OverrideImplementMethodsHandler
.
generateMethods
(
myFixture
.
get
Project
(),
myFixture
.
get
Editor
(),
classOrObject
,
myFixture
.
getEditor
(),
classOrObject
,
OverrideImplementMethodsHandler
.
membersFromDescriptors
(
Collections
.
singletonList
(
singleToOverride
)));
}
}.
execute
();
...
...
@@ -233,7 +233,7 @@ public class OverrideImplementTest extends LightCodeInsightFixtureTestCase {
@Override
protected
void
run
(
Result
result
)
throws
Throwable
{
OverrideImplementMethodsHandler
.
generateMethods
(
myFixture
.
get
Project
(),
myFixture
.
get
Editor
(),
classOrObject
,
myFixture
.
getEditor
(),
classOrObject
,
OverrideImplementMethodsHandler
.
membersFromDescriptors
(
descriptorsList
));
}
}.
execute
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录