flaxel/parser
Fork: 2 Star: 2 (更新于 2024-11-22 21:36:07)
license: Apache-2.0
Language: Java .
simple interface and cli for javaparser
最后发布版本: 1.0.0 ( 2019-06-09 03:37:51)
This project contains java code to analyze, transform and generate code. It can also be used from the console with the command line interface.
Getting Started
If you follow the next steps you can get the parser_core
as a jar archive to analyze, transform and generate java code.
Prerequisites
The project is created with the build tool Maven, the ide Eclipse and the Java Version 11.
Setup
It is possible to include the jar archive with the tool JitPack. Otherwise you can download the archive from the release page and include the archive manually.
Maven
Add the repository to the build file:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add the dependency:
<dependency>
<groupId>com.github.flaxel.parser</groupId>
<artifactId>parser_core</artifactId>
<version>1.0.0</version>
</dependency>
Gradle
Add the repository to the build file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.github.flaxel.parser:parser_core:1.0.0'
}
SBT
Add the repository to the build file:
resolvers += "jitpack" at "https://jitpack.io"
Add the dependency:
libraryDependencies += "com.github.flaxel.parser" % "parser_core" % "1.0.0"
Leiningen
Add the repository to the build file:
:repositories [["jitpack" "https://jitpack.io"]]
Add the dependency:
:dependencies [[com.github.flaxel.parser/parser_core "1.0.0"]]
Examples
Analyze java code - list all class elements:
File file = new File("path/to/java_file");
ListClassHandler unitHandler = new ListClassHandler(System.out);
Analyzer.analyzeFile(file, unitHandler);
Transform java code - rename class to interface:
File file = new File("path/to/java_file");
RenameHandler unitHandler = new RenameHandler(System.out, "class", (oldString) -> "interface");
Transformer.transformFile(file, unitHandler);
Generate java code - create a person class:
File file = new File("path/to/java_file");
PojoGenerator generator = new PojoGenerator("Person", List.of(String.class, String.class), List.of("preName", "name"));
Generator.generate(generator, file);
You can find all generators, filters and handlers for analyzing, transforming and problems in the documentation.
Documentation
There exists a java documentation for the module parser_core
. It is published on the branch gh-pages and can be accessed through this link https://flaxel.github.io/parser.
Compiling and Testing
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. First it is necessary to clone the project from the master branch.
git clone https://github.com/flaxel/parser.git
After that you can create all jars for the project.
mvn clean install
It is also possible to run all tests of the project.
mvn test
Deployment
If you want to use the command line interface named parser_cli
, please download the zip archive from the release page. The next steps depend on your operating system.
Linux
There are two possibilities to add the parser. But first you must install the parser:
sudo mkdir /opt/parser
cd ~/Downloads
sudo unzip parser.zip -d /opt/parser
If you want to use the parser from the command line you can execute the following command:
echo "alias parser='java -jar /opt/parser/parser_cli-1.0.0-jar-with-dependencies.jar'" >> ~/.bash_aliases
Or you can add the parser as application:
cd /opt/parser
sudo mv parser.desktop /usr/share/applications/
Windows
It is very simple to execute the parser. You have to execute the parser.bat and the command line is started.
最近版本更新:(数据更新于 2024-09-04 13:51:03)
2019-06-09 03:37:51 1.0.0
主题(topics):
cli, code-analysis, code-generation, code-generator, java, java-command, javaparser, library, parser
flaxel/parser同语言 Java最近更新仓库
2024-11-22 14:41:49 dromara/dante-cloud
2024-11-21 20:32:01 spring-projects/spring-boot
2024-11-21 09:44:43 Card-Forge/forge
2024-11-20 14:38:43 StarRocks/starrocks
2024-11-19 23:42:52 spring-projects/spring-authorization-server
2024-11-18 21:40:12 4379711/lol-helper