Skip to content

Commit c49fc3b

Browse files
CesarCoelhoclaude
andcommitted
Add fallback comments for generated composite fields and classes
Generated composite fields and the composite class itself were emitted without a Javadoc comment when the XML carried no comment, producing "no comment" warnings. Fall back to "The <name> field." and "The <name> structure." respectively when the XML comment is absent, while still using the XML comment when present. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2b0573d commit c49fc3b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

api-generator/generator-java/src/main/java/esa/mo/tools/stubgen/java/JavaClassWriter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ public void addClassVariable(boolean isStatic, boolean isFinal, String scope, Co
144144

145145
protected void addClassVariable(boolean isDeprecated, boolean isStatic, boolean isFinal, String scope,
146146
CompositeField field, boolean isObject, boolean isArray, String initialValue) throws IOException {
147-
addMultilineComment(1, false, field.getComment(), false);
147+
String fieldComment = field.getComment();
148+
if (fieldComment == null || fieldComment.isEmpty()) {
149+
fieldComment = "The " + field.getFieldName() + " field.";
150+
}
151+
addMultilineComment(1, false, fieldComment, false);
148152

149153
StringBuilder buf = new StringBuilder(scope);
150154
buf.append(" ");

api-generator/generator-java/src/main/java/esa/mo/tools/stubgen/java/JavaCompositeClass.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ public void createCompositeClass(File folder, AreaType area, ServiceType service
8282
List<CompositeField> superCompElements = generator.createCompositeSuperElementsList(file, parentType);
8383

8484
boolean abstractComposite = (composite.getShortFormPart() == null);
85+
String compositeComment = composite.getComment();
86+
if (compositeComment == null || compositeComment.isEmpty()) {
87+
compositeComment = "The " + className + " structure.";
88+
}
8589
file.addClassOpenStatement(className, !abstractComposite, abstractComposite,
86-
parentClass, parentInterface, composite.getComment());
90+
parentClass, parentInterface, compositeComment);
8791
String fqName = generator.createElementType(area.getName(), serviceName, className);
8892

8993
if (!abstractComposite) {

0 commit comments

Comments
 (0)