Eclipse JDT--AST入门(转载)

转载自 [url]http://blog.csdn.net/flying881114/article/details/6187061[/url],有少许改动。

---入门文档

1. Eclipse Corner Article: Abstract Syntax Tree
[url]http://www.eclipse.org/articles/Article-JavaCodeManipulation_AST/index.html[/url]
(英文,AST的概述,细节代码不多)

这张图不错的,描述了使用ast的流程,一共6步。
[img]http://www.eclipse.org/articles/Article-JavaCodeManipulation_AST/images/workflow.png[/img]

2. 探索Eclipse的ASTParser
[url]http://www.ibm.com/developerworks/cn/opensource/os-ast/index.html[/url]
(中文,相对详细的讲解和代码)

个人认为上面2篇都是不错的入门文章,值得反复回头细细咀嚼。

---AST使用

1. Eclipse JDT--AST and JavaModel Tutorial
[url]http://www.vogella.de/articles/EclipseJDT/article.html[/url]
(英文,代码很多,但需要有更多的背景知识)

2. Eclipse AST 使用指南
[url]http://wenku.baidu.com/view/a0b8e07931b765ce050814ac.html[/url]
(pdf文档,更加详细地说明了AST 相关类与方法,可以与eclipse documentation结合使用)

3. Eclipse documentation
[url]http://help.eclipse.org/helios/index.jsp[/url]
其实,最靠谱的还是直接看eclipse文档。在这里你可以了解你想知道的一切。

4. Yet another AST tutorial
[url]http://sahits.ch/blog/?p=228[/url]
英文,有大量代码,从易到难讲解

---使用AST相关

1. 使用AST出现问题?不知道使用什么jar包?看看这里吧:
[url]http://lym6520.javaeye.com/blog/747840[/url]

由于上文用的jar包比较老,是基于jdt core3.6版的,这里给出一个比较新的基于maven的dependency,jdt core是3.9版的。


<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.9.0.v20130604-1421</version>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
<version>3.6.0.v20100503</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.6.0.v20100526-0737</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>3.6.0.v20100505</version>
</dependency>
<dependency>
<groupId>org.jibx.config.3rdparty.org.eclipse</groupId>
<artifactId>org.eclipse.text</artifactId>
<version>3.5.100.v20110505-0800</version>
</dependency>


2. 想亲眼看看你源文件的AST是什么样的?为你的Eclipse装一个ASTview插件吧!
[url]http://www.eclipse.org/jdt/ui/astview/index.php[/url]
或者下载附件里的java代码,直接运行图形化工具AstExplorer也可以。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值