Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
abfd03ca
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,发现更多精彩内容 >>
提交
abfd03ca
编写于
4月 09, 2012
作者:
S
Stepan Koltsov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
descriptor name cannot be empty string
* add assertion * fix tests * #KT-1748 Fixed
上级
5ec31b8c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
69 addition
and
43 deletion
+69
-43
compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java
.../backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java
+8
-6
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java
...jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java
+5
-1
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java
...rains/jet/lang/descriptors/DeclarationDescriptorImpl.java
+5
-0
compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java
...nd/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java
+5
-0
compiler/frontend/src/org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java
.../org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java
+14
-5
compiler/testData/renderer/FunctionTypes.kt
compiler/testData/renderer/FunctionTypes.kt
+8
-8
compiler/testData/renderer/TupleTypes.kt
compiler/testData/renderer/TupleTypes.kt
+10
-10
js/js.translator/src/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.java
...translate/declaration/NamespaceDeclarationTranslator.java
+3
-3
js/js.translator/src/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.java
...rains/k2js/translate/declaration/NamespaceTranslator.java
+4
-0
js/js.translator/src/org/jetbrains/k2js/translate/utils/JsDescriptorUtils.java
...org/jetbrains/k2js/translate/utils/JsDescriptorUtils.java
+7
-10
未找到文件。
compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java
浏览文件 @
abfd03ca
...
...
@@ -263,6 +263,14 @@ public class JetTypeMapper {
return
getFQName
(
descriptor
.
getContainingDeclaration
());
}
if
(
descriptor
.
getContainingDeclaration
()
instanceof
ModuleDescriptor
)
{
return
""
;
}
if
(
descriptor
instanceof
ModuleDescriptor
)
{
throw
new
IllegalStateException
(
"missed something"
);
}
DeclarationDescriptor
container
=
descriptor
.
getContainingDeclaration
();
String
name
=
descriptor
.
getName
();
if
(
JetPsiUtil
.
NO_NAME_PROVIDED
.
equals
(
name
))
{
...
...
@@ -271,12 +279,6 @@ public class JetTypeMapper {
if
(
name
.
contains
(
"/"
))
return
name
;
if
(
container
!=
null
)
{
if
(
container
.
getContainingDeclaration
()
instanceof
ModuleDescriptor
)
{
return
name
;
}
if
(
container
instanceof
ModuleDescriptor
)
{
throw
new
IllegalStateException
(
"missed something"
);
}
String
baseName
=
getFQName
(
container
);
if
(!
baseName
.
isEmpty
())
{
return
baseName
+
(
container
instanceof
NamespaceDescriptor
?
"/"
:
"$"
)
+
name
;
...
...
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java
浏览文件 @
abfd03ca
...
...
@@ -29,7 +29,11 @@ import java.util.List;
public
abstract
class
AbstractNamespaceDescriptorImpl
extends
DeclarationDescriptorImpl
implements
NamespaceDescriptor
{
private
NamespaceType
namespaceType
;
public
AbstractNamespaceDescriptorImpl
(
@NotNull
NamespaceDescriptorParent
containingDeclaration
,
List
<
AnnotationDescriptor
>
annotations
,
String
name
)
{
public
AbstractNamespaceDescriptorImpl
(
@NotNull
NamespaceDescriptorParent
containingDeclaration
,
List
<
AnnotationDescriptor
>
annotations
,
@NotNull
String
name
)
{
super
(
containingDeclaration
,
annotations
,
name
);
boolean
rootAccordingToContainer
=
containingDeclaration
instanceof
ModuleDescriptor
;
...
...
compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java
浏览文件 @
abfd03ca
...
...
@@ -34,6 +34,11 @@ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements
public
DeclarationDescriptorImpl
(
@Nullable
DeclarationDescriptor
containingDeclaration
,
@NotNull
List
<
AnnotationDescriptor
>
annotations
,
@NotNull
String
name
)
{
super
(
annotations
);
if
(
name
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"descriptor name cannot be empty string"
);
}
this
.
name
=
name
;
this
.
containingDeclaration
=
containingDeclaration
;
}
...
...
compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java
浏览文件 @
abfd03ca
...
...
@@ -72,9 +72,14 @@ public class JetNamespaceHeader extends JetReferenceExpression {
}
@Override
@NotNull
public
String
getName
()
{
PsiElement
nameIdentifier
=
getNameIdentifier
();
return
nameIdentifier
==
null
?
""
:
nameIdentifier
.
getText
();
}
public
boolean
isRoot
()
{
return
getName
().
length
()
==
0
;
}
}
compiler/frontend/src/org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java
浏览文件 @
abfd03ca
...
...
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.ModuleConfiguration
;
import
org.jetbrains.jet.lang.descriptors.ModuleDescriptor
;
import
org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
;
import
org.jetbrains.jet.lang.descriptors.NamespaceDescriptorImpl
;
import
org.jetbrains.jet.lang.descriptors.NamespaceDescriptorParent
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
...
...
@@ -85,12 +86,20 @@ public class NamespaceFactoryImpl implements NamespaceFactory {
currentOwner
=
namespaceDescriptor
;
}
String
name
=
JetPsiUtil
.
safeName
(
namespaceHeader
.
getName
());
NamespaceDescriptorImpl
namespaceDescriptor
=
createNamespaceDescriptorIfNeeded
(
file
,
currentOwner
,
name
,
false
,
namespaceHeader
.
getLastPartExpression
());
NamespaceDescriptorImpl
namespaceDescriptor
;
String
name
;
if
(
namespaceHeader
.
isRoot
())
{
// again to register file in trace
namespaceDescriptor
=
createNamespaceDescriptorIfNeeded
(
file
,
moduleDescriptor
,
"<root>"
,
true
,
null
);
}
else
{
name
=
namespaceHeader
.
getName
();
namespaceDescriptor
=
createNamespaceDescriptorIfNeeded
(
file
,
currentOwner
,
name
,
namespaceHeader
.
isRoot
(),
namespaceHeader
.
getLastPartExpression
());
trace
.
record
(
BindingContext
.
NAMESPACE_IS_SRC
,
namespaceDescriptor
,
true
);
trace
.
record
(
RESOLUTION_SCOPE
,
namespaceHeader
,
outerScope
);
trace
.
record
(
BindingContext
.
NAMESPACE_IS_SRC
,
namespaceDescriptor
,
true
);
trace
.
record
(
RESOLUTION_SCOPE
,
namespaceHeader
,
outerScope
);
}
return
namespaceDescriptor
;
}
...
...
compiler/testData/renderer/FunctionTypes.kt
浏览文件 @
abfd03ca
...
...
@@ -8,11 +8,11 @@ var v6 : Int.(String, Int) -> Unit
var
v7
:
ExtensionFunction1
<
Int
,
String
,
Boolean
>
//internal final var v1 : () -> Unit defined in <module>.<root>
.
//internal final var v2 : (jet.Int) -> jet.Int defined in <module>.<root>
.
//internal final var v3 : (jet.Int, #(jet.String, jet.String)) -> jet.String defined in <module>.<root>
.
//internal final var v4 : (jet.Int) -> jet.String defined in <module>.<root>
.
//internal final var v4 : (() -> jet.Int, (#(jet.String, jet.String)) -> Unit) -> jet.String defined in <module>.<root>
.
//internal final var v5 : jet.Int.() -> jet.Int defined in <module>.<root>
.
//internal final var v6 : jet.Int.(jet.String, jet.Int) -> Unit defined in <module>.<root>
.
//internal final var v7 : jet.Int.(jet.String) -> jet.Boolean defined in <module>.<root>
.
//internal final var v1 : () -> Unit defined in <module>.<root>
//internal final var v2 : (jet.Int) -> jet.Int defined in <module>.<root>
//internal final var v3 : (jet.Int, #(jet.String, jet.String)) -> jet.String defined in <module>.<root>
//internal final var v4 : (jet.Int) -> jet.String defined in <module>.<root>
//internal final var v4 : (() -> jet.Int, (#(jet.String, jet.String)) -> Unit) -> jet.String defined in <module>.<root>
//internal final var v5 : jet.Int.() -> jet.Int defined in <module>.<root>
//internal final var v6 : jet.Int.(jet.String, jet.Int) -> Unit defined in <module>.<root>
//internal final var v7 : jet.Int.(jet.String) -> jet.Boolean defined in <module>.<root>
compiler/testData/renderer/TupleTypes.kt
浏览文件 @
abfd03ca
...
...
@@ -9,13 +9,13 @@ var v8 : #(Int, String, String)
var
v9
:
Tuple2
<
Int
,
String
>
var
v10
:
Tuple3
<
Int
,
Int
,
Int
>?
//internal final var v1 : Unit defined in <module>.<root>.
//internal final var v2 : Unit? defined in <module>.<root>.
//internal final var v3 : Unit defined in <module>.<root>.
//internal final var v4 : Unit? defined in <module>.<root>.
//internal final var v5 : Unit defined in <module>.<root>.
//internal final var v6 : #(jet.Int) defined in <module>.<root>.
//internal final var v7 : #(jet.Int)? defined in <module>.<root>.
//internal final var v8 : #(jet.Int, jet.String, jet.String) defined in <module>.<root>.
//internal final var v9 : #(jet.Int, jet.String) defined in <module>.<root>.
//internal final var v10 : #(jet.Int, jet.Int, jet.Int)? defined in <module>.<root>.
\ No newline at end of file
//internal final var v1 : Unit defined in <module>.<root>
//internal final var v2 : Unit? defined in <module>.<root>
//internal final var v3 : Unit defined in <module>.<root>
//internal final var v4 : Unit? defined in <module>.<root>
//internal final var v5 : Unit defined in <module>.<root>
//internal final var v6 : #(jet.Int) defined in <module>.<root>
//internal final var v7 : #(jet.Int)? defined in <module>.<root>
//internal final var v8 : #(jet.Int, jet.String, jet.String) defined in <module>.<root>
//internal final var v9 : #(jet.Int, jet.String) defined in <module>.<root>
//internal final var v10 : #(jet.Int, jet.Int, jet.Int)? defined in <module>.<root>
js/js.translator/src/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.java
浏览文件 @
abfd03ca
...
...
@@ -95,7 +95,7 @@ public final class NamespaceDeclarationTranslator extends AbstractTranslator {
@NotNull
private
List
<
NamespaceTranslator
>
getTranslatorsForNonEmptyNamespaces
()
{
List
<
NamespaceTranslator
>
namespaceTranslators
=
Lists
.
newArrayList
();
for
(
NamespaceDescriptor
descriptor
:
filterNonEmptyNamespaces
(
filterTopLevelNamespaces
(
namespaceDescriptors
)))
{
for
(
NamespaceDescriptor
descriptor
:
filterNonEmptyNamespaces
(
filterTopLevel
AndRoot
Namespaces
(
namespaceDescriptors
)))
{
namespaceTranslators
.
add
(
new
NamespaceTranslator
(
descriptor
,
classDeclarationTranslator
,
context
()));
}
return
namespaceTranslators
;
...
...
@@ -123,10 +123,10 @@ public final class NamespaceDeclarationTranslator extends AbstractTranslator {
}
@NotNull
private
static
List
<
NamespaceDescriptor
>
filterTopLevelNamespaces
(
@NotNull
List
<
NamespaceDescriptor
>
namespaceDescriptors
)
{
private
static
List
<
NamespaceDescriptor
>
filterTopLevel
AndRoot
Namespaces
(
@NotNull
List
<
NamespaceDescriptor
>
namespaceDescriptors
)
{
List
<
NamespaceDescriptor
>
result
=
Lists
.
newArrayList
();
for
(
NamespaceDescriptor
descriptor
:
namespaceDescriptors
)
{
if
(
JsDescriptorUtils
.
isTopLevelNamespace
(
descriptor
))
{
if
(
JsDescriptorUtils
.
isTopLevelNamespace
(
descriptor
)
||
JsDescriptorUtils
.
isRootNamespace
(
descriptor
)
)
{
result
.
add
(
descriptor
);
}
}
...
...
js/js.translator/src/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.java
浏览文件 @
abfd03ca
...
...
@@ -21,6 +21,7 @@ import com.google.dart.compiler.backend.js.ast.*;
import
com.google.dart.compiler.util.AstUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
;
import
org.jetbrains.jet.lang.resolve.DescriptorUtils
;
import
org.jetbrains.k2js.translate.context.TranslationContext
;
import
org.jetbrains.k2js.translate.general.AbstractTranslator
;
import
org.jetbrains.k2js.translate.general.Translation
;
...
...
@@ -96,6 +97,9 @@ public final class NamespaceTranslator extends AbstractTranslator {
@NotNull
private
List
<
JsPropertyInitializer
>
getNestedNamespaceDeclarations
()
{
if
(
JsDescriptorUtils
.
isRootNamespace
(
descriptor
))
{
return
Lists
.
newArrayList
();
}
List
<
JsPropertyInitializer
>
result
=
Lists
.
newArrayList
();
List
<
NamespaceDescriptor
>
nestedNamespaces
=
JsDescriptorUtils
.
getNestedNamespaces
(
descriptor
);
for
(
NamespaceDescriptor
nestedNamespace
:
nestedNamespaces
)
{
...
...
js/js.translator/src/org/jetbrains/k2js/translate/utils/JsDescriptorUtils.java
浏览文件 @
abfd03ca
...
...
@@ -152,10 +152,7 @@ public final class JsDescriptorUtils {
@NotNull
public
static
String
getNameForNamespace
(
@NotNull
NamespaceDescriptor
descriptor
)
{
//if (descriptor.getContainingDeclaration() instanceof ModuleDescriptor) {
// return Namer.getAnonymousNamespaceName();
//} else
if
(
descriptor
.
getName
().
isEmpty
())
{
if
(
descriptor
.
getContainingDeclaration
()
instanceof
ModuleDescriptor
)
{
return
Namer
.
getAnonymousNamespaceName
();
}
else
{
...
...
@@ -240,12 +237,12 @@ public final class JsDescriptorUtils {
}
public
static
boolean
isTopLevelNamespace
(
@NotNull
NamespaceDescriptor
namespaceDescriptor
)
{
NamespaceDescriptorParent
containingDeclaration
=
namespaceDescriptor
.
getContainingDeclaration
();
boolean
containedInModule
=
!(
containingDeclaration
instanceof
NamespaceDescriptor
)
;
if
(
containedInModule
)
{
return
true
;
}
return
containingDeclaration
.
getContainingDeclaration
()
instanceof
ModuleDescriptor
;
return
namespaceDescriptor
.
getContainingDeclaration
()
instanceof
NamespaceDescriptor
&&
namespaceDescriptor
.
getContainingDeclaration
().
getContainingDeclaration
()
instanceof
ModuleDescriptor
;
}
public
static
boolean
isRootNamespace
(
@NotNull
NamespaceDescriptor
namespaceDescriptor
)
{
return
namespaceDescriptor
.
getContainingDeclaration
()
instanceof
ModuleDescriptor
;
}
@NotNull
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录