it is done

This commit is contained in:
Anuken
2019-12-25 01:39:38 -05:00
parent 5b21873f3c
commit 514d4817c8
488 changed files with 4572 additions and 4574 deletions

View File

@@ -1,4 +1,4 @@
package io.anuke.annotations;
package mindustry.annotations;
import java.lang.annotation.*;

View File

@@ -1,7 +1,7 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.squareup.javapoet.*;
import io.anuke.annotations.Annotations.*;
import mindustry.annotations.Annotations.*;
import javax.annotation.processing.*;
import javax.lang.model.*;
@@ -12,10 +12,10 @@ import java.nio.file.*;
import java.util.*;
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedAnnotationTypes("io.anuke.annotations.Annotations.StyleDefaults")
@SupportedAnnotationTypes("mindustry.annotations.Annotations.StyleDefaults")
public class AssetsAnnotationProcessor extends AbstractProcessor{
/** Name of the base package to put all the generated classes. */
private static final String packageName = "io.anuke.mindustry.gen";
private static final String packageName = "mindustry.gen";
private String path;
private int round;
@@ -39,8 +39,8 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
.getParent().getParent().getParent().getParent().getParent().getParent().toString();
path = path.replace("%20", " ");
processSounds("Sounds", path + "/assets/sounds", "io.anuke.arc.audio.Sound");
processSounds("Musics", path + "/assets/music", "io.anuke.arc.audio.Music");
processSounds("Sounds", path + "/assets/sounds", "arc.audio.Sound");
processSounds("Musics", path + "/assets/music", "arc.audio.Music");
processUI(roundEnv.getElementsAnnotatedWith(StyleDefaults.class));
return true;
@@ -75,7 +75,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
suffix = suffix.isEmpty() ? "" : "-" + suffix;
String sfilen = filename + suffix;
String dtype = p.getFileName().toString().endsWith(".9.png") ? "io.anuke.arc.scene.style.NinePatchDrawable" : "io.anuke.arc.scene.style.TextureRegionDrawable";
String dtype = p.getFileName().toString().endsWith(".9.png") ? "arc.scene.style.NinePatchDrawable" : "arc.scene.style.TextureRegionDrawable";
String varname = capitalize(sfilen);
TypeSpec.Builder ttype = type;
@@ -100,7 +100,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
t.getEnclosedElements().stream().filter(e -> e.getKind() == ElementKind.FIELD).forEach(field -> {
String fname = field.getSimpleName().toString();
if(fname.startsWith("default")){
loadStyles.addStatement("io.anuke.arc.Core.scene.addStyle(" + field.asType().toString() + ".class, io.anuke.mindustry.ui.Styles." + fname + ")");
loadStyles.addStatement("io.anuke.arc.Core.scene.addStyle(" + field.asType().toString() + ".class, mindustry.ui.Styles." + fname + ")");
}
});
}
@@ -142,11 +142,11 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
dispose.addStatement("io.anuke.arc.Core.assets.unload(" + filename + ")");
dispose.addStatement(name + " = null");
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), name, Modifier.STATIC, Modifier.PUBLIC).initializer("new io.anuke.arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), name, Modifier.STATIC, Modifier.PUBLIC).initializer("new arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
});
if(classname.equals("Sounds")){
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), "none", Modifier.STATIC, Modifier.PUBLIC).initializer("new io.anuke.arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), "none", Modifier.STATIC, Modifier.PUBLIC).initializer("new arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
}
type.addMethod(loadBegin.build());

View File

@@ -1,9 +1,9 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.sun.source.util.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
import io.anuke.annotations.Annotations.*;
import mindustry.annotations.Annotations.*;
import javax.annotation.processing.*;
import javax.lang.model.*;

View File

@@ -1,4 +1,4 @@
package io.anuke.annotations;
package mindustry.annotations;
import java.util.ArrayList;

View File

@@ -1,4 +1,4 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.sun.source.tree.*;
import com.sun.source.util.TreePathScanner;
@@ -9,7 +9,7 @@ import com.sun.tools.javac.code.Symbol.MethodSymbol;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCTypeApply;
import io.anuke.annotations.Annotations.CallSuper;
import mindustry.annotations.Annotations.CallSuper;
import java.lang.annotation.Annotation;

