Initial commit
This commit is contained in:
parent
82ab06541c
commit
0241f4d641
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/target
|
||||
/licenseheader.txt
|
||||
/nb-configuration.xml
|
||||
/nbactions.xml
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
||||
/.vscode
|
||||
62
pom.xml
Normal file
62
pom.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>electrosphere</groupId>
|
||||
<artifactId>highlevel-netcode-gen</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<version.roaster>2.28.0.Final</version.roaster>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.forge.roaster</groupId>
|
||||
<artifactId>roaster-api</artifactId>
|
||||
<version>${version.roaster}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.forge.roaster</groupId>
|
||||
<artifactId>roaster-jdt</artifactId>
|
||||
<version>${version.roaster}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.javaparser</groupId>
|
||||
<artifactId>javaparser-symbol-solver-core</artifactId>
|
||||
<version>3.25.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>electrosphere.main.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase> <!-- bind to the packaging phase -->
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
82
src/main/java/electrosphere/main/Main.java
Normal file
82
src/main/java/electrosphere/main/Main.java
Normal file
@ -0,0 +1,82 @@
|
||||
package electrosphere.main;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jboss.forge.roaster.Roaster;
|
||||
import org.jboss.forge.roaster.model.source.FieldSource;
|
||||
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
||||
import org.jboss.forge.roaster.model.source.JavaDocSource;
|
||||
|
||||
import electrosphere.main.targets.NetcodeGenTarget;
|
||||
import electrosphere.main.targets.TargetFile;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
static String[] targetFiles = new String[]{
|
||||
"C:\\Users\\satellite\\Documents\\Renderer\\src\\main\\java\\electrosphere\\entity\\state\\IdleTree.java",
|
||||
};
|
||||
|
||||
public static void main(String args[]){
|
||||
System.out.println("Hello, world!");
|
||||
for(String targetFilePath : targetFiles){
|
||||
String content = "";
|
||||
try {
|
||||
content = Files.readString(new File(targetFilePath).toPath());
|
||||
} catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
TargetFile targetFile = new TargetFile(targetFilePath, content);
|
||||
for(NetcodeGenTarget target : parseGenerationTargets(targetFile)){
|
||||
System.out.println(target.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static List<NetcodeGenTarget> parseGenerationTargets(TargetFile targetFile){
|
||||
List<NetcodeGenTarget> targets = new LinkedList<NetcodeGenTarget>();
|
||||
for(FieldSource<JavaClassSource> field : targetFile.getSource().getFields()){
|
||||
System.out.println(field.getName());
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
|
||||
static void sourceCodeModification(){
|
||||
String sampleFile = "";
|
||||
try {
|
||||
sampleFile = Files.readString(new File("C:/Users/satellite/Documents/Renderer/src/main/java/electrosphere/renderer/texture/Texture.java").toPath());
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, sampleFile);
|
||||
javaClass.addMethod()
|
||||
.setPublic()
|
||||
.setStatic(true)
|
||||
.setName("main")
|
||||
.setReturnTypeVoid()
|
||||
.setBody("System.out.println(\"Hello World\");")
|
||||
.addParameter("java.lang.String[]", "args");
|
||||
System.out.println(javaClass);
|
||||
}
|
||||
|
||||
static void addingJavadocToClass(){
|
||||
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, "public class SomeClass {}");
|
||||
JavaDocSource javaDoc = javaClass.getJavaDoc();
|
||||
|
||||
javaDoc.setFullText("Full class documentation");
|
||||
// or
|
||||
javaDoc.setText("Class documentation text");
|
||||
javaDoc.addTagValue("@author","George Gastaldi");
|
||||
|
||||
System.out.println(javaClass);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package electrosphere.main.targets;
|
||||
|
||||
public class NetcodeGenTarget {
|
||||
|
||||
String name;
|
||||
|
||||
public NetcodeGenTarget(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
22
src/main/java/electrosphere/main/targets/TargetFile.java
Normal file
22
src/main/java/electrosphere/main/targets/TargetFile.java
Normal file
@ -0,0 +1,22 @@
|
||||
package electrosphere.main.targets;
|
||||
|
||||
import org.jboss.forge.roaster.Roaster;
|
||||
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
||||
|
||||
public class TargetFile {
|
||||
|
||||
String path;
|
||||
String content;
|
||||
JavaClassSource source;
|
||||
|
||||
public TargetFile(String path, String content){
|
||||
this.path = path;
|
||||
this.content = content;
|
||||
this.source = Roaster.parse(JavaClassSource.class, content);
|
||||
}
|
||||
|
||||
public JavaClassSource getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user