`
xpenxpen
  • 浏览: 703323 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Eclipse JDT--AST入门(转载)

阅读更多
转载自 http://blog.csdn.net/flying881114/article/details/6187061,有少许改动。

---入门文档

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

这张图不错的,描述了使用ast的流程,一共6步。


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

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

---AST使用

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

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

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

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

---使用AST相关

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

由于上文用的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插件吧!
http://www.eclipse.org/jdt/ui/astview/index.php
或者下载附件里的java代码,直接运行图形化工具AstExplorer也可以。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics