yinwang0 / pysonar2 Goto Github PK
View Code? Open in Web Editor NEWPySonar2: a semantic indexer for Python with interprocedual type inference
License: Apache License 2.0
PySonar2: a semantic indexer for Python with interprocedual type inference
License: Apache License 2.0
Thank you for persuading Google to share this promising tool! I am trying to build from commit 59ae0ac under Debian 7.1 amd64 and I am seeing errors as shown below. The environment is as follows:
$ mvn --version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-4-amd64", arch: "amd64", family: "unix"
$ python -V
Python 2.7.3
$ mvn -e clean package
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pysonar2 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.3:clean (default-clean) @ pysonar ---
[INFO] Deleting file set: /home/lgadalla/projects/pysonar2/target (included: [**], excluded: [])
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ pysonar ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pysonar ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 91 source files to /home/lgadalla/projects/pysonar2/target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ProxyParser.java: /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ProxyParser.java uses unchecked or unsafe operations.
[WARNING] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ProxyParser.java: Recompile with -Xlint:unchecked for details.
[INFO] 2 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/NodeVisitor.java:[69,26] cannot find symbol
symbol: class Withitem
location: interface org.yinwang.pysonar.ast.NodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/With.java:[15,17] cannot find symbol
symbol: class Withitem
location: class org.yinwang.pysonar.ast.With
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/With.java:[19,31] cannot find symbol
symbol: class Withitem
location: class org.yinwang.pysonar.ast.With
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[242,26] cannot find symbol
symbol: class Withitem
location: class org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[25,20] name clash: visit(org.yinwang.pysonar.ast.Alias) in org.yinwang.pysonar.ast.DefaultNodeVisitor overrides a method whose erasure is the same as another method, yet neither overrides the other
first method: visit(org.yinwang.pysonar.ast.With) in org.yinwang.pysonar.ast.DefaultNodeVisitor
second method: visit(Withitem) in org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[29,20] name clash: visit(org.yinwang.pysonar.ast.Assert) in org.yinwang.pysonar.ast.DefaultNodeVisitor overrides a method whose erasure is the same as another method, yet neither overrides the other
first method: visit(org.yinwang.pysonar.ast.With) in org.yinwang.pysonar.ast.DefaultNodeVisitor
second method: visit(Withitem) in org.yinwang.pysonar.ast.DefaultNodeVisitor
(many more)
[INFO] 100 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.209s
[INFO] Finished at: Tue Nov 12 09:16:36 PST 2013
[INFO] Final Memory: 11M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project pysonar: Compilation failure: Compilation failure:
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/NodeVisitor.java:[69,26] cannot find symbol
[ERROR] symbol: class Withitem
[ERROR] location: interface org.yinwang.pysonar.ast.NodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/With.java:[15,17] cannot find symbol
[ERROR] symbol: class Withitem
[ERROR] location: class org.yinwang.pysonar.ast.With
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/With.java:[19,31] cannot find symbol
[ERROR] symbol: class Withitem
[ERROR] location: class org.yinwang.pysonar.ast.With
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[242,26] cannot find symbol
[ERROR] symbol: class Withitem
[ERROR] location: class org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[25,20] name clash: visit(org.yinwang.pysonar.ast.Alias) in org.yinwang.pysonar.ast.DefaultNodeVisitor overrides a method whose erasure is the same as another method, yet neither overrides the other
[ERROR] first method: visit(org.yinwang.pysonar.ast.With) in org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] second method: visit(Withitem) in org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[29,20] name clash: visit(org.yinwang.pysonar.ast.Assert) in org.yinwang.pysonar.ast.DefaultNodeVisitor overrides a method whose erasure is the same as another method, yet neither overrides the other
[ERROR] first method: visit(org.yinwang.pysonar.ast.With) in org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] second method: visit(Withitem) in org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] /home/lgadalla/projects/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[33,20] name clash: visit(org.yinwang.pysonar.ast.Assign) in org.yinwang.pysonar.ast.DefaultNodeVisitor overrides a method whose erasure is the same as another method, yet neither overrides the other
(many more)
[ERROR] first method: visit(org.yinwang.pysonar.ast.Yield) in org.yinwang.pysonar.ast.GenericNodeVisitor
[ERROR] second method: visit(Withitem) in org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project pysonar: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Exception in thread "main" java.lang.NullPointerException
at org.python.indexer.types.FunType.printType(FunType.java:180)
at org.python.indexer.types.Type.toString(Type.java:212)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at org.python.indexer.demos.Linker.processRef(Linker.java:175)
at org.python.indexer.demos.Linker.findLinks(Linker.java:54)
at org.python.indexer.demos.HtmlDemo.generateHtml(HtmlDemo.java:125)
at org.python.indexer.demos.HtmlDemo.start(HtmlDemo.java:115)
at org.python.indexer.demos.HtmlDemo.main(HtmlDemo.java:217)
and what does this message:
dest path length is shorter than root path: dest=/usr/lib/python2.7/sre_constants.py, root=/home/banxi/path/for/my/python/project
mean?
On Mac OS X 10.9, where python 3 is not installed:
Failed to start Python
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1364)
at org.yinwang.pysonar._.die(_.java:336)
at org.yinwang.pysonar._.die(_.java:325)
at org.yinwang.pysonar.Parser.startInterpreter(Parser.java:832)
at org.yinwang.pysonar.Parser.startPythonProcesses(Parser.java:65)
at org.yinwang.pysonar.Parser.<init>(Parser.java:43)
at org.yinwang.pysonar.AstCache.get(AstCache.java:39)
at org.yinwang.pysonar.Analyzer.getAstCache(Analyzer.java:368)
at org.yinwang.pysonar.Analyzer.<init>(Analyzer.java:75)
at org.yinwang.pysonar.demos.Demo.start(Demo.java:49)
at org.yinwang.pysonar.demos.Demo.main(Demo.java:192)
When the ∞ character is present, the output after that point will be cut off.
reproducer:
x = int()
if 1.5 < x and x < 10:
if x < 6.2:
w = x # [2, 6]
else:
w = x # [7, 10)
else:
w = x # (-∞, 1] [10, +∞)
print w
Currently numbers are inferred all as 'int' or 'float'. It would be nice to have actual static values (or range) propagated. This will increase accuracy.
十分抱歉用这样十分唐突的方式联系找你, 我实在找不到你,我今天(2014年12月10)刚看到你的<程序员的心理疾病>文章,如获至宝,看见你的文章我如梦初醒,似乎看清楚了些什么,找到你的新浪博客http://blog.sina.com.cn/yinwang0,但是已经关闭了, 我心痛不已, 为什么一个针砭时弊的优秀的人放弃抵抗, 我想用轻微的语言留住你,不要离开我们.
我87年生人, 是个大专生, 没有华丽的背景, 更没有多么高的天赋, 像我一样的代码民工在北上广有很多, 脑袋笨笨想挣点钱,攒点钱, 但是我不傻, 我知道什么样的人是好人, 你是那个好人, 如果每个高手都归隐山林, 留下的那份责任谁来承担呢,大家都说能力越大,责任越大, 请不要轻易放弃我们, 请拿起你的学识振臂高呼吧,
改变需要时间,请不要失去耐心,推翻旧的陋习需要反抗,请带领我们走出沼泽.
如果司马迁放弃了就没有史记了;
如果甘地放弃了印度会变成什么样子;
如果马丁路德金放弃了呢?
如果超人,蝙蝠侠,蜘蛛侠,超级英雄放弃抵抗了呢?
当我看到你的文章,我瞬间就心跳加速了高兴不已, 你看见了, 看见了别人看不到的地方,你是多么宝贵,
你是多么幸运可以去推翻旧的环境,去粉刷新的房子,如果说我们生下来并不属于自己,生下来就是为了改变世界,让世界更美好,去帮助别人,让自己和别人变的更好. 如果你认同, 请原谅那些伤害你的人, 哪怕会再次受伤, 也请你再一次带领我们, 去帮助我们认识真实的世界, 我们总会明白你的苦心, 那些先慢慢醒来的人跟随你的脚步去唤醒起更多的人.
最后恳请你不要禁声,世界已经很丑陋了,我们太需要你这样的人,哪怕一张黑纸上只有一个白点, 哪怕白点很小,我们也是有希望去对抗黑暗和丑陋的.
我叫田明 邮箱[email protected] (请原谅我的唐突给你带来的不便)
The new way of highjacking CPython seems to be much slower than Jython's parser (although it can now handle Python 3). The speed is 10 files/second v.s. 25 files/second. It works by dumping the ASTs as JSON into a file and then read them using Gson (in my experience Gson is faster than Jackson).
I haven't yet figured out whether it is slow because of CPython's parser is slow, or it is slow because the way I handle JSON and files. I assumed that the files are stored in the disk buffer.
This may not be a priority because it slows down things when they are first parsed, but then lots of ASTs are cached and serialized to disk, so later analysis becomes much faster.
I followed the example given in HtmlDemo.java, but cannot find the HTML files. Did I do anything wrong?
$ java -classpath dist/jython.jar org.python.indexer.demos.HtmlDemo "C:\Python27\Lib" "C:\Python27\Lib\email"
Building index
...........
Finished loading files. 518 functions were called.
Analyzing uncalled functions, count: 2412
................................
Summary:
- modules loaded: 146
- unresolved modules: 63
- semantics problems: 129
- parsing problems: 0
Finished indexing in: 0:0:14
Generating HTML
0 items processed, time: 0:0:0, rate: 0
Wrote 0 files to E:\Workspace\jython\html
Finished generating HTML in: 0:0:1
pull request #51 fix some python3 crash problem, but the downside is found now getDocstring returns something like:
"""
hello
"""
instead of
hello
what do you think we should keep the original behavior? I could send you a fix if that is the case.
if isinstance(x, int):
foo(x);
elif isinstance(x, str):
bar(x)
when seeing those conditions, x should have the corresponding types in the particular branch. Currently this information is missing.
It is reported that some code containing Chinese comments will have highlights misaligned. I noticed that this happens with the "cpython-parser" branch, but haven't been able to reproduce in the master branch (which uses Jython's parser).
I'll look more into that when I have an actual reproducer for this bug.
def get_admin_by_username_password(username, password):
"""
根据用户名和密码找出管理员
:param username: 用户名
:param password: 密码
:return: 如果找到返回Admin找不到返回None
"""
if username is None or password is None:
return None
u = None
for each in _admins:
if each.username == username:
u = each
break
if u is None:
return None
if u.password == password:
return u
return None
http://github.com/opdemand/deis/symbols/python/cm/chef_api/ChefAPI/request
The return type of the function (in picture) should contain str
as its first tuple component, because resp.read()
has type (HTTPResponse, None)->str. But this information was somehow lost.
Tried to write a small reproducer but couldn't reproduce the same problem:
class A:
def f():
return 1
def g():
x = A()
return x.f(), "hi"
Analyze the following:
def x(q):
if q == 0:
return (2, True)
else:
return (None, False)
y, z = x(3)
Expected:
y :: { int | None }
z :: bool
Actual behavior:
type of y is not inferred
type of z is not inferred
Diagnostic is created: unpacking non-iterable: {(None, bool) | (int, bool)}
This type of code is seen with functions that emulate multiple-value returns, so there is a use case.
Hello,
first of all I'm very impressed by pysonar and your coding style. Just perfect :)
For my use case of pysonar I had to adjust Node.java
a little. children
allows the user to walk the modified AST and transType
('type' is already in use somewhere else) stores the resulting type for each Node. This way one can retrieve the type of every intermediate expression.
--- ../Node.java 2014-06-27 20:34:34.325686269 +0200
+++ src/main/java/org/yinwang/pysonar/ast/Node.java 2014-06-27 20:30:23.389684137 +0200
@@ -27,6 +27,9 @@
public String name;
public Node parent = null;
+ public List<Node> children = new ArrayList<>();
+ public Type transType = null;
+
public Node() {
}
@@ -72,6 +75,7 @@
for (Node n : nodes) {
if (n != null) {
n.setParent(this);
+ this.children.add(n);
}
}
}
@@ -83,6 +87,7 @@
for (Node n : nodes) {
if (n != null) {
n.setParent(this);
+ this.children.add(n);
}
}
}
@@ -115,7 +120,8 @@
@NotNull
public static Type transformExpr(@NotNull Node n, State s) {
- return n.transform(s);
+ n.transType = n.transform(s);
+ return n.transType;
}
"Analyzing uncalled functions" stage writes a new line for each increment of the progress indicator rather than rewriting the output line as it does in the "Loading and analyzing files" stage.
Tested on Ubuntu 13.10 running Oracle Java JDK 1.7.0_51
Command string "java -d64 -Xmx3G -jar target/pysonar-2.0-SNAPSHOT.jar /usr/lib/python2.7 ./html"
a="hello"
k=2
while(k<=3):
b=a
print b
k=k+1
a=1
b should be of string|int
type, not string
type
I build the code via mvn clean package as README said. Then I kept falling by running demo program. It claimed I did not have python installed. Of course it was not true.
-> java -jar target/pysonar-2.0-SNAPSHOT.jar /usr/lib/python2.7 ./python_2.7_html
Building index
Not found: python2
Not found: python3
You don't seem to have either of Python or Python3 on PATH
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1364)
By tracing some code I found the problem is that I have to create directory /tmp/pysonar2 in advance.
Then it loaded and started running till the next exception:
java -jar target/pysonar-2.0-SNAPSHOT.jar /usr/lib/python2.7 ./python_2.7_html
Building index
Started process: python
Started process: python3
..................................................
500 items processed, time: 0:0:13, rate: 38
..........................................
Finished loading files. 524 functions were called.
Analyzing uncalled functions, count: 13738
..................................................
5000 items processed, time: 0:0:26, rate: 192
....Exception in thread "main" java.lang.NullPointerException
at org.yinwang.pysonar.ast.Attribute.getAttrType(Attribute.java:94)
at org.yinwang.pysonar.ast.Attribute.resolve(Attribute.java:89)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.Call.resolve(Call.java:49)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.Subscript.resolve(Subscript.java:28)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.Assign.resolve(Assign.java:35)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.Block.resolve(Block.java:56)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.For.resolve(For.java:43)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.Block.resolve(Block.java:56)
at org.yinwang.pysonar.ast.Node.resolveExpr(Node.java:95)
at org.yinwang.pysonar.ast.Call.apply(Call.java:140)
at org.yinwang.pysonar.Indexer.applyUncalled(Indexer.java:712)
at org.yinwang.pysonar.Indexer.finish(Indexer.java:643)
at org.yinwang.pysonar.demos.Demo.start(Demo.java:88)
at org.yinwang.pysonar.demos.Demo.main(Demo.java:200)
The environment is Fedora 19 x86_64. java version "1.7.0_45" Python 2.7.5
Hi there,
I see that there's a class that dumps to JSON in the source, but I can't seem to get it to do anything - the output files just contain []
. Is there an example somewhere of how to use this?
I'm running it with the following command line (slightly sanitized):
java -jar ~/Documents/repos/pysonar2/target/pysonar-2.0-SNAPSHOT.jar ./filename.py /usr/lib/python2.7/:/an-include-path-1/:/an-include-path-2/ /tmp/gph
Thanks,
--Andrew
A relative import such as from ..foo.bar import ...
is highlighted as "from ..f o o.b ar import ..." (sorry for the extra spaces...), i.e. the characters highlighted should be shifted by the number of leading dots.
The interprocess communication between Java and CPython is error-prone and may pause at certain points. The reason is quite tricky to find out. A better way is needed to do the IPC.
I'm tired of fixing the parser issues. If you want to donate a cleanly designed Python parser, that will be very appreciated :)
parser failed on file
/usr/local/lib/python2.7/site-packages/docutils/utils/error_reporting.py
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe4 in position 150: invalid continuation byte
A python tool would be better in python, to integrate with editors that use python as a plugin language (sublime text 3) and tools that use external programs and you don't have a java virtual machine.
Code highlight is misplaced when there are Chinese characters:
I also encountered problems with encoding in UTF-8 with BOM:
The souce code and the HTML files shown in the figures can be download at https://db.tt/MHXGaU2s
Analysis finished within 5 minutes, but HTML taking over 6G mem and didn't finish. I suspect there is an infinite loop somewhere in HTML generation code triggered by the corner cases uncovered by the extra discovered nodes after a recent enhancement.
没有withitem
This bug is here is for achieving a goal of logic correctness, may not affect the usefulness of results. It's partially done, but had other issues with the change. So currently put down for further reviews.
The current termination condition at recursion isn't really correct (although most static analysis tools such as Coverity only go this far. It stops recursion when the call-site is already on stack, which will prevent the same call-site with different parameter types being invoked. This will cause loss of useful type information, and thus possible false negatives.
The correct way should put (call-site, ) pair on stack, and terminate the recursion only if this pair recur. This is similar to Cartesian Product Algorithm.
When run mvn clean package
with oracle jdk and openjdk, both come with error like these:
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/NodeVisitor.java:[69,26] 找不到符号
符号: 类 Withitem
位置: 接口 org.yinwang.pysonar.ast.NodeVisitor
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/With.java:[15,17] 找不到符号
符号: 类 Withitem
位置: 类 org.yinwang.pysonar.ast.With
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/With.java:[19,31] 找不到符号
符号: 类 Withitem
位置: 类 org.yinwang.pysonar.ast.With
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[242,26] 找不到符号
符号: 类 Withitem
位置: 类 org.yinwang.pysonar.ast.DefaultNodeVisitor
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[25,20] 名称冲突: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(org.yinwang.pysonar.ast.Alias) 覆盖的方法的疑符与另一个方法的相同, 但两者均不覆盖对方
第一个方法: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(org.yinwang.pysonar.ast.With)
第二个方法: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(Withitem)
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[29,20] 名称冲突: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(org.yinwang.pysonar.ast.Assert) 覆盖的方法的疑符与另一个方法的相同, 但两者均不覆盖对方
第一个方法: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(org.yinwang.pysonar.ast.With)
第二个方法: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(Withitem)
[ERROR] /home/wangwangwar/program/python/pysonar2/src/main/java/org/yinwang/pysonar/ast/DefaultNodeVisitor.java:[33,20] 名称冲突: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(org.yinwang.pysonar.ast.Assign) 覆盖的方法的疑符与另一个方法的相同, 但两者均不覆盖对方
第一个方法: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(org.yinwang.pysonar.ast.With)
第二个方法: org.yinwang.pysonar.ast.DefaultNodeVisitor 中的 visit(Withitem)
Is my environment broken? All of you compile success but me. I really want to try this tools.
failed to parse: /usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_importKey.py
[Please report bug]: unexpected ast node: NameConstant
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1329)
at org.yinwang.pysonar..die(.java:344)
at org.yinwang.pysonar..die(.java:333)
at org.yinwang.pysonar.Parser.convert(Parser.java:590)
at org.yinwang.pysonar.Parser.convert(Parser.java:128)
at org.yinwang.pysonar.Parser.convertListNode(Parser.java:625)
at org.yinwang.pysonar.Parser.convertBlock(Parser.java:641)
at org.yinwang.pysonar.Parser.convert(Parser.java:295)
at org.yinwang.pysonar.Parser.convertList(Parser.java:605)
at org.yinwang.pysonar.Parser.convert(Parser.java:519)
at org.yinwang.pysonar.Parser.convertListNode(Parser.java:625)
at org.yinwang.pysonar.Parser.convertBlock(Parser.java:641)
at org.yinwang.pysonar.Parser.convert(Parser.java:106)
at org.yinwang.pysonar.Parser.parseFileInner(Parser.java:903)
at org.yinwang.pysonar.Parser.parseFile(Parser.java:848)
at org.yinwang.pysonar.AstCache.getAST(AstCache.java:99)
at org.yinwang.pysonar.Analyzer.getAstForFile(Analyzer.java:378)
at org.yinwang.pysonar.Analyzer.parseAndResolve(Analyzer.java:331)
at org.yinwang.pysonar.Analyzer.loadFile(Analyzer.java:317)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:517)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.analyze(Analyzer.java:97)
at org.yinwang.pysonar.demos.Demo.start(Demo.java:47)
at org.yinwang.pysonar.demos.Demo.main(Demo.java:172)
21:06 $ java -jar target/pysonar-2.0-SNAPSHOT.jar ~/anaconda3/lib/python3.5 .html
copied models to: /private/var/folders/5q/lllv2yf95hg_n6h6kjttbmdw0000gn/T/pysonar2/models.64a3d6b9-89de-4fbc-a882-7edc10d7a0d6
AST cache is at: /private/var/folders/5q/lllv2yf95hg_n6h6kjttbmdw0000gn/T/pysonar2/ast_cache
started: python
started: python3
Loading and analyzing files
[Please report bug]: unexpected ast node: AsyncFunctionDef
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1329)
at org.yinwang.pysonar..die(.java:344)
at org.yinwang.pysonar..die(.java:333)
at org.yinwang.pysonar.Parser.convert(Parser.java:626)
at org.yinwang.pysonar.Parser.convertListNode(Parser.java:680)
at org.yinwang.pysonar.Parser.convertBlock(Parser.java:696)
at org.yinwang.pysonar.Parser.convert(Parser.java:107)
at org.yinwang.pysonar.Parser.parseFileInner(Parser.java:959)
at org.yinwang.pysonar.Parser.parseFile(Parser.java:900)
at org.yinwang.pysonar.AstCache.getAST(AstCache.java:99)
at org.yinwang.pysonar.Analyzer.getAstForFile(Analyzer.java:378)
at org.yinwang.pysonar.Analyzer.parseAndResolve(Analyzer.java:331)
at org.yinwang.pysonar.Analyzer.loadFile(Analyzer.java:317)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:517)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.analyze(Analyzer.java:97)
at org.yinwang.pysonar.demos.Demo.start(Demo.java:47)
at org.yinwang.pysonar.demos.Demo.main(Demo.java:172)
Accessing https://yinwang0.wordpress.com/2010/09/12/pysonar gives :
https://yinwang0.wordpress.com/ is marked private by its owner. If you were invited to view this site, please log in below. Read more about privacy settings.
java -jar target/pysonar-2.0-SNAPSHOT.jar /usr/lib/python2.7 ./html
copied models to: /private/var/folders/nc/6vm5h_854gg0lmhxgb8r41l00000gn/T/pysonar2/models.daa68e69-d0e4-45d9-9bf0-fe0928353733
AST cache is at: /private/var/folders/nc/6vm5h_854gg0lmhxgb8r41l00000gn/T/pysonar2/ast_cache
started: python
started: python3
Loading and analyzing files
50% ( 729 of 1451) SPEED: 10/s AVG SPEED: 10/s ETA: 0:1:12 Exception in thread "main" java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to java.lang.String
at org.yinwang.pysonar.Parser.convert(Parser.java:326)
at org.yinwang.pysonar.Parser.convertListNode(Parser.java:647)
at org.yinwang.pysonar.Parser.convertBlock(Parser.java:663)
at org.yinwang.pysonar.Parser.convert(Parser.java:325)
at org.yinwang.pysonar.Parser.convertListNode(Parser.java:647)
at org.yinwang.pysonar.Parser.convertBlock(Parser.java:663)
at org.yinwang.pysonar.Parser.convert(Parser.java:230)
at org.yinwang.pysonar.Parser.convertListNode(Parser.java:647)
at org.yinwang.pysonar.Parser.convertBlock(Parser.java:663)
at org.yinwang.pysonar.Parser.convert(Parser.java:107)
at org.yinwang.pysonar.Parser.parseFileInner(Parser.java:926)
at org.yinwang.pysonar.Parser.parseFile(Parser.java:871)
at org.yinwang.pysonar.AstCache.getAST(AstCache.java:99)
at org.yinwang.pysonar.Analyzer.getAstForFile(Analyzer.java:378)
at org.yinwang.pysonar.Analyzer.parseAndResolve(Analyzer.java:331)
at org.yinwang.pysonar.Analyzer.loadFile(Analyzer.java:317)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:517)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:513)
at org.yinwang.pysonar.Analyzer.analyze(Analyzer.java:97)
at org.yinwang.pysonar.demos.Demo.start(Demo.java:47)
at org.yinwang.pysonar.demos.Demo.main(Demo.java:172)
Hi there,
I recognized that in the following code the key and value type of x
is not available as well as the element type of y
.
x = {}
x[1] = 2 # or
#x.update({1: 2})
y = []
y.append(1)
Imho this should be resolvable.
Currently standard lib functions are hardcoded in Builtins.java. This is messy. Try to make "models" like that of Coverity analysis, and use a unified way to treat primitive lib functions and usual functions.
BUILD FAILED
/home/wangwangwar/program/python/pysonar2/jython/build.xml:576: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Lorg/objectweb/asm/ClassReader;I)V
at org.python.expose.generate.ExposedTypeProcessor.(ExposedTypeProcessor.java:49)
at org.python.expose.generate.ExposeTask.expose(ExposeTask.java:49)
at org.python.expose.generate.ExposeTask.process(ExposeTask.java:39)
at org.python.util.GlobMatchingTask.execute(GlobMatchingTask.java:70)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
The module system has been changed into a very complicated way since I finished my first internship at Google, to the point I dared not change it during my second internship :-P The bad thing is after all this complication, it wasn't really correct given a tricky example which nobody should write:
import a.b.c.f
from a.b.c import *
will not import f into the current name space when f
is not in __all__
of package c.
This contradicts the behavior as defined in: http://docs.python.org/2/tutorial/modules.html#importing-from-a-package
import sound.effects.echo
import sound.effects.surround
from sound.effects import *
"In this example, the echo and surround modules are imported in the current namespace because they are defined in the sound.effects package when the from...import statement is executed. (This also works when __all__
is defined.)"
This is not true. If you have __all__ = ['surround']
in sound/effects/echo/__init__.py
, the from sound.effects import * will not put 'echo' into the current name space even if you already have import sound.effects.echo and have 'echo' in the sound.effects package.
In general "from X import *" should not be used, and Python's module system does seem to be over-engineered, but a static analysis tool should still try to do its best to help when the programmers write this kind of code.
I deleted all the code regarding import statements, and will rewrite all of the code.
我是个人工智能爱好者,这一生都打算用于实现强人工智能,不知道你对此感不感兴趣。目前我还是刚刚大学毕业不久,或许没你聪明,但刚看你文章发现对研究的热爱和态度是和你一样的。如果一切都好的话,我会在未来2年内组建自己的公司和团队,然后搞AI。其实对于我们这样的人,缺的应该就是一个环境,而这个环境估计只能自己造。
在公司和学校都不可能真正自由,在学校被各种学业束缚;在公司用的是别人的钱,被经济束缚。但是,难道自己建公司就不被经济束缚了?但总要自由好多吧,这世上真正自由的条件大概就是需要经济自由吧。不知道你对此有没有兴趣。公司 和 AI。
I'm running the snapshot demo and get the following:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/yinwang/pysonar/demos/Demo : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
This is partially done, with somethings broken again (namely the module system, which needs to be simplified). Will make a separate branch.
Although the analysis doesn't take much memory (< 2G). The HTML generation stage takes a lot of memory. After some bug fixes, the analysis stage resolves more names, such that HTML generation stage is using over 6G of memory for Python 2.7 standard library. This is too much and must be reduced.
Running on windows with the following command(via powershell)
java -jar target\pysonar-2.0-SNAPSHOT.jar C:\Python27\ArcGIS10.3\Lib\json .\html
and got the following exception
copied models to: C:\Users\zhuo7364\AppData\Local\Temp\pysonar2\models.e72326df-c57e-47ff-a15e-88cddb162811
AST cache is at: C:\Users\zhuo7364\AppData\Local\Temp\pysonar2\ast_cache
Failed to start: python3
started: python
Loading and analyzing files
Failed to get canonical path
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Unknown Source)
at org.yinwang.pysonar..die(.java:336)
at org.yinwang.pysonar..die(.java:325)
at org.yinwang.pysonar..unifyPath(.java:444)
at org.yinwang.pysonar..unifyPath(.java:436)
at org.yinwang.pysonar..makePathString(.java:431)
at org.yinwang.pysonar.AstCache.getCachePath(AstCache.java:125)
at org.yinwang.pysonar.AstCache.getCachePath(AstCache.java:119)
at org.yinwang.pysonar.AstCache.getSerializedModule(AstCache.java:159)
at org.yinwang.pysonar.AstCache.getAST(AstCache.java:89)
at org.yinwang.pysonar.Analyzer.getAstForFile(Analyzer.java:379)
at org.yinwang.pysonar.Analyzer.parseAndResolve(Analyzer.java:332)
at org.yinwang.pysonar.Analyzer.loadFile(Analyzer.java:319)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:518)
at org.yinwang.pysonar.Analyzer.loadFileRecursive(Analyzer.java:514)
at org.yinwang.pysonar.Analyzer.analyze(Analyzer.java:99)
at org.yinwang.pysonar.demos.Demo.start(Demo.java:51)
at org.yinwang.pysonar.demos.Demo.main(Demo.java:192)
Did I input a right path or this could be a potential issue?
Thank you very much
I'd like to generate a call graph of a python codebase via static analysis (like what https://github.com/gousiosg/java-callgraph does for Java code). I think I might be able to use pysonar2 to do this. Is this possible? I'm not sure where I would need to hook into the code.
After fixing #29 the HTML files are generated, but the contents don't look quite right. All the links are in wrong locations. This may have something to do with CPython's way of parsing and decoding text. Also might be related to line end conventions in different systems.
lei@ubuntu:~/app/pysonar2$ mvn clean package -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pysonar2 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.3:clean (default-clean) @ pysonar ---
[INFO] Deleting file set: /home/lei/app/pysonar2/target (included: [**], excluded: [])
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ pysonar ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pysonar ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 93 source files to /home/lei/app/pysonar2/target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/ProxyParser.java: /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/ProxyParser.java uses unchecked or unsafe operations.
[WARNING] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/ProxyParser.java: Recompile with -Xlint:unchecked for details.
[INFO] 2 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[75,13] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Demo.java:[4,27] cannot find symbol
symbol: class FancyProgress
location: package org.yinwang.pysonar
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Linker.java:[53,9] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.demos.Linker
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Linker.java:[53,38] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.demos.Linker
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Linker.java:[66,24] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.demos.Linker
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[546,35] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[652,9] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[652,38] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Demo.java:[107,9] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.demos.Demo
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Demo.java:[107,38] cannot find symbol
symbol: class FancyProgress
location: class org.yinwang.pysonar.demos.Demo
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.603s
[INFO] Finished at: Thu Nov 14 22:46:17 EST 2013
[INFO] Final Memory: 11M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project pysonar: Compilation failure: Compilation failure:
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[75,13] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Demo.java:[4,27] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: package org.yinwang.pysonar
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Linker.java:[53,9] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.demos.Linker
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Linker.java:[53,38] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.demos.Linker
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Linker.java:[66,24] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.demos.Linker
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[546,35] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[652,9] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/Indexer.java:[652,38] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.Indexer
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Demo.java:[107,9] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.demos.Demo
[ERROR] /home/lei/app/pysonar2/src/main/java/org/yinwang/pysonar/demos/Demo.java:[107,38] cannot find symbol
[ERROR] symbol: class FancyProgress
[ERROR] location: class org.yinwang.pysonar.demos.Demo
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project pysonar: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
In New bugs are stil being fixed...
, is stil
a typo?
Too many bindings get into the states when processing this file, causing the system to run out of memory.
cpython/Tools/pybench/Constructs.py
This super long evil nested if statement is causing the trouble:
def test(self):
a,b,c = 1,2,3
for i in range(self.rounds):
if a == 1:
if b == 2:
if c != 3:
c = 3
b = 3
else:
c = 2
elif b == 3:
b = 2
a = 2
elif a == 2:
a = 3
else:
a = 1
if a == 1:
if b == 2:
if c != 3:
c = 3
b = 3
else:
c = 2
elif b == 3:
b = 2
a = 2
elif a == 2:
a = 3
else:
a = 1
...... .....
java -jar target/pysonar-2.0-SNAPSHOT.jar /usr/lib/python2.7 ./html
[Exception] in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.yinwang.pysonar.ast.Node.hashCode(Node.java:186)
at java.util.HashMap.hash(HashMap.java:366)
at java.util.HashMap.put(HashMap.java:496)
at org.yinwang.pysonar.Analyzer.putRef(Analyzer.java:236)
at org.yinwang.pysonar.ast.Name.transform(Name.java:46)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Subscript.transform(Subscript.java:28)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Assign.transform(Assign.java:29)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Block.transform(Block.java:47)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.If.transform(If.java:37)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Block.transform(Block.java:47)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Call.apply(Call.java:155)
at org.yinwang.pysonar.ast.Call.resolveCall(Call.java:84)
at org.yinwang.pysonar.ast.Call.transform(Call.java:70)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Return.transform(Return.java:26)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Block.transform(Block.java:47)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Call.apply(Call.java:155)
at org.yinwang.pysonar.ast.Call.resolveCall(Call.java:84)
at org.yinwang.pysonar.ast.Call.transform(Call.java:70)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Assign.transform(Assign.java:29)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
at org.yinwang.pysonar.ast.Block.transform(Block.java:47)
at org.yinwang.pysonar.ast.Node.transformExpr(Node.java:118)
A irrelevant question here. In your presentation, you mentioned that it's easy to extend it to support other dynamic language. are there any guides or documentation on how to support javascript? Do you have any plan to support javascript?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.