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" />
|
||||
<module name="generators" />
|
||||
<envs />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="" />
|
||||
<option name="TRANSPORT" value="0" />
|
||||
<option name="LOCAL" value="true" />
|
||||
</RunnerSettings>
|
||||
<RunnerSettings RunnerId="Run" />
|
||||
<ConfigurationWrapper RunnerId="Debug" />
|
||||
<ConfigurationWrapper RunnerId="Run" />
|
||||
<method />
|
||||
</configuration>
|
||||
|
||||
@@ -71,14 +71,18 @@ public class Printer {
|
||||
if (withholdIndentOnce) {
|
||||
withholdIndentOnce = false;
|
||||
}
|
||||
else {
|
||||
append(indent);
|
||||
else if (objects.length > 0) {
|
||||
printIndent();
|
||||
}
|
||||
printWithNoIndent(objects);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void printIndent() {
|
||||
append(indent);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Printer printWithNoIndent(Object... objects) {
|
||||
for (Object object : objects) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestGenerator {
|
||||
@@ -156,19 +157,24 @@ public class TestGenerator {
|
||||
p.pushIndent();
|
||||
|
||||
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);
|
||||
p.println();
|
||||
if (iterator.hasNext() || !innerTestClasses.isEmpty()) {
|
||||
p.println();
|
||||
}
|
||||
}
|
||||
|
||||
Collection<TestClassModel> innerTestClasses = testClassModel.getInnerTestClasses();
|
||||
for (TestClassModel innerTestClass : innerTestClasses) {
|
||||
if (innerTestClass.isEmpty()) {
|
||||
continue;
|
||||
for (Iterator<TestClassModel> iterator = innerTestClasses.iterator(); iterator.hasNext(); ) {
|
||||
TestClassModel innerTestClass = iterator.next();
|
||||
if (!innerTestClass.isEmpty()) {
|
||||
generateTestClass(p, innerTestClass, true);
|
||||
if (iterator.hasNext()) {
|
||||
p.println();
|
||||
}
|
||||
}
|
||||
generateTestClass(p, innerTestClass, true);
|
||||
p.println();
|
||||
}
|
||||
|
||||
p.popIndent();
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -109,7 +110,7 @@ public class DependencyInjectorGenerator {
|
||||
p.println("}"); // class
|
||||
|
||||
importManager.addClass(NotNull.class);
|
||||
importManager.addClass(javax.annotation.PreDestroy.class);
|
||||
importManager.addClass(PreDestroy.class);
|
||||
StringBuilder imports = new StringBuilder();
|
||||
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";
|
||||
p.println(FileUtil.loadFile(new File(copyright)));
|
||||
|
||||
@@ -252,7 +253,7 @@ public class DependencyInjectorGenerator {
|
||||
p.pushIndent();
|
||||
for (Iterator<Parameter> iterator = parameters.iterator(); iterator.hasNext(); ) {
|
||||
Parameter parameter = iterator.next();
|
||||
p.print(); // indent
|
||||
p.printIndent();
|
||||
if (parameter.isRequired()) {
|
||||
p.printWithNoIndent("@NotNull ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user