Don't output trailing spaces in Printer
Also don't output trailing empty lines in TestGenerator
This commit is contained in:
+6
@@ -10,7 +10,13 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
<module name="generators" />
|
<module name="generators" />
|
||||||
<envs />
|
<envs />
|
||||||
|
<RunnerSettings RunnerId="Debug">
|
||||||
|
<option name="DEBUG_PORT" value="" />
|
||||||
|
<option name="TRANSPORT" value="0" />
|
||||||
|
<option name="LOCAL" value="true" />
|
||||||
|
</RunnerSettings>
|
||||||
<RunnerSettings RunnerId="Run" />
|
<RunnerSettings RunnerId="Run" />
|
||||||
|
<ConfigurationWrapper RunnerId="Debug" />
|
||||||
<ConfigurationWrapper RunnerId="Run" />
|
<ConfigurationWrapper RunnerId="Run" />
|
||||||
<method />
|
<method />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -71,14 +71,18 @@ public class Printer {
|
|||||||
if (withholdIndentOnce) {
|
if (withholdIndentOnce) {
|
||||||
withholdIndentOnce = false;
|
withholdIndentOnce = false;
|
||||||
}
|
}
|
||||||
else {
|
else if (objects.length > 0) {
|
||||||
append(indent);
|
printIndent();
|
||||||
}
|
}
|
||||||
printWithNoIndent(objects);
|
printWithNoIndent(objects);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printIndent() {
|
||||||
|
append(indent);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Printer printWithNoIndent(Object... objects) {
|
public Printer printWithNoIndent(Object... objects) {
|
||||||
for (Object object : objects) {
|
for (Object object : objects) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TestGenerator {
|
public class TestGenerator {
|
||||||
@@ -156,19 +157,24 @@ public class TestGenerator {
|
|||||||
p.pushIndent();
|
p.pushIndent();
|
||||||
|
|
||||||
Collection<TestMethodModel> testMethods = testClassModel.getTestMethods();
|
Collection<TestMethodModel> testMethods = testClassModel.getTestMethods();
|
||||||
|
Collection<TestClassModel> innerTestClasses = testClassModel.getInnerTestClasses();
|
||||||
|
|
||||||
for (TestMethodModel testMethodModel : testMethods) {
|
for (Iterator<TestMethodModel> iterator = testMethods.iterator(); iterator.hasNext(); ) {
|
||||||
|
TestMethodModel testMethodModel = iterator.next();
|
||||||
generateTestMethod(p, testMethodModel);
|
generateTestMethod(p, testMethodModel);
|
||||||
p.println();
|
if (iterator.hasNext() || !innerTestClasses.isEmpty()) {
|
||||||
|
p.println();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<TestClassModel> innerTestClasses = testClassModel.getInnerTestClasses();
|
for (Iterator<TestClassModel> iterator = innerTestClasses.iterator(); iterator.hasNext(); ) {
|
||||||
for (TestClassModel innerTestClass : innerTestClasses) {
|
TestClassModel innerTestClass = iterator.next();
|
||||||
if (innerTestClass.isEmpty()) {
|
if (!innerTestClass.isEmpty()) {
|
||||||
continue;
|
generateTestClass(p, innerTestClass, true);
|
||||||
|
if (iterator.hasNext()) {
|
||||||
|
p.println();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
generateTestClass(p, innerTestClass, true);
|
|
||||||
p.println();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.popIndent();
|
p.popIndent();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.utils.Printer;
|
import org.jetbrains.jet.utils.Printer;
|
||||||
|
|
||||||
|
import javax.annotation.PreDestroy;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -109,7 +110,7 @@ public class DependencyInjectorGenerator {
|
|||||||
p.println("}"); // class
|
p.println("}"); // class
|
||||||
|
|
||||||
importManager.addClass(NotNull.class);
|
importManager.addClass(NotNull.class);
|
||||||
importManager.addClass(javax.annotation.PreDestroy.class);
|
importManager.addClass(PreDestroy.class);
|
||||||
StringBuilder imports = new StringBuilder();
|
StringBuilder imports = new StringBuilder();
|
||||||
generateImports(new Printer(imports), injectorPackageName);
|
generateImports(new Printer(imports), injectorPackageName);
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ public class DependencyInjectorGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generatePreamble(String injectorPackageName, Printer p) throws IOException {
|
private static void generatePreamble(String injectorPackageName, Printer p) throws IOException {
|
||||||
String copyright = "injector-generator/copyright.txt";
|
String copyright = "injector-generator/copyright.txt";
|
||||||
p.println(FileUtil.loadFile(new File(copyright)));
|
p.println(FileUtil.loadFile(new File(copyright)));
|
||||||
|
|
||||||
@@ -252,7 +253,7 @@ public class DependencyInjectorGenerator {
|
|||||||
p.pushIndent();
|
p.pushIndent();
|
||||||
for (Iterator<Parameter> iterator = parameters.iterator(); iterator.hasNext(); ) {
|
for (Iterator<Parameter> iterator = parameters.iterator(); iterator.hasNext(); ) {
|
||||||
Parameter parameter = iterator.next();
|
Parameter parameter = iterator.next();
|
||||||
p.print(); // indent
|
p.printIndent();
|
||||||
if (parameter.isRequired()) {
|
if (parameter.isRequired()) {
|
||||||
p.printWithNoIndent("@NotNull ");
|
p.printWithNoIndent("@NotNull ");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user