Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
3f2654c1
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,发现更多精彩内容 >>
提交
3f2654c1
编写于
6月 15, 2011
作者:
D
Dmitry Jemerov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
run configuration producer
上级
1001b4ae
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
97 addition
and
0 deletion
+97
-0
idea/src/META-INF/plugin.xml
idea/src/META-INF/plugin.xml
+1
-0
idea/src/org/jetbrains/jet/lang/psi/JetClass.java
idea/src/org/jetbrains/jet/lang/psi/JetClass.java
+12
-0
idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationProducer.java
...jetbrains/jet/plugin/run/JetRunConfigurationProducer.java
+80
-0
idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationType.java
...org/jetbrains/jet/plugin/run/JetRunConfigurationType.java
+4
-0
未找到文件。
idea/src/META-INF/plugin.xml
浏览文件 @
3f2654c1
...
...
@@ -34,6 +34,7 @@
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.plugin.annotations.JetPsiChecker"
/>
<documentationProvider
implementation=
"org.jetbrains.jet.plugin.JetQuickDocumentationProvider"
/>
<configurationType
implementation=
"org.jetbrains.jet.plugin.run.JetRunConfigurationType"
/>
<configurationProducer
implementation=
"org.jetbrains.jet.plugin.run.JetRunConfigurationProducer"
/>
<codeInsight.lineMarkerProvider
language=
"jet"
implementationClass=
"org.jetbrains.jet.plugin.annotations.JetLineMarkerProvider"
/>
<iconProvider
implementation=
"org.jetbrains.jet.plugin.JetIconProvider"
/>
<fileTypeIndentOptionsProvider
implementation=
"org.jetbrains.jet.plugin.formatter.JetIndentOptionsProvider"
/>
...
...
idea/src/org/jetbrains/jet/lang/psi/JetClass.java
浏览文件 @
3f2654c1
package
org.jetbrains.jet.lang.psi
;
import
com.intellij.lang.ASTNode
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.JetNodeTypes
;
...
...
@@ -90,4 +91,15 @@ public class JetClass extends JetTypeParameterListOwner implements JetClassOrObj
return
body
.
getProperties
();
}
public
String
getFQName
()
{
JetNamedDeclaration
parent
=
PsiTreeUtil
.
getParentOfType
(
this
,
JetNamespace
.
class
,
JetClass
.
class
);
if
(
parent
instanceof
JetNamespace
)
{
return
((
JetNamespace
)
parent
).
getFQName
()
+
"."
+
getName
();
}
if
(
parent
instanceof
JetClass
)
{
return
((
JetClass
)
parent
).
getFQName
()
+
"."
+
getName
();
}
return
getName
();
}
}
idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationProducer.java
0 → 100644
浏览文件 @
3f2654c1
package
org.jetbrains.jet.plugin.run
;
import
com.intellij.execution.Location
;
import
com.intellij.execution.RunnerAndConfigurationSettings
;
import
com.intellij.execution.actions.ConfigurationContext
;
import
com.intellij.execution.junit.RuntimeConfigurationProducer
;
import
com.intellij.openapi.module.Module
;
import
com.intellij.openapi.util.text.StringUtil
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiFile
;
import
org.jetbrains.jet.lang.psi.*
;
import
java.util.List
;
/**
* @author yole
*/
public
class
JetRunConfigurationProducer
extends
RuntimeConfigurationProducer
implements
Cloneable
{
private
PsiElement
mySourceElement
;
public
JetRunConfigurationProducer
()
{
super
(
JetRunConfigurationType
.
getInstance
());
}
@Override
public
PsiElement
getSourceElement
()
{
return
mySourceElement
;
}
@Override
protected
RunnerAndConfigurationSettings
createConfigurationByElement
(
Location
location
,
ConfigurationContext
configurationContext
)
{
JetClass
containingClass
=
(
JetClass
)
location
.
getParentElement
(
JetClass
.
class
);
if
(
containingClass
!=
null
&&
hasMain
(
containingClass
.
getDeclarations
()))
{
mySourceElement
=
containingClass
;
return
createConfigurationByQName
(
location
.
getModule
(),
configurationContext
,
containingClass
.
getFQName
());
}
PsiFile
psiFile
=
location
.
getPsiElement
().
getContainingFile
();
if
(
psiFile
instanceof
JetFile
)
{
JetNamespace
namespace
=
((
JetFile
)
psiFile
).
getRootNamespace
();
if
(
hasMain
(
namespace
.
getDeclarations
()))
{
mySourceElement
=
namespace
;
return
createConfigurationByQName
(
location
.
getModule
(),
configurationContext
,
namespace
.
getFQName
()
+
".namespace"
);
}
}
return
null
;
}
private
boolean
hasMain
(
List
<
JetDeclaration
>
declarations
)
{
for
(
JetDeclaration
declaration
:
declarations
)
{
if
(
declaration
instanceof
JetFunction
)
{
JetFunction
function
=
(
JetFunction
)
declaration
;
if
(
"main"
.
equals
(
function
.
getName
()))
{
List
<
JetParameter
>
parameters
=
function
.
getValueParameters
();
if
(
parameters
.
size
()
==
1
)
{
JetTypeReference
reference
=
parameters
.
get
(
0
).
getTypeReference
();
if
(
reference
!=
null
&&
reference
.
getText
().
equals
(
"Array<String>"
))
{
// TODO correct check
return
true
;
}
}
}
}
}
return
false
;
}
private
RunnerAndConfigurationSettings
createConfigurationByQName
(
Module
module
,
ConfigurationContext
context
,
String
fqName
)
{
RunnerAndConfigurationSettings
settings
=
cloneTemplateConfiguration
(
module
.
getProject
(),
context
);
JetRunConfiguration
configuration
=
(
JetRunConfiguration
)
settings
.
getConfiguration
();
configuration
.
setModule
(
module
);
configuration
.
setName
(
StringUtil
.
trimEnd
(
fqName
,
".namespace"
));
configuration
.
MAIN_CLASS_NAME
=
fqName
;
return
settings
;
}
@Override
public
int
compareTo
(
Object
o
)
{
return
PREFERED
;
}
}
idea/src/org/jetbrains/jet/plugin/run/JetRunConfigurationType.java
浏览文件 @
3f2654c1
...
...
@@ -9,6 +9,10 @@ import org.jetbrains.jet.plugin.JetFileType;
* @author yole
*/
public
class
JetRunConfigurationType
extends
ConfigurationTypeBase
{
public
static
JetRunConfigurationType
getInstance
()
{
return
ConfigurationTypeUtil
.
findConfigurationType
(
JetRunConfigurationType
.
class
);
}
public
JetRunConfigurationType
()
{
super
(
"JetRunConfigurationType"
,
"Jet"
,
"Jet"
,
JetFileType
.
INSTANCE
.
getIcon
());
addFactory
(
new
JetRunConfigurationFactory
(
this
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录