mirror of
https://github.com/apple/pkl.git
synced 2026-03-27 19:41:18 +01:00
Address warning diagnostics (#1395)
This addressess various warning diagnostics throughout the codebase.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,9 @@ public class Annotation extends AbstractNode {
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(0);
|
||||
var ret = (Type) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable ObjectBody getBody() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,12 +54,16 @@ public final class Class extends AbstractNode {
|
||||
|
||||
public Keyword getClassKeyword() {
|
||||
assert children != null;
|
||||
return (Keyword) children.get(keywordOffset);
|
||||
var ret = (Keyword) children.get(keywordOffset);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Identifier getName() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(keywordOffset + 1);
|
||||
var ret = (Identifier) children.get(keywordOffset + 1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeParameterList getTypeParameterList() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,9 @@ public class ClassMethod extends AbstractNode {
|
||||
|
||||
public Identifier getName() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(nameOffset);
|
||||
var ret = (Identifier) children.get(nameOffset);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeParameterList getTypeParameterList() {
|
||||
@@ -67,7 +69,9 @@ public class ClassMethod extends AbstractNode {
|
||||
|
||||
public ParameterList getParameterList() {
|
||||
assert children != null;
|
||||
return (ParameterList) children.get(nameOffset + 2);
|
||||
var ret = (ParameterList) children.get(nameOffset + 2);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,9 @@ public final class ClassProperty extends AbstractNode {
|
||||
|
||||
public Identifier getName() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(nameOffset);
|
||||
var ret = (Identifier) children.get(nameOffset);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package org.pkl.parser.syntax;
|
||||
import java.util.List;
|
||||
import org.pkl.parser.ParserVisitor;
|
||||
import org.pkl.parser.Span;
|
||||
import org.pkl.parser.util.Nullable;
|
||||
|
||||
public final class DocComment extends AbstractNode {
|
||||
private final List<Span> spans;
|
||||
@@ -38,7 +37,7 @@ public final class DocComment extends AbstractNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @Nullable T accept(ParserVisitor<? extends T> visitor) {
|
||||
public <T> T accept(ParserVisitor<? extends T> visitor) {
|
||||
return visitor.visitDocComment(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import org.pkl.parser.ParserVisitor;
|
||||
import org.pkl.parser.Span;
|
||||
import org.pkl.parser.util.Nullable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr(Span span, @Nullable List<? extends @Nullable Node> children) {
|
||||
@@ -200,7 +201,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +219,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +240,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public StringConstant getImportStr() {
|
||||
assert children != null;
|
||||
return (StringConstant) children.get(0);
|
||||
var ret = (StringConstant) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean isGlob() {
|
||||
@@ -258,7 +265,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ReadType getReadType() {
|
||||
@@ -285,7 +294,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(0);
|
||||
var ret = (Identifier) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable ArgumentList getArgumentList() {
|
||||
@@ -314,12 +325,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(1);
|
||||
var ret = (Identifier) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
@@ -344,7 +359,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(0);
|
||||
var ret = (Identifier) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable ArgumentList getArgumentList() {
|
||||
@@ -365,7 +382,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getArg() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,12 +400,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getArg() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(1);
|
||||
var ret = (Expr) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,17 +425,23 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getCond() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getThen() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(1);
|
||||
var ret = (Expr) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getEls() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(2);
|
||||
var ret = (Expr) children.get(2);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,17 +457,23 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Parameter getParameter() {
|
||||
assert children != null;
|
||||
return (Parameter) children.get(0);
|
||||
var ret = (Parameter) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getBindingExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(1);
|
||||
var ret = (Expr) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(2);
|
||||
var ret = (Expr) children.get(2);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,12 +489,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public ParameterList getParameterList() {
|
||||
assert children != null;
|
||||
return (ParameterList) children.get(0);
|
||||
var ret = (ParameterList) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(1);
|
||||
var ret = (Expr) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,7 +514,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,7 +537,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public ObjectBody getBody() {
|
||||
assert children != null;
|
||||
return (ObjectBody) children.get(1);
|
||||
var ret = (ObjectBody) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Span newSpan() {
|
||||
@@ -516,12 +559,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ObjectBody getBody() {
|
||||
assert children != null;
|
||||
return (ObjectBody) children.get(1);
|
||||
var ret = (ObjectBody) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +584,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +602,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +620,9 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,12 +641,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getLeft() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Expr getRight() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(1);
|
||||
var ret = (Expr) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Operator getOp() {
|
||||
@@ -608,12 +665,12 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
BinaryOperatorExpr binaryOp = (BinaryOperatorExpr) o;
|
||||
return Objects.deepEquals(children, binaryOp.children)
|
||||
&& op == binaryOp.op
|
||||
@@ -638,12 +695,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(1);
|
||||
var ret = (Type) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,12 +720,16 @@ public abstract sealed class Expr extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(1);
|
||||
var ret = (Type) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,9 @@ public class ExtendsOrAmendsClause extends AbstractNode {
|
||||
|
||||
public StringConstant getUrl() {
|
||||
assert children != null;
|
||||
return (StringConstant) children.get(0);
|
||||
var ret = (StringConstant) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
@@ -58,12 +60,12 @@ public class ExtendsOrAmendsClause extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,12 +56,12 @@ public final class Identifier extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
Identifier identifier = (Identifier) o;
|
||||
return Objects.equals(value, identifier.value) && Objects.equals(span, identifier.span);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,9 @@ public final class ImportClause extends AbstractNode {
|
||||
|
||||
public StringConstant getImportStr() {
|
||||
assert children != null;
|
||||
return (StringConstant) children.get(0);
|
||||
var ret = (StringConstant) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean isGlob() {
|
||||
@@ -57,12 +59,12 @@ public final class ImportClause extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,12 +44,12 @@ public final class Modifier extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
Modifier modifier = (Modifier) o;
|
||||
return value == modifier.value && Objects.equals(span, modifier.span);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,6 +83,8 @@ public final class ModuleDecl extends AbstractNode {
|
||||
if (extendsOrAmends != null) {
|
||||
return start.endWith(extendsOrAmends.span());
|
||||
}
|
||||
return start.endWith(children.get(nameOffset + 1).span());
|
||||
var end = children.get(nameOffset + 1);
|
||||
assert end != null;
|
||||
return start.endWith(end.span());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import org.pkl.parser.ParserVisitor;
|
||||
import org.pkl.parser.Span;
|
||||
import org.pkl.parser.util.Nullable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public ObjectMember(Span span, @Nullable List<? extends @Nullable Node> children) {
|
||||
@@ -40,7 +41,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +68,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(identifierOffset);
|
||||
var ret = (Identifier) children.get(identifierOffset);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||
@@ -106,12 +111,16 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Keyword getFunctionKeyword() {
|
||||
assert children != null;
|
||||
return (Keyword) children.get(identifierOffset);
|
||||
var ret = (Keyword) children.get(identifierOffset);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(identifierOffset + 1);
|
||||
var ret = (Identifier) children.get(identifierOffset + 1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeParameterList getTypeParameterList() {
|
||||
@@ -121,7 +130,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public ParameterList getParamList() {
|
||||
assert children != null;
|
||||
return (ParameterList) children.get(identifierOffset + 3);
|
||||
var ret = (ParameterList) children.get(identifierOffset + 3);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||
@@ -131,7 +142,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(identifierOffset + 5);
|
||||
var ret = (Expr) children.get(identifierOffset + 5);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@@ -147,7 +160,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
Span end;
|
||||
var typeAnnotation = children.get(identifierOffset + 4);
|
||||
if (typeAnnotation == null) {
|
||||
end = children.get(identifierOffset + 3).span();
|
||||
var stop = children.get(identifierOffset + 3);
|
||||
assert stop != null;
|
||||
end = stop.span();
|
||||
} else {
|
||||
end = typeAnnotation.span();
|
||||
}
|
||||
@@ -168,7 +183,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getPred() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable Expr getExpr() {
|
||||
@@ -195,7 +212,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getKey() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable Expr getValue() {
|
||||
@@ -225,7 +244,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
@@ -247,12 +268,12 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
@@ -279,12 +300,16 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getPredicate() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ObjectBody getThenClause() {
|
||||
assert children != null;
|
||||
return (ObjectBody) children.get(1);
|
||||
var ret = (ObjectBody) children.get(1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable ObjectBody getElseClause() {
|
||||
@@ -306,7 +331,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Parameter getP1() {
|
||||
assert children != null;
|
||||
return (Parameter) children.get(0);
|
||||
var ret = (Parameter) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable Parameter getP2() {
|
||||
@@ -316,12 +343,16 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(2);
|
||||
var ret = (Expr) children.get(2);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ObjectBody getBody() {
|
||||
assert children != null;
|
||||
return (ObjectBody) children.get(3);
|
||||
var ret = (ObjectBody) children.get(3);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Span forSpan() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,9 @@ public abstract sealed class Parameter extends AbstractNode {
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(0);
|
||||
var ret = (Identifier) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,12 +45,12 @@ public class StringConstant extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,12 +52,12 @@ public abstract sealed class StringPart extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
@@ -78,7 +78,9 @@ public abstract sealed class StringPart extends AbstractNode {
|
||||
|
||||
public Expr getExpr() {
|
||||
assert children != null;
|
||||
return (Expr) children.get(0);
|
||||
var ret = (Expr) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,7 +73,9 @@ public abstract sealed class Type extends AbstractNode {
|
||||
|
||||
public StringConstant getStr() {
|
||||
assert children != null;
|
||||
return (StringConstant) children.get(0);
|
||||
var ret = (StringConstant) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +91,9 @@ public abstract sealed class Type extends AbstractNode {
|
||||
|
||||
public QualifiedIdentifier getName() {
|
||||
assert children != null;
|
||||
return (QualifiedIdentifier) children.get(0);
|
||||
var ret = (QualifiedIdentifier) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeArgumentList getArgs() {
|
||||
@@ -110,7 +114,9 @@ public abstract sealed class Type extends AbstractNode {
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(0);
|
||||
var ret = (Type) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +132,9 @@ public abstract sealed class Type extends AbstractNode {
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(0);
|
||||
var ret = (Type) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +150,9 @@ public abstract sealed class Type extends AbstractNode {
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(0);
|
||||
var ret = (Type) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -190,12 +200,12 @@ public abstract sealed class Type extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
@@ -227,7 +237,9 @@ public abstract sealed class Type extends AbstractNode {
|
||||
|
||||
public Type getRet() {
|
||||
assert children != null;
|
||||
return (Type) children.get(children.size() - 1);
|
||||
var ret = (Type) children.get(children.size() - 1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import org.pkl.parser.ParserVisitor;
|
||||
import org.pkl.parser.Span;
|
||||
import org.pkl.parser.util.Nullable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class TypeAlias extends AbstractNode {
|
||||
private final int modifiersOffset;
|
||||
private final int nameOffset;
|
||||
@@ -54,12 +55,16 @@ public final class TypeAlias extends AbstractNode {
|
||||
|
||||
public Keyword getTypealiasKeyword() {
|
||||
assert children != null;
|
||||
return (Keyword) children.get(nameOffset);
|
||||
var ret = (Keyword) children.get(nameOffset);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Identifier getName() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(nameOffset + 1);
|
||||
var ret = (Identifier) children.get(nameOffset + 1);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public @Nullable TypeParameterList getTypeParameterList() {
|
||||
@@ -69,7 +74,9 @@ public final class TypeAlias extends AbstractNode {
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(nameOffset + 3);
|
||||
var ret = (Type) children.get(nameOffset + 3);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@@ -83,7 +90,9 @@ public final class TypeAlias extends AbstractNode {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var end = children.get(nameOffset + 1).span();
|
||||
var endNode = children.get(nameOffset + 1);
|
||||
assert endNode != null;
|
||||
var end = endNode.span();
|
||||
var tparList = children.get(nameOffset + 2);
|
||||
if (tparList != null) {
|
||||
end = tparList.span();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,6 +32,8 @@ public class TypeAnnotation extends AbstractNode {
|
||||
|
||||
public Type getType() {
|
||||
assert children != null;
|
||||
return (Type) children.get(0);
|
||||
var ret = (Type) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,9 @@ public final class TypeParameter extends AbstractNode {
|
||||
|
||||
public Identifier getIdentifier() {
|
||||
assert children != null;
|
||||
return (Identifier) children.get(0);
|
||||
var ret = (Identifier) children.get(0);
|
||||
assert ret != null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,12 +60,12 @@ public final class TypeParameter extends AbstractNode {
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,19 +71,6 @@ class GenericSexpRenderer(code: String) {
|
||||
buf.append(')')
|
||||
}
|
||||
|
||||
private fun renderQualifiedAccess(node: Node) {
|
||||
var children = node.children
|
||||
if (children.last().type == NodeType.UNQUALIFIED_ACCESS_EXPR) {
|
||||
children = children.dropLast(1) + collectChildren(children.last())
|
||||
}
|
||||
val toRender = mutableListOf<Node>()
|
||||
for (child in children) {
|
||||
if (child.type in IGNORED_CHILDREN || child.type == NodeType.OPERATOR) continue
|
||||
toRender += child
|
||||
}
|
||||
doRender(name(node), toRender)
|
||||
}
|
||||
|
||||
private fun renderDefaultUnionType(node: Node) {
|
||||
buf.append(tab)
|
||||
buf.append("(defaultUnionType\n")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -1092,7 +1092,7 @@ class SexpRenderer {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun sortModuleEntries(mod: org.pkl.parser.syntax.Module): List<Node> {
|
||||
private fun sortModuleEntries(mod: Module): List<Node> {
|
||||
val res = mutableListOf<Node>()
|
||||
res += mod.classes
|
||||
res += mod.typeAliases
|
||||
|
||||
Reference in New Issue
Block a user