Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
5c8e4958
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,发现更多精彩内容 >>
提交
5c8e4958
编写于
6月 04, 2018
作者:
N
Nicolay Mitropolsky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Uast: exposing enum constants literal values (#KT-23456)
上级
12707a64
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
35 addition
and
21 deletion
+35
-21
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt
...n/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt
+4
-0
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172
...c/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172
+4
-0
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt
...org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt
+7
-5
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172
...jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172
+7
-9
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.173
...jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.173
+6
-4
plugins/uast-kotlin/testData/EnumValueMembers.log.txt
plugins/uast-kotlin/testData/EnumValueMembers.log.txt
+1
-0
plugins/uast-kotlin/testData/EnumValueMembers.log.txt.172
plugins/uast-kotlin/testData/EnumValueMembers.log.txt.172
+1
-0
plugins/uast-kotlin/testData/EnumValueMembers.render.txt
plugins/uast-kotlin/testData/EnumValueMembers.render.txt
+1
-1
plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172
plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172
+4
-2
未找到文件。
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt
浏览文件 @
5c8e4958
...
...
@@ -163,6 +163,10 @@ fun doConvertParent(element: UElement, parent: PsiElement?): UElement? {
return
result
.
initializingClass
}
if
(
result
is
UCallExpression
&&
result
.
uastParent
is
UEnumConstant
)
{
return
result
.
uastParent
}
if
(
result
is
USwitchClauseExpressionWithBody
&&
!
isInConditionBranch
(
element
,
result
))
{
return
result
.
body
}
...
...
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172
浏览文件 @
5c8e4958
...
...
@@ -133,6 +133,10 @@ fun doConvertParent(element: UElement, parent: PsiElement?): UElement? {
return
result
.
initializingClass
}
if
(
result
is
UCallExpression
&&
result
.
uastParent
is
UEnumConstant
)
{
return
result
.
uastParent
}
if
(
result
is
USwitchClauseExpressionWithBody
&&
!isInConditionBranch(element, result)) {
return
result
.
body
}
...
...
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt
浏览文件 @
5c8e4958
...
...
@@ -430,11 +430,13 @@ class KotlinUEnumConstant(
override
val
valueArgumentCount
:
Int
get
()
=
psi
.
argumentList
?.
expressions
?.
size
?:
0
override
val
valueArguments
by
lz
{
psi
.
argumentList
?.
expressions
?.
map
{
getLanguagePlugin
().
convertElement
(
it
,
this
)
as
?
UExpression
?:
UastEmptyExpression
}
?:
emptyList
()
override
val
valueArguments
by
lz
(
fun
():
List
<
UExpression
>
{
val
ktEnumEntry
=
sourcePsi
as
?
KtEnumEntry
?:
return
emptyList
()
val
ktSuperTypeCallEntry
=
ktEnumEntry
.
initializerList
?.
initializers
?.
firstOrNull
()
as
?
KtSuperTypeCallEntry
?:
return
emptyList
()
return
ktSuperTypeCallEntry
.
valueArguments
.
map
{
it
.
getArgumentExpression
()
?.
let
{
getLanguagePlugin
().
convertElement
(
it
,
this
)
}
as
?
UExpression
?:
UastEmptyExpression
(
this
)
}
})
override
val
returnType
:
PsiType
?
get
()
=
uastParent
?.
getAsJavaPsiElement
(
PsiClass
::
class
.
java
)
?.
let
{
PsiTypesUtil
.
getClassType
(
it
)
}
...
...
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172
浏览文件 @
5c8e4958
...
...
@@ -19,17 +19,13 @@ package org.jetbrains.uast.kotlin
import
com
.
intellij
.
psi
.*
import
org
.
jetbrains
.
kotlin
.
asJava
.
classes
.
KtLightClass
import
org
.
jetbrains
.
kotlin
.
asJava
.
elements
.
KtLightElement
import
org
.
jetbrains
.
kotlin
.
psi
.
KtNamedDeclaration
import
org
.
jetbrains
.
kotlin
.
psi
.
KtParameter
import
org
.
jetbrains
.
kotlin
.
psi
.
KtProperty
import
org
.
jetbrains
.
kotlin
.
psi
.
KtVariableDeclaration
import
org
.
jetbrains
.
kotlin
.
psi
.*
import
org
.
jetbrains
.
uast
.*
import
org
.
jetbrains
.
uast
.
internal
.
acceptList
import
org
.
jetbrains
.
uast
.
java
.
JavaAbstractUExpression
import
org
.
jetbrains
.
uast
.
java
.
JavaUAnnotation
import
org
.
jetbrains
.
uast
.
java
.
annotations
import
org
.
jetbrains
.
uast
.
kotlin
.
declarations
.
UastLightIdentifier
import
org
.
jetbrains
.
uast
.
kotlin
.
internal
.
KotlinUElementWithComments
import
org
.
jetbrains
.
uast
.
kotlin
.
psi
.
UastKotlinPsiParameter
import
org
.
jetbrains
.
uast
.
kotlin
.
psi
.
UastKotlinPsiVariable
import
org
.
jetbrains
.
uast
.
visitor
.
UastVisitor
...
...
@@ -256,11 +252,13 @@ open class KotlinUEnumConstant(
override
val
valueArgumentCount
:
Int
get
()
=
psi
.
argumentList
?.
expressions
?.
size
?:
0
override
val
valueArguments
by
lz
{
psi
.
argumentList
?.
expressions
?.
map
{
getLanguagePlugin
().
convertElement
(
it
,
this
)
as
?
UExpression
?:
UastEmptyExpression
}
?:
emptyList
()
override
val
valueArguments
by
lz
(
fun
():
List
<
UExpression
>
{
val
ktEnumEntry
=
(
psi
as
?
KtLightElement
<*,
*>)?.
kotlinOrigin
as
?
KtEnumEntry
?:
return
emptyList
()
val
ktSuperTypeCallEntry
=
ktEnumEntry
.
initializerList
?.
initializers
?.
firstOrNull
()
as
?
KtSuperTypeCallEntry
?:
return
emptyList
()
return
ktSuperTypeCallEntry
.
valueArguments
.
map
{
it
.
getArgumentExpression
()?.
let
{
getLanguagePlugin
().
convertElement
(
it
,
this
)
}
as
?
UExpression
?:
UastEmptyExpression
}
})
override
val
returnType
:
PsiType
?
get
()
=
psi
.
type
...
...
plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.173
浏览文件 @
5c8e4958
...
...
@@ -411,11 +411,13 @@ class KotlinUEnumConstant(
override
val
valueArgumentCount
:
Int
get
()
=
psi
.
argumentList
?.
expressions
?.
size
?:
0
override
val
valueArguments
by
lz
{
psi
.
argumentList
?.
expressions
?.
map
{
getLanguagePlugin
().
convertElement
(
it
,
this
)
as
?
UExpression
?:
UastEmptyExpression
}
?:
emptyList
()
override
val
valueArguments
by
lz
(
fun
():
List
<
UExpression
>
{
val
ktEnumEntry
=
sourcePsi
as
?
KtEnumEntry
?:
return
emptyList
()
val
ktSuperTypeCallEntry
=
ktEnumEntry
.
initializerList
?.
initializers
?.
firstOrNull
()
as
?
KtSuperTypeCallEntry
?:
return
emptyList
()
return
ktSuperTypeCallEntry
.
valueArguments
.
map
{
it
.
getArgumentExpression
()?.
let
{
getLanguagePlugin
().
convertElement
(
it
,
this
)
}
as
?
UExpression
?:
UastEmptyExpression
}
})
override
val
returnType
:
PsiType
?
get
()
=
uastParent
?.
getAsJavaPsiElement
(
PsiClass
::
class
.
java
)?.
let
{
PsiTypesUtil
.
getClassType
(
it
)
}
...
...
plugins/uast-kotlin/testData/EnumValueMembers.log.txt
浏览文件 @
5c8e4958
...
...
@@ -3,6 +3,7 @@ UFile (package = )
UEnumConstant (name = SHEET)
UAnnotation (fqName = null)
USimpleNameReferenceExpression (identifier = Style)
ULiteralExpression (value = "foo")
UClass (name = null)
UAnnotationMethod (name = getExitAnimation)
UBlockExpression
...
...
plugins/uast-kotlin/testData/EnumValueMembers.log.txt.172
浏览文件 @
5c8e4958
...
...
@@ -2,6 +2,7 @@ UFile (package = )
UClass (name = Style)
UEnumConstant (name = SHEET)
USimpleNameReferenceExpression (identifier = Style)
ULiteralExpression (value = "foo")
UClass (name = null)
UAnnotationMethod (name = getExitAnimation)
UBlockExpression
...
...
plugins/uast-kotlin/testData/EnumValueMembers.render.txt
浏览文件 @
5c8e4958
public enum Style {
@null SHEET {
@null SHEET
("foo")
{
public fun getExitAnimation() : java.lang.String {
return "bar"
}
...
...
plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172
浏览文件 @
5c8e4958
public enum Style {
SHEET {
public fun getExitAnimation() : java.lang.String = "bar"
SHEET("foo") {
public fun getExitAnimation() : java.lang.String {
return "bar"
}
fun SHEET() = UastEmptyExpression
}
private final var value: java.lang.String
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录