Skip to content

Commit

Permalink
Fix some new array dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Jun 12, 2024
1 parent 72ca712 commit 458fcec
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,24 @@ private Expression convertExpressionImpl(JCExpression javac) {
if (type instanceof ArrayType childArrayType) {
arrayType = childArrayType;
if( this.ast.apiLevel >= AST.JLS8_INTERNAL) {
arrayType.dimensions().addFirst(this.ast.newDimension());
var extraDimensions = jcNewArray.getDimAnnotations().stream()
.map(annotations -> annotations.stream().map(this::convert).toList())
.map(annotations -> {
Dimension dim = this.ast.newDimension();
dim.annotations().addAll(annotations);
int startOffset = annotations.stream().mapToInt(Annotation::getStartPosition).min().orElse(-1);
int endOffset = annotations.stream().mapToInt(ann -> ann.getStartPosition() + ann.getLength()).max().orElse(-1);
dim.setSourceRange(startOffset, endOffset - startOffset);
return dim;
})
.toList();
if (arrayType.dimensions().isEmpty()) {
arrayType.dimensions().addAll(extraDimensions);
} else {
var lastDimension = arrayType.dimensions().removeFirst();
arrayType.dimensions().addAll(extraDimensions);
arrayType.dimensions().add(lastDimension);
}
} else {
arrayType = this.ast.newArrayType(childArrayType);
}
Expand Down Expand Up @@ -2429,7 +2446,8 @@ Type convertToType(JCTree javac) {
res = this.ast.newSimpleType(convertName(simpleType.getName()));
commonSettings(res, javac);
}
} else {
}
if (res == null) { // nothing specific
res = convertToType(jcAnnotatedType.getUnderlyingType());
}
if (res instanceof AnnotatableType annotatableType && this.ast.apiLevel() >= AST.JLS8) {
Expand Down

0 comments on commit 458fcec

Please sign in to comment.