Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
d4d9ac7b
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,发现更多精彩内容 >>
提交
d4d9ac7b
编写于
4月 01, 2011
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Null checks
上级
48fdfc54
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
33 addition
and
18 deletion
+33
-18
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java
...c/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java
+21
-7
idea/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java
idea/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java
+5
-0
idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java
...g/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java
+7
-11
未找到文件。
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java
浏览文件 @
d4d9ac7b
...
...
@@ -34,7 +34,7 @@ public class JetControlFlowProcessor {
public
void
generateSubroutineControlFlow
(
@NotNull
JetElement
subroutineElement
,
@NotNull
List
<?
extends
JetElement
>
body
,
boolean
preferBlocks
)
{
if
(
subroutineElement
instanceof
JetNamedDeclaration
)
{
JetNamedDeclaration
namedDeclaration
=
(
JetNamedDeclaration
)
subroutineElement
;
enterLabeledElement
(
namedDeclaration
.
getName
(
),
namedDeclaration
);
enterLabeledElement
(
JetPsiUtil
.
safeName
(
namedDeclaration
.
getName
()
),
namedDeclaration
);
}
boolean
functionLiteral
=
subroutineElement
instanceof
JetFunctionLiteralExpression
;
builder
.
enterSubroutine
(
subroutineElement
,
functionLiteral
);
...
...
@@ -107,7 +107,10 @@ public class JetControlFlowProcessor {
@Override
public
void
visitParenthesizedExpression
(
JetParenthesizedExpression
expression
)
{
value
(
expression
.
getExpression
(),
false
);
JetExpression
innerExpression
=
expression
.
getExpression
();
if
(
innerExpression
!=
null
)
{
value
(
innerExpression
,
false
);
}
}
@Override
...
...
@@ -129,8 +132,10 @@ public class JetControlFlowProcessor {
public
void
visitLabelQualifiedExpression
(
JetLabelQualifiedExpression
expression
)
{
String
labelName
=
expression
.
getLabelName
();
JetExpression
labeledExpression
=
expression
.
getLabeledExpression
();
if
(
labelName
!=
null
&&
labeledExpression
!=
null
)
{
visitLabeledExpression
(
labelName
,
labeledExpression
);
}
}
private
void
visitLabeledExpression
(
@NotNull
String
labelName
,
@NotNull
JetExpression
labeledExpression
)
{
JetExpression
deparenthesized
=
JetPsiUtil
.
deparenthesize
(
labeledExpression
);
...
...
@@ -143,23 +148,30 @@ public class JetControlFlowProcessor {
@Override
public
void
visitBinaryExpression
(
JetBinaryExpression
expression
)
{
IElementType
operationType
=
expression
.
getOperationReference
().
getReferencedNameElementType
();
JetExpression
right
=
expression
.
getRight
();
if
(
operationType
==
JetTokens
.
ANDAND
)
{
value
(
expression
.
getLeft
(),
false
);
Label
resultLabel
=
builder
.
createUnboundLabel
();
builder
.
jumpOnFalse
(
resultLabel
);
value
(
expression
.
getRight
(),
false
);
if
(
right
!=
null
)
{
value
(
right
,
false
);
}
builder
.
bindLabel
(
resultLabel
);
}
else
if
(
operationType
==
JetTokens
.
OROR
)
{
value
(
expression
.
getLeft
(),
false
);
Label
resultLabel
=
builder
.
createUnboundLabel
();
builder
.
jumpOnTrue
(
resultLabel
);
value
(
expression
.
getRight
(),
false
);
if
(
right
!=
null
)
{
value
(
right
,
false
);
}
builder
.
bindLabel
(
resultLabel
);
}
else
{
value
(
expression
.
getLeft
(),
false
);
value
(
expression
.
getRight
(),
false
);
if
(
right
!=
null
)
{
value
(
right
,
false
);
}
builder
.
readNode
(
expression
);
}
}
...
...
@@ -168,7 +180,9 @@ public class JetControlFlowProcessor {
public
void
visitUnaryExpression
(
JetUnaryExpression
expression
)
{
IElementType
operationType
=
expression
.
getOperationSign
().
getReferencedNameElementType
();
if
(
JetTokens
.
LABELS
.
contains
(
operationType
))
{
visitLabeledExpression
(
expression
.
getOperationSign
().
getReferencedName
().
substring
(
1
),
expression
.
getBaseExpression
());
String
referencedName
=
expression
.
getOperationSign
().
getReferencedName
();
referencedName
=
referencedName
==
null
?
" <?>"
:
referencedName
;
visitLabeledExpression
(
referencedName
.
substring
(
1
),
expression
.
getBaseExpression
());
}
else
{
visitElement
(
expression
);
...
...
idea/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java
浏览文件 @
d4d9ac7b
...
...
@@ -15,4 +15,9 @@ public class JetPsiUtil {
}
return
result
;
}
@NotNull
public
static
String
safeName
(
String
name
)
{
return
name
==
null
?
"<no name provided>"
:
name
;
}
}
idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java
浏览文件 @
d4d9ac7b
...
...
@@ -30,7 +30,7 @@ public class ClassDescriptorResolver {
ClassDescriptorImpl
classDescriptor
=
new
ClassDescriptorImpl
(
scope
.
getContainingDeclaration
(),
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
classElement
.
getModifierList
()),
safeName
(
classElement
.
getName
()));
JetPsiUtil
.
safeName
(
classElement
.
getName
()));
trace
.
recordDeclarationResolution
(
classElement
,
classDescriptor
);
...
...
@@ -81,7 +81,7 @@ public class ClassDescriptorResolver {
descriptor
,
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
classElement
.
getModifierList
()),
!
open
,
safeName
(
classElement
.
getName
()),
JetPsiUtil
.
safeName
(
classElement
.
getName
()),
typeParameters
,
supertypes
);
descriptor
.
setTypeConstructor
(
...
...
@@ -157,7 +157,7 @@ public class ClassDescriptorResolver {
FunctionDescriptorImpl
functionDescriptor
=
new
FunctionDescriptorImpl
(
containingDescriptor
,
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
function
.
getModifierList
()),
safeName
(
function
.
getName
())
JetPsiUtil
.
safeName
(
function
.
getName
())
);
WritableScope
innerScope
=
semanticServices
.
createWritableScope
(
scope
,
functionDescriptor
);
innerScope
.
addLabeledDeclaration
(
functionDescriptor
);
...
...
@@ -216,7 +216,7 @@ public class ClassDescriptorResolver {
functionDescriptor
,
i
,
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
valueParameter
.
getModifierList
()),
safeName
(
valueParameter
.
getName
()),
JetPsiUtil
.
safeName
(
valueParameter
.
getName
()),
valueParameter
.
isMutable
()
?
type
:
null
,
type
,
valueParameter
.
getDefaultValue
()
!=
null
,
...
...
@@ -250,7 +250,7 @@ public class ClassDescriptorResolver {
containingDescriptor
,
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
typeParameter
.
getModifierList
()),
typeParameter
.
getVariance
(),
safeName
(
typeParameter
.
getName
()),
JetPsiUtil
.
safeName
(
typeParameter
.
getName
()),
Collections
.
singleton
(
bound
),
bound
);
...
...
@@ -299,7 +299,7 @@ public class ClassDescriptorResolver {
PropertyDescriptor
propertyDescriptor
=
new
PropertyDescriptorImpl
(
containingDeclaration
,
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
parameter
.
getModifierList
()),
safeName
(
parameter
.
getName
()),
JetPsiUtil
.
safeName
(
parameter
.
getName
()),
parameter
.
isMutable
()
?
null
:
type
,
type
);
trace
.
recordDeclarationResolution
(
parameter
,
propertyDescriptor
);
...
...
@@ -327,7 +327,7 @@ public class ClassDescriptorResolver {
PropertyDescriptorImpl
propertyDescriptor
=
new
PropertyDescriptorImpl
(
containingDeclaration
,
AttributeResolver
.
INSTANCE
.
resolveAttributes
(
property
.
getModifierList
()),
safeName
(
property
.
getName
()),
JetPsiUtil
.
safeName
(
property
.
getName
()),
property
.
isVar
()
?
type
:
null
,
type
);
trace
.
recordDeclarationResolution
(
property
,
propertyDescriptor
);
...
...
@@ -397,8 +397,4 @@ public class ClassDescriptorResolver {
return
propertyDescriptor
;
}
@NotNull
private
static
String
safeName
(
String
name
)
{
return
name
==
null
?
"<no name provided>"
:
name
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录