Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
d7cb2f24
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,发现更多精彩内容 >>
提交
d7cb2f24
编写于
5月 03, 2012
作者:
S
Stepan Koltsov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve idea classes
上级
28dc1ba6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
16 deletion
+64
-16
compiler/tests/org/jetbrains/jet/cli/jvm/compiler/longTest/ResolveDescriptorsFromExternalLibraries.java
...ler/longTest/ResolveDescriptorsFromExternalLibraries.java
+64
-16
未找到文件。
compiler/tests/org/jetbrains/jet/cli/jvm/compiler/longTest/ResolveDescriptorsFromExternalLibraries.java
浏览文件 @
d7cb2f24
...
...
@@ -16,6 +16,7 @@
package
org.jetbrains.jet.cli.jvm.compiler.longTest
;
import
com.google.common.collect.Lists
;
import
com.google.common.io.ByteStreams
;
import
com.intellij.openapi.Disposable
;
import
com.intellij.openapi.util.Disposer
;
...
...
@@ -41,6 +42,8 @@ import java.io.FileInputStream;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
...
...
@@ -51,24 +54,54 @@ public class ResolveDescriptorsFromExternalLibraries {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
ResolveDescriptorsFromExternalLibraries
().
run
();
boolean
hasErrors
=
new
ResolveDescriptorsFromExternalLibraries
().
run
();
System
.
out
.
println
(
"$"
);
if
(
hasErrors
)
{
System
.
exit
(
1
);
}
}
private
static
List
<
File
>
findJarsInDirectory
(
@NotNull
File
directory
)
{
List
<
File
>
r
=
Lists
.
newArrayList
();
List
<
File
>
stack
=
Lists
.
newArrayList
();
stack
.
add
(
directory
);
while
(!
stack
.
isEmpty
())
{
File
file
=
stack
.
get
(
stack
.
size
()
-
1
);
stack
.
remove
(
stack
.
size
()
-
1
);
if
(
file
.
isFile
()
&&
file
.
getName
().
endsWith
(
".jar"
))
{
r
.
add
(
file
);
}
File
[]
children
=
file
.
listFiles
();
if
(
children
!=
null
)
{
stack
.
addAll
(
Arrays
.
asList
(
children
));
}
}
return
r
;
}
private
void
run
()
throws
Exception
{
testLibraryFile
(
null
,
"rt.jar"
);
testLibrary
(
"com.google.guava"
,
"guava"
,
"12.0-rc2"
);
testLibrary
(
"org.springframework"
,
"spring-core"
,
"3.1.1.RELEASE"
);
private
boolean
run
()
throws
Exception
{
boolean
hasErrors
=
false
;
hasErrors
|=
testLibraryFile
(
null
,
"rt.jar"
);
for
(
File
jar
:
findJarsInDirectory
(
new
File
(
"ideaSDK"
)))
{
hasErrors
|=
testLibraryFile
(
jar
,
jar
.
getPath
());
}
hasErrors
|=
testLibrary
(
"com.google.guava"
,
"guava"
,
"12.0-rc2"
);
hasErrors
|=
testLibrary
(
"org.springframework"
,
"spring-core"
,
"3.1.1.RELEASE"
);
return
hasErrors
;
}
private
void
testLibrary
(
@NotNull
String
org
,
@NotNull
String
module
,
@NotNull
String
rev
)
throws
Exception
{
private
boolean
testLibrary
(
@NotNull
String
org
,
@NotNull
String
module
,
@NotNull
String
rev
)
throws
Exception
{
LibFromMaven
lib
=
new
LibFromMaven
(
org
,
module
,
rev
);
File
jar
=
getLibrary
(
lib
);
testLibraryFile
(
jar
,
lib
.
toString
());
return
testLibraryFile
(
jar
,
lib
.
toString
());
}
private
void
testLibraryFile
(
@Nullable
File
jar
,
@NotNull
String
libDescription
)
throws
IOException
{
private
boolean
testLibraryFile
(
@Nullable
File
jar
,
@NotNull
String
libDescription
)
throws
IOException
{
System
.
out
.
println
(
"Testing library "
+
libDescription
+
"..."
);
if
(
jar
!=
null
)
{
System
.
out
.
println
(
"Using file "
+
jar
);
...
...
@@ -99,9 +132,13 @@ public class ResolveDescriptorsFromExternalLibraries {
InjectorForJavaSemanticServices
injector
=
new
InjectorForJavaSemanticServices
(
jetCoreEnvironment
.
getCompilerDependencies
(),
jetCoreEnvironment
.
getProject
());
FileInputStream
is
=
new
FileInputStream
(
jar
);
boolean
hasErrors
;
try
{
ZipInputStream
zip
=
new
ZipInputStream
(
is
);
for
(;;)
{
hasErrors
=
false
;
for
(;
;
)
{
ZipEntry
entry
=
zip
.
getNextEntry
();
if
(
entry
==
null
)
{
break
;
...
...
@@ -117,14 +154,23 @@ public class ResolveDescriptorsFromExternalLibraries {
continue
;
}
String
className
=
entryName
.
substring
(
0
,
entryName
.
length
()
-
".class"
.
length
()).
replace
(
"/"
,
"."
);
ClassDescriptor
clazz
=
injector
.
getJavaDescriptorResolver
().
resolveClass
(
new
FqName
(
className
),
DescriptorSearchRule
.
ERROR_IF_FOUND_IN_KOTLIN
);
if
(
clazz
==
null
)
{
throw
new
IllegalStateException
(
"class not found by name "
+
className
+
" in "
+
libDescription
);
try
{
ClassDescriptor
clazz
=
injector
.
getJavaDescriptorResolver
().
resolveClass
(
new
FqName
(
className
),
DescriptorSearchRule
.
ERROR_IF_FOUND_IN_KOTLIN
);
if
(
clazz
==
null
)
{
throw
new
IllegalStateException
(
"class not found by name "
+
className
+
" in "
+
libDescription
);
}
clazz
.
getDefaultType
().
getMemberScope
().
getAllDescriptors
();
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"failed to resolve "
+
className
);
e
.
printStackTrace
();
//throw new RuntimeException("failed to resolve " + className + ": " + e, e);
hasErrors
=
true
;
}
clazz
.
getDefaultType
().
getMemberScope
().
getAllDescriptors
();
}
}
finally
{
}
finally
{
try
{
is
.
close
();
}
...
...
@@ -133,7 +179,9 @@ public class ResolveDescriptorsFromExternalLibraries {
Disposer
.
dispose
(
junk
);
}
System
.
out
.
println
(
"Testing library "
+
libDescription
+
" done in "
+
TimeUtils
.
millisecondsToSecondsString
(
System
.
currentTimeMillis
()
-
start
)
+
"s"
);
System
.
out
.
println
(
"Testing library "
+
libDescription
+
" done in "
+
TimeUtils
.
millisecondsToSecondsString
(
System
.
currentTimeMillis
()
-
start
)
+
"s "
+
(
hasErrors
?
"with"
:
"without"
)
+
" errors"
);
return
hasErrors
;
}
@NotNull
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录