Skip to content

Commit e31da7d

Browse files
committed
Minor formatter changes to reduce whitespace. Actually, it seems as though most of it was intentional originally. I just think it's ugly looking.
1 parent aa5aa15 commit e31da7d

2 files changed

Lines changed: 48 additions & 22 deletions

File tree

codemodel/src/main/java/com/sun/codemodel/JDefinedClass.java

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -807,38 +807,67 @@ public void declare(JFormatter f) {
807807
* prints the body of a class.
808808
*/
809809
protected void declareBody(JFormatter f) {
810-
f.p('{').nl().nl().i();
810+
f.p('{').nl().i();
811811
boolean first = true;
812812

813813
if (!enumConstantsByName.isEmpty()) {
814-
for (JEnumConstant c : enumConstantsByName.values()) {
815-
if (!first) f.p(',').nl();
814+
for (JEnumConstant c : enumConstantsByName.values()) {
815+
if (!first) { f.p(',').nl();}
816+
else { first = false; }
816817
f.d(c);
817-
first = false;
818818
}
819819
f.p(';').nl();
820820
}
821821

822-
for( JFieldVar field : fields.values() )
822+
for (JFieldVar field : fields.values()) {
823823
f.d(field);
824-
if (init != null)
825-
f.nl().p("static").s(init);
826-
if (instanceInit != null)
827-
f.nl().s(instanceInit);
828-
for (JMethod m : constructors) {
829-
f.nl().d(m);
824+
first = false;
830825
}
831-
for (JMethod m : methods) {
832-
f.nl().d(m);
826+
827+
if (init != null) {
828+
if (!first) { f.nl(); }
829+
else { first = false; }
830+
f.p("static").s(init);
831+
}
832+
833+
if (instanceInit != null) {
834+
if (!first) { f.nl(); }
835+
else { first = false; }
836+
f.s(instanceInit);
837+
}
838+
839+
for (JMethod m : constructors) {
840+
if (!first) { f.nl(); }
841+
else { first = false; }
842+
f.d(m);
843+
}
844+
845+
for (JMethod m : methods) {
846+
if (!first) { f.nl(); }
847+
else { first = false; }
848+
f.d(m);
833849
}
834-
if(classes!=null)
835-
for (JDefinedClass dc : classes.values())
836-
f.nl().d(dc);
837850

851+
if (classes != null) {
852+
for (JDefinedClass dc : classes.values()) {
853+
if (!first) { f.nl(); }
854+
else { first = false; }
855+
f.d(dc);
856+
}
857+
}
838858

839-
if (directBlock != null)
859+
if (directBlock != null) {
860+
if (!first) { f.nl(); }
861+
else { first = false; }
840862
f.p(directBlock);
841-
f.nl().o().p('}').nl();
863+
}
864+
865+
// handle empty classes
866+
if (first) {
867+
f.nl();
868+
}
869+
870+
f.o().p('}').nl();
842871
}
843872

844873
/**

codemodel/src/main/java/com/sun/codemodel/JDocComment.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,11 @@ public Map<String,String> addXdoclet(String name, String attribute, String value
172172
}
173173

174174
public void generate(JFormatter f) {
175-
// I realized that we can't use StringTokenizer because
176-
// this will recognize multiple \n as one token.
177-
178175
f.p("/**").nl();
179176

177+
// prints the main body
180178
format(f," * ");
181179

182-
f.p(" * ").nl();
183180
for (Map.Entry<String,JCommentPart> e : atParams.entrySet()) {
184181
f.p(" * @param ").p(e.getKey()).nl();
185182
e.getValue().format(f,INDENT);

0 commit comments

Comments
 (0)