Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
d378e4bd
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,体验更适合开发者的 AI 搜索 >>
提交
d378e4bd
编写于
3月 30, 2012
作者:
P
Pavel V. Talanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some hacky API tweaks to conform with new stdlib APIs.
上级
428c517e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
71 addition
and
67 deletion
+71
-67
js/js.libraries/src/stdlib/JUMaps.kt
js/js.libraries/src/stdlib/JUMaps.kt
+5
-0
js/js.translator/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java
...r/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java
+10
-8
js/js.translator/src/org/jetbrains/k2js/config/Config.java
js/js.translator/src/org/jetbrains/k2js/config/Config.java
+2
-1
js/js.translator/testFiles/webDemoExamples2/cases/builder.kt
js/js.translator/testFiles/webDemoExamples2/cases/builder.kt
+54
-58
未找到文件。
js/js.libraries/src/stdlib/JUMaps.kt
0 → 100644
浏览文件 @
d378e4bd
package
kotlin
import
java.util.Map
as
JMap
/** Provides [] access to maps */
fun
<
K
,
V
>
JMap
<
K
,
V
>.
set
(
key
:
K
,
value
:
V
)
=
this
.
put
(
key
,
value
)
js/js.translator/src/org/jetbrains/k2js/analyze/AnalyzerFacadeForJS.java
浏览文件 @
d378e4bd
...
...
@@ -66,11 +66,11 @@ public final class AnalyzerFacadeForJS {
final
ModuleDescriptor
owner
=
new
ModuleDescriptor
(
"<module>"
);
TopDownAnalysisParameters
topDownAnalysisParameters
=
new
TopDownAnalysisParameters
(
notLibFiles
(
config
.
getLibFiles
()),
false
,
false
);
notLibFiles
(
config
.
getLibFiles
()),
false
,
false
);
InjectorForTopDownAnalyzerForJs
injector
=
new
InjectorForTopDownAnalyzerForJs
(
project
,
topDownAnalysisParameters
,
new
ObservableBindingTrace
(
bindingTraceContext
),
owner
,
JetControlFlowDataTraceFactory
.
EMPTY
,
JsConfiguration
.
jsLibConfiguration
(
project
));
project
,
topDownAnalysisParameters
,
new
ObservableBindingTrace
(
bindingTraceContext
),
owner
,
JetControlFlowDataTraceFactory
.
EMPTY
,
JsConfiguration
.
jsLibConfiguration
(
project
));
injector
.
getTopDownAnalyzer
().
analyzeFiles
(
withJsLibAdded
(
files
,
config
));
return
bindingTraceContext
.
getBindingContext
();
...
...
@@ -110,11 +110,11 @@ public final class AnalyzerFacadeForJS {
final
ModuleDescriptor
owner
=
new
ModuleDescriptor
(
"<module>"
);
TopDownAnalysisParameters
topDownAnalysisParameters
=
new
TopDownAnalysisParameters
(
Predicates
.<
PsiFile
>
alwaysTrue
(),
false
,
false
);
Predicates
.<
PsiFile
>
alwaysTrue
(),
false
,
false
);
InjectorForTopDownAnalyzerForJs
injector
=
new
InjectorForTopDownAnalyzerForJs
(
project
,
topDownAnalysisParameters
,
new
ObservableBindingTrace
(
bindingTraceContext
),
owner
,
JetControlFlowDataTraceFactory
.
EMPTY
,
JsConfiguration
.
jsLibConfiguration
(
project
));
project
,
topDownAnalysisParameters
,
new
ObservableBindingTrace
(
bindingTraceContext
),
owner
,
JetControlFlowDataTraceFactory
.
EMPTY
,
JsConfiguration
.
jsLibConfiguration
(
project
));
injector
.
getTopDownAnalyzer
().
analyzeFiles
(
Collections
.
singletonList
(
file
));
return
bindingTraceContext
.
getBindingContext
();
...
...
@@ -135,15 +135,17 @@ public final class AnalyzerFacadeForJS {
@Override
public
void
addDefaultImports
(
@NotNull
Collection
<
JetImportDirective
>
directives
)
{
//TODO: these thing should not be hard-coded like that
directives
.
add
(
JetPsiFactory
.
createImportDirective
(
project
,
new
ImportPath
(
"js.*"
)));
directives
.
add
(
JetPsiFactory
.
createImportDirective
(
project
,
new
ImportPath
(
JetStandardClasses
.
STANDARD_CLASSES_FQNAME
,
true
)));
directives
.
add
(
JetPsiFactory
.
createImportDirective
(
project
,
new
ImportPath
(
"kotlin.*"
)));
}
@Override
public
void
extendNamespaceScope
(
@NotNull
BindingTrace
trace
,
@NotNull
NamespaceDescriptor
namespaceDescriptor
,
@NotNull
WritableScope
namespaceMemberScope
)
{
DefaultModuleConfiguration
.
createStandardConfiguration
(
project
,
true
).
extendNamespaceScope
(
trace
,
namespaceDescriptor
,
namespaceMemberScope
);
DefaultModuleConfiguration
.
createStandardConfiguration
(
project
,
true
)
.
extendNamespaceScope
(
trace
,
namespaceDescriptor
,
namespaceMemberScope
);
}
}
}
js/js.translator/src/org/jetbrains/k2js/config/Config.java
浏览文件 @
d378e4bd
...
...
@@ -44,7 +44,8 @@ public abstract class Config {
"/raphael/raphael.kt"
,
"/html5/canvas.kt"
,
"/html5/files.kt"
,
"/html5/image.kt"
"/html5/image.kt"
,
"/stdlib/JUMaps.kt"
);
protected
static
final
String
LIBRARIES_LOCATION
=
"js/js.libraries/src"
;
...
...
js/js.translator/testFiles/webDemoExamples2/cases/builder.kt
浏览文件 @
d378e4bd
...
...
@@ -7,42 +7,41 @@
* See this page for details:
* http://confluence.jetbrains.net/display/Kotlin/Type-safe+Groovy-style+builders
*/
import
js.*
import
java.util.*
fun
main
(
args
:
Array
<
String
>)
{
val
result
=
html
{
head
{
title
{+
"XML encoding with Kotlin"
}
}
body
{
h1
{+
"XML encoding with Kotlin"
}
p
{+
"this format can be used as an alternative markup to XML"
}
// an element with attributes and text content
a
(
href
=
"http://jetbrains.com/kotlin"
)
{+
"Kotlin"
}
// mixed content
p
{
+
"This is some"
b
{+
"mixed"
}
+
"text. For more see the"
a
(
href
=
"http://jetbrains.com/kotlin"
)
{+
"Kotlin"
}
+
"project"
}
p
{+
"some text"
}
// content generated from command-line arguments
p
{
+
"Command line arguments were:"
ul
{
for
(
arg
in
args
)
li
{+
arg
}
}
}
html
{
head
{
title
{+
"XML encoding with Kotlin"
}
}
body
{
h1
{+
"XML encoding with Kotlin"
}
p
{+
"this format can be used as an alternative markup to XML"
}
// an element with attributes and text content
a
(
href
=
"http://jetbrains.com/kotlin"
)
{+
"Kotlin"
}
// mixed content
p
{
+
"This is some"
b
{+
"mixed"
}
+
"text. For more see the"
a
(
href
=
"http://jetbrains.com/kotlin"
)
{+
"Kotlin"
}
+
"project"
}
p
{+
"some text"
}
// content generated from command-line arguments
p
{
+
"Command line arguments were:"
ul
{
for
(
arg
in
args
)
li
{+
arg
}
}
}
}
}
println
(
result
)
}
...
...
@@ -50,15 +49,15 @@ trait Element {
fun
render
(
builder
:
StringBuilder
,
indent
:
String
)
fun
toString
()
:
String
?
{
val
builder
=
StringBuilder
()
render
(
builder
,
""
)
return
builder
.
toString
()
val
builder
=
StringBuilder
()
render
(
builder
,
""
)
return
builder
.
toString
()
}
}
class
TextElement
(
val
text
:
String
)
:
Element
{
override
fun
render
(
builder
:
StringBuilder
,
indent
:
String
)
{
builder
.
append
(
"$indent$text\n"
)
builder
.
append
(
"$indent$text\n"
)
}
}
...
...
@@ -67,31 +66,31 @@ abstract class Tag(val name : String) : Element {
val
attributes
=
HashMap
<
String
,
String
>()
protected
fun
initTag
<
T
:
Element
>(
tag
:
T
,
init
:
T
.()
->
Unit
)
:
T
{
tag
.
init
()
children
.
add
(
tag
)
return
tag
tag
.
init
()
children
.
add
(
tag
)
return
tag
}
override
fun
render
(
builder
:
StringBuilder
,
indent
:
String
)
{
builder
.
append
(
"$indent<$name${renderAttributes()}>\n"
)
for
(
c
in
children
)
{
c
.
render
(
builder
,
indent
+
" "
)
}
builder
.
append
(
"$indent</$name>\n"
)
builder
.
append
(
"$indent<$name${renderAttributes()}>\n"
)
for
(
c
in
children
)
{
c
?
.
render
(
builder
,
indent
+
" "
)
}
builder
.
append
(
"$indent</$name>\n"
)
}
private
fun
renderAttributes
()
:
String
?
{
val
builder
=
StringBuilder
()
for
(
a
in
attributes
.
keySet
())
{
builder
.
append
(
" $a=\"${attributes[a]}\""
)
}
return
builder
.
toString
()
val
builder
=
StringBuilder
()
for
(
a
in
attributes
.
keySet
())
{
builder
.
append
(
" $a=\"${attributes[a]}\""
)
}
return
builder
.
toString
()
}
}
abstract
class
TagWithText
(
name
:
String
)
:
Tag
(
name
)
{
fun
String
.
plus
()
{
children
.
add
(
TextElement
(
this
))
children
.
add
(
TextElement
(
this
))
}
}
...
...
@@ -113,8 +112,8 @@ abstract class BodyTag(name : String) : TagWithText(name) {
fun
h1
(
init
:
H1
.()
->
Unit
)
=
initTag
(
H1
(),
init
)
fun
ul
(
init
:
UL
.()
->
Unit
)
=
initTag
(
UL
(),
init
)
fun
a
(
href
:
String
,
init
:
A
.()
->
Unit
)
{
val
a
=
initTag
(
A
(),
init
)
a
.
href
=
href
val
a
=
initTag
(
A
(),
init
)
a
.
href
=
href
}
}
...
...
@@ -129,17 +128,14 @@ class P() : BodyTag("p")
class
H1
()
:
BodyTag
(
"h1"
)
class
A
()
:
BodyTag
(
"a"
)
{
public
var
href
:
String
get
()
=
attributes
[
"href"
]
set
(
value
)
{
attributes
[
"href"
]
=
value
}
get
()
=
attributes
[
"href"
].
sure
()
set
(
value
)
{
attributes
[
"href"
]
=
value
}
}
fun
html
(
init
:
HTML
.()
->
Unit
)
:
HTML
{
val
html
=
HTML
()
html
.
init
()
return
html
}
// An excerpt from the Standard Library
fun
<
K
,
V
>
Map
<
K
,
V
>.
set
(
key
:
K
,
value
:
V
)
=
this
.
put
(
key
,
value
)
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录