blob: 776707e5c197e924ac3b77516c08ac327d1049a2 [file] [log] [blame] [view]
Nicholas Smith646793d2015-01-20 14:53:07 +00001## Java Parser and Abstract Syntax Tree
matozoid2cab70d2013-09-16 13:31:33 +02002
Danny van Bruggen3ad07502017-03-23 15:24:33 +01003This package contains a Java 1.0 - Java 9 Parser with AST generation and visitor support.
Nicholas Smithcd1296d2015-01-20 14:22:40 +00004
Danny van Bruggen11887502016-12-05 19:27:34 +01005The AST records the source code structure.
6You can analyze source code for any purpose.
7It is possible to change the AST nodes or create new ones to modify the source code.
8
9When you need not only the text from the source code but you also need type information,
10you can use [the Java Symbol Solver project.](https://github.com/javaparser/javasymbolsolver)
matozoid2d4deca2011-10-30 14:35:59 +010011
Nicholas Smithd7c51132015-09-02 13:14:42 +010012[![Maven Central](https://img.shields.io/maven-central/v/com.github.javaparser/javaparser-core.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.javaparser%22%20AND%20a%3A%22javaparser-core%22)
Nicholas Smith2b77f432015-02-23 11:01:28 +000013[![Build Status](https://travis-ci.org/javaparser/javaparser.svg?branch=master)](https://travis-ci.org/javaparser/javaparser)
Nicholas Smithcc80fc12015-08-17 15:15:26 +010014[![Coverage Status](https://coveralls.io/repos/javaparser/javaparser/badge.svg?branch=master&service=github)](https://coveralls.io/github/javaparser/javaparser?branch=master)
Nicholas Smithd6a80982015-08-17 15:25:32 +010015[![Join the chat at https://gitter.im/javaparser/javaparser](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/javaparser/javaparser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Nicholas Smithcc80fc12015-08-17 15:15:26 +010016
Nicholas Smithcd1296d2015-01-20 14:22:40 +000017## Features
18
19* Light weight
20* Performant
21* Easy to use
22* Modifiable AST
Danny van Bruggen11887502016-12-05 19:27:34 +010023* Code generation
Nicholas Smithcd1296d2015-01-20 14:22:40 +000024* Support of comments
25
26## Dependency Management
27
matozoid3c137e92016-04-06 19:37:37 +020028The project binaries are available in Maven Central. Just add the following to your maven configuration or tailor to your own dependency management system.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010029
Danny van Bruggeneb248962017-01-11 15:00:00 +010030[Please refer to the Migration Guide when upgrading from 2.5.1](https://github.com/javaparser/javaparser/wiki/Migration-Guide)
Danny van Bruggen11887502016-12-05 19:27:34 +010031```xml
32<dependency>
33 <groupId>com.github.javaparser</groupId>
34 <artifactId>javaparser-core</artifactId>
Danny van Bruggen3d195982017-07-05 12:02:09 +020035 <version>3.2.10</version>
Danny van Bruggen3588d262017-02-19 23:00:47 +010036</dependency>
37```
38
Nicholas Smithcd1296d2015-01-20 14:22:40 +000039## How To Compile Sources
Nicholas Smith15a23ae2015-01-14 10:27:51 +000040
Danny van Bruggend67b5062017-04-16 15:07:23 +020041If you checked out the project from GitHub you can build the project with maven using:
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010042
Federico Tomassetti2051f042014-07-30 19:01:19 +010043```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010044mvn clean install
Federico Tomassetti2051f042014-07-30 19:01:19 +010045```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010046
Danny van Bruggen11887502016-12-05 19:27:34 +010047If you checkout the sources and want to view the project in an IDE, it is best to first generate some of the source files; otherwise you will get many compilation complaints in the IDE. (mvn clean install already does this for you.)
Nicholas Smithcd1296d2015-01-20 14:22:40 +000048
49```
50mvn javacc:javacc
51```
52
Danny van Bruggen45f83182017-07-10 20:15:11 +020053If you modify the code of the AST nodes, specifically if you add or remove fields or node classes,
54a lot of stuff needs to be rebuilt.
55The `run_metamodel_generator.sh` script will rebuild the metamodel,
56which is used by the code generators which are run by `run_core_generators.sh`
57Make sure that `javaparser-core` at least compiles before you run these.
58
Nicholas Smithcd1296d2015-01-20 14:22:40 +000059## Manual
60
61Examples of how to use the library can be found on the [Manual](https://github.com/javaparser/javaparser/wiki/Manual) page of the wiki
62
Nicholas Smith26c753d2015-01-14 10:02:55 +000063## Troubleshooting
64
Danny van Bruggen11887502016-12-05 19:27:34 +010065First try the [wiki](https://github.com/javaparser/javaparser/wiki).
Nicholas Smith26c753d2015-01-14 10:02:55 +000066
Danny van Bruggen11887502016-12-05 19:27:34 +010067Didn't find an answer? Try [searching for existing issues](https://github.com/javaparser/javaparser/issues?utf8=%E2%9C%93&q=is%3Aissue%20)
68
69Still nothing? [Open an issue](https://github.com/javaparser/javaparser/issues/new) or [come chat on Gitter](https://gitter.im/javaparser/javaparser)
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010070
71## Javadoc
72
Nicholas Smithc86a9ff2015-08-12 13:20:26 +010073The libraries javadoc can be found [here](http://www.javadoc.io/doc/com.github.javaparser/javaparser-core/)
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010074
75## History
76
Didier Villevaloisd5e88432015-03-16 14:23:45 +010077This parser is based on work by Sreenivasa Viswanadha and JĂșlio Vilmar Gesser. The original project, now inactive, was originally hosted at [Google Code](http://code.google.com/p/javaparser/) and supported only parsing Java 1.5.
matozoid2d4deca2011-10-30 14:35:59 +010078
Danny van Bruggen3ad07502017-03-23 15:24:33 +010079The project now supports parsing Java 9 and aims to continue support for features in future versions of the Java language.
Nicholas Smith26c753d2015-01-14 10:02:55 +000080
Federico Tomassetti43e1e412015-08-06 17:31:26 +020081## Related projects
82
Federico Tomassetti212fd3f2016-10-20 21:41:35 +020083[JavaSymbolSolver](https://github.com/javaparser/javasymbolsolver) is a project from the same committers working on JavaParser.
84You can use it to calculate the type of JavaParser expressions and connecting references with their declarations.
85
Federico Tomassetti43e1e412015-08-06 17:31:26 +020086From JavaParser other projects have been derived:
87
88* [Walkmod](http://walkmod.com/): a tool to automatically correct violations of code conventions
Edgar Espina1986cf82016-02-29 09:40:38 -030089* [jooby spec](http://jooby.org/doc/spec): analyze and exports [jooby routes](http://jooby.org) to [raml](http://raml.org) and [Swagger](http://swagger.io)
Federico Tomassetti43e1e412015-08-06 17:31:26 +020090
91## Credits
92
93This project has been maintained thanks to the joint efforts of many contributors: we are extremely grateful to all of them.
94
95In particular we are thankful to the contributions we received by the [Walkmod](http://walkmod.com/) project which permitted to finalize support for Java 8. The author granted us the permissions to release that code also under the Apache License and we have greatly appreciated that.
96
Didier Villevaloisd5e88432015-03-16 14:23:45 +010097## License
Nicholas Smith26c753d2015-01-14 10:02:55 +000098
Federico Tomassetti2c7ba122015-08-12 08:06:33 +020099JavaParser is available either under the terms of the LGPL License or the Apache License. You as the user are entitled to choose the terms under which adopt JavaParser.
Federico Tomassettiee6a48a2015-07-25 14:42:17 +0200100
101For details about the LGPL License please refer to [LICENSE.LGPL](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.LGPL).
102
103For details about the Apache License please refer to [LICENSE.APACHE](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.APACHE).