View File

@@ -1,7 +1,7 @@
package io.anuke.annotations;
package mindustry.annotations;
import io.anuke.annotations.Annotations.ReadClass;
import io.anuke.annotations.Annotations.WriteClass;
import mindustry.annotations.Annotations.ReadClass;
import mindustry.annotations.Annotations.WriteClass;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
@@ -11,8 +11,8 @@ import java.util.HashMap;
import java.util.Set;
/**
* This class finds reader and writer methods annotated by the {@link io.anuke.annotations.Annotations.WriteClass}
* and {@link io.anuke.annotations.Annotations.ReadClass} annotations.
* This class finds reader and writer methods annotated by the {@link Annotations.WriteClass}
* and {@link Annotations.ReadClass} annotations.
*/
public class IOFinder{

View File

@@ -1,6 +1,6 @@
package io.anuke.annotations;
package mindustry.annotations;
import io.anuke.annotations.Annotations.*;
import mindustry.annotations.Annotations.*;
import javax.lang.model.element.ExecutableElement;

View File

@@ -1,9 +1,9 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.squareup.javapoet.*;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.annotations.IOFinder.ClassSerializer;
import mindustry.annotations.Annotations.Loc;
import mindustry.annotations.Annotations.Remote;
import mindustry.annotations.IOFinder.ClassSerializer;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
@@ -16,9 +16,9 @@ import java.util.stream.Collectors;
/** The annotation processor for generating remote method call code. */
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedAnnotationTypes({
"io.anuke.annotations.Annotations.Remote",
"io.anuke.annotations.Annotations.WriteClass",
"io.anuke.annotations.Annotations.ReadClass",
"mindustry.annotations.Annotations.Remote",
"mindustry.annotations.Annotations.WriteClass",
"mindustry.annotations.Annotations.ReadClass",
})
public class RemoteMethodAnnotationProcessor extends AbstractProcessor{
/** Maximum size of each event packet. */
@@ -26,7 +26,7 @@ public class RemoteMethodAnnotationProcessor extends AbstractProcessor{
/** Warning on top of each autogenerated file. */
public static final String autogenWarning = "Autogenerated file. Do not modify!\n";
/** Name of the base package to put all the generated classes. */
private static final String packageName = "io.anuke.mindustry.gen";
private static final String packageName = "mindustry.gen";
/** Name of class that handles reading and invoking packets on the server. */
private static final String readServerName = "RemoteReadServer";

View File

@@ -1,7 +1,7 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.squareup.javapoet.*;
import io.anuke.annotations.IOFinder.ClassSerializer;
import mindustry.annotations.IOFinder.ClassSerializer;
import javax.lang.model.element.*;
import javax.tools.Diagnostic.Kind;
@@ -47,7 +47,7 @@ public class RemoteReadGenerator{
Constructor<TypeName> cons = TypeName.class.getDeclaredConstructor(String.class);
cons.setAccessible(true);
TypeName playerType = cons.newInstance("io.anuke.mindustry.entities.type.Player");
TypeName playerType = cons.newInstance("mindustry.entities.type.Player");
//add player parameter
readMethod.addParameter(playerType, "player");
}

View File

@@ -1,8 +1,8 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.squareup.javapoet.*;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.IOFinder.ClassSerializer;
import mindustry.annotations.Annotations.Loc;
import mindustry.annotations.IOFinder.ClassSerializer;
import javax.lang.model.element.*;
import javax.tools.Diagnostic.Kind;
@@ -77,7 +77,7 @@ public class RemoteWriteGenerator{
return;
}
if(!elem.getParameters().get(0).asType().toString().equals("io.anuke.mindustry.entities.type.Player")){
if(!elem.getParameters().get(0).asType().toString().equals("mindustry.entities.type.Player")){
Utils.messager.printMessage(Kind.ERROR, "Client invoke methods should have a first parameter of type Player.", elem);
return;
}
@@ -85,12 +85,12 @@ public class RemoteWriteGenerator{
//if toAll is false, it's a 'send to one player' variant, so add the player as a parameter
if(!toAll){
method.addParameter(ClassName.bestGuess("io.anuke.mindustry.net.NetConnection"), "playerConnection");
method.addParameter(ClassName.bestGuess("mindustry.net.NetConnection"), "playerConnection");
}
//add sender to ignore
if(forwarded){
method.addParameter(ClassName.bestGuess("io.anuke.mindustry.net.NetConnection"), "exceptConnection");
method.addParameter(ClassName.bestGuess("mindustry.net.NetConnection"), "exceptConnection");
}
//call local method if applicable, shouldn't happen when forwarding method as that already happens by default
@@ -127,7 +127,7 @@ public class RemoteWriteGenerator{
method.beginControlFlow("if(" + getCheckString(methodEntry.where) + ")");
//add statement to create packet from pool
method.addStatement("$1N packet = $2N.obtain($1N.class, $1N::new)", "io.anuke.mindustry.net.Packets.InvokePacket", "io.anuke.arc.util.pooling.Pools");
method.addStatement("$1N packet = $2N.obtain($1N.class, $1N::new)", "mindustry.net.Packets.InvokePacket", "arc.util.pooling.Pools");
//assign buffer
method.addStatement("packet.writeBuffer = TEMP_BUFFER");
//assign priority
@@ -206,7 +206,7 @@ public class RemoteWriteGenerator{
//send the actual packet
method.addStatement(sendString + "packet, " +
(methodEntry.unreliable ? "io.anuke.mindustry.net.Net.SendMode.udp" : "io.anuke.mindustry.net.Net.SendMode.tcp") + ")");
(methodEntry.unreliable ? "mindustry.net.Net.SendMode.udp" : "mindustry.net.Net.SendMode.tcp") + ")");
//end check for server/client

View File

@@ -1,7 +1,7 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.squareup.javapoet.*;
import io.anuke.annotations.Annotations.*;
import mindustry.annotations.Annotations.*;
import javax.annotation.processing.*;
import javax.lang.model.*;
@@ -14,12 +14,12 @@ import java.util.*;
import java.util.zip.*;
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedAnnotationTypes("io.anuke.annotations.Annotations.Serialize")
@SupportedAnnotationTypes("mindustry.annotations.Annotations.Serialize")
public class SerializeAnnotationProcessor extends AbstractProcessor{
/** Target class name. */
private static final String className = "Serialization";
/** Name of the base package to put all the generated classes. */
private static final String packageName = "io.anuke.mindustry.gen";
private static final String packageName = "mindustry.gen";
private int round;

View File

@@ -1,8 +1,8 @@
package io.anuke.annotations;
package mindustry.annotations;
import com.squareup.javapoet.*;
import io.anuke.annotations.Annotations.Struct;
import io.anuke.annotations.Annotations.StructField;
import mindustry.annotations.Annotations.Struct;
import mindustry.annotations.Annotations.StructField;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
@@ -19,11 +19,11 @@ import java.util.Set;
*/
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedAnnotationTypes({
"io.anuke.annotations.Annotations.Struct"
"mindustry.annotations.Annotations.Struct"
})
public class StructAnnotationProcessor extends AbstractProcessor{
/** Name of the base package to put all the generated classes. */
private static final String packageName = "io.anuke.mindustry.gen";
private static final String packageName = "mindustry.gen";
private int round;
@Override

View File

@@ -1,4 +1,4 @@
package io.anuke.annotations;
package mindustry.annotations;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;

View File

@@ -1,5 +1,5 @@
io.anuke.annotations.RemoteMethodAnnotationProcessor
io.anuke.annotations.SerializeAnnotationProcessor
io.anuke.annotations.StructAnnotationProcessor
io.anuke.annotations.CallSuperAnnotationProcessor
io.anuke.annotations.AssetsAnnotationProcessor
mindustry.annotations.RemoteMethodAnnotationProcessor
mindustry.annotations.SerializeAnnotationProcessor
mindustry.annotations.StructAnnotationProcessor
mindustry.annotations.CallSuperAnnotationProcessor
mindustry.annotations.AssetsAnnotationProcessor