Skip to content

Commit 3ad6ee1

Browse files
committed
Fix failing test (#976)
1 parent 84ea159 commit 3ad6ee1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/gr/uom/java/xmi/UMLModelASTReader.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,12 @@ private void processRecordDeclaration(CompilationUnit cu, RecordDeclaration reco
466466
if(recordDeclaration.isPackageMemberTypeDeclaration()) {
467467
umlClass.setPackageDeclaration(umlPackage);
468468
umlClass.setPackageDeclarationJavadoc(packageDoc);
469+
boolean isLastType = cu.types().get(cu.types().size()-1).equals(recordDeclaration);
469470
for(UMLComment comment : comments) {
470471
if(comment.getLocationInfo().before(locationInfo) && !locationInfo.nextLine(comment.getLocationInfo())) {
471472
umlClass.getPackageDeclarationComments().add(comment);
472473
}
473-
else if(locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
474+
else if(isLastType && locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
474475
umlClass.getPackageDeclarationComments().add(comment);
475476
}
476477
}
@@ -572,11 +573,12 @@ private void processAnnotationTypeDeclaration(CompilationUnit cu, AnnotationType
572573
if(annotationDeclaration.isPackageMemberTypeDeclaration()) {
573574
umlClass.setPackageDeclaration(umlPackage);
574575
umlClass.setPackageDeclarationJavadoc(packageDoc);
576+
boolean isLastType = cu.types().get(cu.types().size()-1).equals(annotationDeclaration);
575577
for(UMLComment comment : comments) {
576578
if(comment.getLocationInfo().before(locationInfo) && !locationInfo.nextLine(comment.getLocationInfo())) {
577579
umlClass.getPackageDeclarationComments().add(comment);
578580
}
579-
else if(locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
581+
else if(isLastType && locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
580582
umlClass.getPackageDeclarationComments().add(comment);
581583
}
582584
}
@@ -635,11 +637,12 @@ private void processEnumDeclaration(CompilationUnit cu, EnumDeclaration enumDecl
635637
if(enumDeclaration.isPackageMemberTypeDeclaration()) {
636638
umlClass.setPackageDeclaration(umlPackage);
637639
umlClass.setPackageDeclarationJavadoc(packageDoc);
640+
boolean isLastType = cu.types().get(cu.types().size()-1).equals(enumDeclaration);
638641
for(UMLComment comment : comments) {
639642
if(comment.getLocationInfo().before(locationInfo) && !locationInfo.nextLine(comment.getLocationInfo())) {
640643
umlClass.getPackageDeclarationComments().add(comment);
641644
}
642-
else if(locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
645+
else if(isLastType && locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
643646
umlClass.getPackageDeclarationComments().add(comment);
644647
}
645648
}
@@ -769,11 +772,12 @@ private void processTypeDeclaration(CompilationUnit cu, TypeDeclaration typeDecl
769772
if(typeDeclaration.isPackageMemberTypeDeclaration()) {
770773
umlClass.setPackageDeclaration(umlPackage);
771774
umlClass.setPackageDeclarationJavadoc(packageDoc);
775+
boolean isLastType = cu.types().get(cu.types().size()-1).equals(typeDeclaration);
772776
for(UMLComment comment : comments) {
773777
if(comment.getLocationInfo().before(locationInfo) && !locationInfo.nextLine(comment.getLocationInfo())) {
774778
umlClass.getPackageDeclarationComments().add(comment);
775779
}
776-
else if(locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
780+
else if(isLastType && locationInfo.getEndLine() < comment.getLocationInfo().getStartLine()) {
777781
umlClass.getPackageDeclarationComments().add(comment);
778782
}
779783
}

0 commit comments

Comments
 (0)