From 616199d10f569b7cfa4e496fccc100acfc28b37b Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Sat, 27 Jan 2024 15:04:42 +0100 Subject: [PATCH] merge aftermath, regeneration of models --- javaparser-core-generators/pom.xml | 2 +- javaparser-core-metamodel-generator/pom.xml | 2 +- javaparser-core-serialization/pom.xml | 2 +- .../JavaParserJsonSerializerTest.java | 8 +- javaparser-core-testing-bdd/pom.xml | 2 +- javaparser-core-testing/pom.xml | 2 +- javaparser-core/bnd.bnd | 1 + javaparser-core/pom.xml | 2 +- .../github/javaparser/JavaParserAdapter.java | 49 +- .../UnicodeEscapeProcessingProvider.java | 6 +- .../ast/nodeTypes/NodeWithParameters.java | 6 +- .../ast/visitor/NodeFinderVisitor.java | 5096 ++++++++--------- .../javaparser/jml/JmlDocSanitizer.java | 6 +- .../javaparser/jml/StringConstructor.java | 1 + .../metamodel/JmlBeginStmtMetaModel.java | 2 +- .../JmlBinaryInfixExprMetaModel.java | 2 +- .../JmlBodyDeclarationMetaModel.java | 2 +- .../metamodel/JmlCallableClauseMetaModel.java | 2 +- ...mlClassAccessibleDeclarationMetaModel.java | 2 +- .../JmlClassExprDeclarationMetaModel.java | 2 +- .../metamodel/JmlClassLevelMetaModel.java | 2 +- .../metamodel/JmlClauseLabelMetaModel.java | 2 +- .../metamodel/JmlClauseMetaModel.java | 2 +- .../metamodel/JmlContractMetaModel.java | 2 +- .../metamodel/JmlDocDeclarationMetaModel.java | 2 +- .../javaparser/metamodel/JmlDocMetaModel.java | 2 +- .../metamodel/JmlDocStmtMetaModel.java | 2 +- .../metamodel/JmlDocTypeMetaModel.java | 2 +- .../metamodel/JmlEndStmtMetaModel.java | 2 +- .../metamodel/JmlExpressionStmtMetaModel.java | 2 +- .../JmlFieldDeclarationMetaModel.java | 2 +- .../metamodel/JmlForallClauseMetaModel.java | 2 +- .../metamodel/JmlGhostStmtMetaModel.java | 2 +- .../metamodel/JmlLabelExprMetaModel.java | 2 +- .../metamodel/JmlLabelStmtMetaModel.java | 2 +- .../metamodel/JmlLetExprMetaModel.java | 2 +- .../JmlMethodDeclarationMetaModel.java | 2 +- .../JmlMultiCompareExprMetaModel.java | 2 +- .../JmlMultiExprClauseMetaModel.java | 2 +- .../metamodel/JmlOldClauseMetaModel.java | 2 +- .../metamodel/JmlQuantifiedExprMetaModel.java | 2 +- .../metamodel/JmlRefiningStmtMetaModel.java | 2 +- .../JmlRepresentsDeclarationMetaModel.java | 2 +- .../JmlSetComprehensionMetaModel.java | 2 +- .../metamodel/JmlSignalsClauseMetaModel.java | 2 +- .../JmlSignalsOnlyClauseMetaModel.java | 2 +- .../JmlSimpleExprClauseMetaModel.java | 2 +- .../metamodel/JmlStatementMetaModel.java | 2 +- .../metamodel/JmlTypeExprMetaModel.java | 2 +- .../JmlUnreachableStmtMetaModel.java | 2 +- .../printer/ConcreteSyntaxModel.java | 16 +- .../github/javaparser/printer/DotPrinter.java | 2 - .../LexicalPreservingPrinter.java | 219 +- .../LookaheadIterator.java | 4 +- .../lexicalpreservation/PeekingIterator.java | 91 +- .../ReshuffledDiffElementExtractor.java | 83 +- .../javaparser/resolution/cache/Cache.java | 5 +- .../resolution/cache/CacheStats.java | 261 +- .../logic/FunctionalInterfaceLogic.java | 9 +- .../logic/MethodResolutionLogic.java | 6 +- .../ResolvedTypeParameterValueProvider.java | 12 +- .../github/javaparser/utils/VisitorList.java | 1 - .../github/javaparser/utils/VisitorSet.java | 1 - javaparser-symbol-solver-core/pom.xml | 2 +- javaparser-symbol-solver-testing/pom.xml | 2 +- jmlparser-jml-pretty/pom.xml | 2 +- jmlparser-jml-tests/pom.xml | 2 +- jmlparser-jml-tools/pom.xml | 4 +- pom.xml | 2 +- 69 files changed, 2931 insertions(+), 3050 deletions(-) diff --git a/javaparser-core-generators/pom.xml b/javaparser-core-generators/pom.xml index 9a56f540b2..0eb000901c 100644 --- a/javaparser-core-generators/pom.xml +++ b/javaparser-core-generators/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-core-metamodel-generator/pom.xml b/javaparser-core-metamodel-generator/pom.xml index 6e5b226e56..ef7bad1dd5 100644 --- a/javaparser-core-metamodel-generator/pom.xml +++ b/javaparser-core-metamodel-generator/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-core-serialization/pom.xml b/javaparser-core-serialization/pom.xml index 64b6bbd016..0ef06f80e8 100644 --- a/javaparser-core-serialization/pom.xml +++ b/javaparser-core-serialization/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-core-serialization/src/test/java/com/github/javaparser/serialization/JavaParserJsonSerializerTest.java b/javaparser-core-serialization/src/test/java/com/github/javaparser/serialization/JavaParserJsonSerializerTest.java index cefa335f62..5c8baad740 100644 --- a/javaparser-core-serialization/src/test/java/com/github/javaparser/serialization/JavaParserJsonSerializerTest.java +++ b/javaparser-core-serialization/src/test/java/com/github/javaparser/serialization/JavaParserJsonSerializerTest.java @@ -22,11 +22,13 @@ import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Node; +import com.google.common.truth.Truth; +import jakarta.json.Json; +import jakarta.json.stream.JsonGenerator; +import jakarta.json.stream.JsonGeneratorFactory; +import org.junit.Assume; import org.junit.jupiter.api.Test; -import javax.json.Json; -import javax.json.stream.JsonGenerator; -import javax.json.stream.JsonGeneratorFactory; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; diff --git a/javaparser-core-testing-bdd/pom.xml b/javaparser-core-testing-bdd/pom.xml index 6ecd784b68..7ebacafe64 100644 --- a/javaparser-core-testing-bdd/pom.xml +++ b/javaparser-core-testing-bdd/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-core-testing/pom.xml b/javaparser-core-testing/pom.xml index 8ed367b401..d224b1dd7a 100644 --- a/javaparser-core-testing/pom.xml +++ b/javaparser-core-testing/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-core/bnd.bnd b/javaparser-core/bnd.bnd index 49fd627317..0ecf072686 100644 --- a/javaparser-core/bnd.bnd +++ b/javaparser-core/bnd.bnd @@ -41,6 +41,7 @@ Bundle-SymbolicName: com.github.javaparser.javaparser-core com.github.javaparser.printer.lexicalpreservation.changes, \ com.github.javaparser.quality, \ com.github.javaparser.resolution, \ + com.github.javaparser.resolution.cache, \ com.github.javaparser.resolution.declarations, \ com.github.javaparser.resolution.logic, \ com.github.javaparser.resolution.model, \ diff --git a/javaparser-core/pom.xml b/javaparser-core/pom.xml index 253a202099..4cef6d311e 100644 --- a/javaparser-core/pom.xml +++ b/javaparser-core/pom.xml @@ -3,7 +3,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-core/src/main/java/com/github/javaparser/JavaParserAdapter.java b/javaparser-core/src/main/java/com/github/javaparser/JavaParserAdapter.java index e12b4414ab..b391bd1c18 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/JavaParserAdapter.java +++ b/javaparser-core/src/main/java/com/github/javaparser/JavaParserAdapter.java @@ -17,7 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ - package com.github.javaparser; import com.github.javaparser.ast.CompilationUnit; @@ -38,7 +37,6 @@ import com.github.javaparser.ast.type.Type; import com.github.javaparser.ast.type.TypeParameter; import com.github.javaparser.javadoc.Javadoc; - import java.io.*; import java.nio.file.Path; import java.util.Objects; @@ -79,82 +77,81 @@ private T handleResult(ParseResult result) { if (result.isSuccessful()) { return result.getResult().orElse(null); } - throw new ParseProblemException(result.getProblems()); } - + public ParserConfiguration getParserConfiguration() { return parser.getParserConfiguration(); } - + public CompilationUnit parse(InputStream in) { return handleResult(getParser().parse(in)); } - + public CompilationUnit parse(File file) throws FileNotFoundException { return handleResult(getParser().parse(file)); } - + public CompilationUnit parse(Path path) throws IOException { return handleResult(getParser().parse(path)); } - + public CompilationUnit parse(Reader reader) { return handleResult(getParser().parse(reader)); } - + public CompilationUnit parse(String code) { return handleResult(getParser().parse(code)); } - + public CompilationUnit parseResource(String path) throws IOException { return handleResult(getParser().parseResource(path)); } - + public BlockStmt parseBlock(String blockStatement) { return handleResult(getParser().parseBlock(blockStatement)); } - + public Statement parseStatement(String statement) { return handleResult(getParser().parseStatement(statement)); } - + public ImportDeclaration parseImport(String importDeclaration) { return handleResult(getParser().parseImport(importDeclaration)); } - + public T parseExpression(String expression) { return handleResult(getParser().parseExpression(expression)); } - + public AnnotationExpr parseAnnotation(String annotation) { return handleResult(getParser().parseAnnotation(annotation)); } - + public BodyDeclaration parseAnnotationBodyDeclaration(String body) { return handleResult(getParser().parseAnnotationBodyDeclaration(body)); } - + public BodyDeclaration parseBodyDeclaration(String body) { return handleResult(getParser().parseBodyDeclaration(body)); } - + public ClassOrInterfaceType parseClassOrInterfaceType(String type) { return handleResult(getParser().parseClassOrInterfaceType(type)); } - + public Type parseType(String type) { return handleResult(getParser().parseType(type)); } - + public VariableDeclarationExpr parseVariableDeclarationExpr(String declaration) { return handleResult(getParser().parseVariableDeclarationExpr(declaration)); } - + public Javadoc parseJavadoc(String content) { return JavadocParser.parse(content); } - + public ExplicitConstructorInvocationStmt parseExplicitConstructorInvocationStmt(String statement) { return handleResult(getParser().parseExplicitConstructorInvocationStmt(statement)); } @@ -162,7 +159,7 @@ public ExplicitConstructorInvocationStmt parseExplicitConstructorInvocationStmt( public Name parseName(String qualifiedName) { return handleResult(getParser().parseName(qualifiedName)); } - + public SimpleName parseSimpleName(String name) { return handleResult(getParser().parseSimpleName(name)); } @@ -170,11 +167,11 @@ public SimpleName parseSimpleName(String name) { public Parameter parseParameter(String parameter) { return handleResult(getParser().parseParameter(parameter)); } - + public PackageDeclaration parsePackageDeclaration(String packageDeclaration) { return handleResult(getParser().parsePackageDeclaration(packageDeclaration)); } - + public TypeDeclaration parseTypeDeclaration(String typeDeclaration) { return handleResult(getParser().parseTypeDeclaration(typeDeclaration)); } @@ -190,7 +187,7 @@ public ModuleDirective parseModuleDirective(String moduleDirective) { public TypeParameter parseTypeParameter(String typeParameter) { return handleResult(getParser().parseTypeParameter(typeParameter)); } - + public MethodDeclaration parseMethodDeclaration(String methodDeclaration) { return handleResult(getParser().parseMethodDeclaration(methodDeclaration)); } diff --git a/javaparser-core/src/main/java/com/github/javaparser/UnicodeEscapeProcessingProvider.java b/javaparser-core/src/main/java/com/github/javaparser/UnicodeEscapeProcessingProvider.java index b2bae8ed8d..0254069586 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/UnicodeEscapeProcessingProvider.java +++ b/javaparser-core/src/main/java/com/github/javaparser/UnicodeEscapeProcessingProvider.java @@ -348,9 +348,9 @@ public PositionUpdate lookup(Position position) { } int insertIndex = -result - 1; if (insertIndex == 0) { - // Before the first delta info, identity mapping. - return PositionUpdate.NONE; - } + // Before the first delta info, identity mapping. + return PositionUpdate.NONE; + } return _deltas.get(insertIndex - 1); } diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java index c0a79e7497..bbb519dbfb 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java +++ b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java @@ -24,11 +24,9 @@ import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.Parameter; import com.github.javaparser.ast.type.Type; - import java.util.Arrays; import java.util.Optional; import java.util.stream.Stream; - import static com.github.javaparser.StaticJavaParser.parseType; import static java.util.stream.Collectors.toList; @@ -162,8 +160,8 @@ default boolean hasParametersOfType(String... paramTypes) { * @return {@code true} if all parameters match one by one, in the given order. */ default boolean hasParametersOfType(Class... paramTypes) { - return getParameters().stream().// if p.getType() is a class or interface type, we want to consider its erasure, i.e., if the parameter - // is "List", we want to consider it as "List", so we need to call getName() + return // if p.getType() is a class or interface type, we want to consider its erasure, i.e., if the parameter + getParameters().stream().// is "List", we want to consider it as "List", so we need to call getName() map(p -> p.getType().toClassOrInterfaceType().map(NodeWithSimpleName::getNameAsString).orElseGet(() -> p.getType().asString())).collect(toList()).equals(Stream.of(paramTypes).map(Class::getSimpleName).collect(toList())); } } diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/visitor/NodeFinderVisitor.java b/javaparser-core/src/main/java/com/github/javaparser/ast/visitor/NodeFinderVisitor.java index 267b99cbd5..5744f9e6f0 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/ast/visitor/NodeFinderVisitor.java +++ b/javaparser-core/src/main/java/com/github/javaparser/ast/visitor/NodeFinderVisitor.java @@ -17,2603 +17,2501 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ +package com.github.javaparser.ast.visitor; -package com.github.javaparser.ast.visitor; - -import java.util.function.BiFunction; - -import com.github.javaparser.Range; -import com.github.javaparser.ast.ArrayCreationLevel; -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.ImportDeclaration; -import com.github.javaparser.ast.Modifier; -import com.github.javaparser.ast.Node; -import com.github.javaparser.ast.NodeList; -import com.github.javaparser.ast.PackageDeclaration; -import com.github.javaparser.ast.body.AnnotationDeclaration; -import com.github.javaparser.ast.body.AnnotationMemberDeclaration; -import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; -import com.github.javaparser.ast.body.CompactConstructorDeclaration; -import com.github.javaparser.ast.body.ConstructorDeclaration; -import com.github.javaparser.ast.body.EnumConstantDeclaration; -import com.github.javaparser.ast.body.EnumDeclaration; -import com.github.javaparser.ast.body.FieldDeclaration; -import com.github.javaparser.ast.body.InitializerDeclaration; -import com.github.javaparser.ast.body.MethodDeclaration; -import com.github.javaparser.ast.body.Parameter; -import com.github.javaparser.ast.body.ReceiverParameter; -import com.github.javaparser.ast.body.RecordDeclaration; -import com.github.javaparser.ast.body.VariableDeclarator; -import com.github.javaparser.ast.comments.BlockComment; -import com.github.javaparser.ast.comments.JavadocComment; -import com.github.javaparser.ast.comments.LineComment; -import com.github.javaparser.ast.expr.ArrayAccessExpr; -import com.github.javaparser.ast.expr.ArrayCreationExpr; -import com.github.javaparser.ast.expr.ArrayInitializerExpr; -import com.github.javaparser.ast.expr.AssignExpr; -import com.github.javaparser.ast.expr.BinaryExpr; -import com.github.javaparser.ast.expr.BooleanLiteralExpr; -import com.github.javaparser.ast.expr.CastExpr; -import com.github.javaparser.ast.expr.CharLiteralExpr; -import com.github.javaparser.ast.expr.ClassExpr; -import com.github.javaparser.ast.expr.ConditionalExpr; -import com.github.javaparser.ast.expr.DoubleLiteralExpr; -import com.github.javaparser.ast.expr.EnclosedExpr; -import com.github.javaparser.ast.expr.FieldAccessExpr; -import com.github.javaparser.ast.expr.InstanceOfExpr; -import com.github.javaparser.ast.expr.IntegerLiteralExpr; -import com.github.javaparser.ast.expr.LambdaExpr; -import com.github.javaparser.ast.expr.LongLiteralExpr; -import com.github.javaparser.ast.expr.MarkerAnnotationExpr; -import com.github.javaparser.ast.expr.MemberValuePair; -import com.github.javaparser.ast.expr.MethodCallExpr; -import com.github.javaparser.ast.expr.MethodReferenceExpr; -import com.github.javaparser.ast.expr.Name; -import com.github.javaparser.ast.expr.NameExpr; -import com.github.javaparser.ast.expr.NormalAnnotationExpr; -import com.github.javaparser.ast.expr.NullLiteralExpr; -import com.github.javaparser.ast.expr.ObjectCreationExpr; -import com.github.javaparser.ast.expr.PatternExpr; -import com.github.javaparser.ast.expr.SimpleName; -import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr; -import com.github.javaparser.ast.expr.StringLiteralExpr; -import com.github.javaparser.ast.expr.SuperExpr; -import com.github.javaparser.ast.expr.SwitchExpr; -import com.github.javaparser.ast.expr.TextBlockLiteralExpr; -import com.github.javaparser.ast.expr.ThisExpr; -import com.github.javaparser.ast.expr.TypeExpr; -import com.github.javaparser.ast.expr.UnaryExpr; -import com.github.javaparser.ast.expr.VariableDeclarationExpr; -import com.github.javaparser.ast.modules.ModuleDeclaration; -import com.github.javaparser.ast.modules.ModuleExportsDirective; -import com.github.javaparser.ast.modules.ModuleOpensDirective; -import com.github.javaparser.ast.modules.ModuleProvidesDirective; -import com.github.javaparser.ast.modules.ModuleRequiresDirective; -import com.github.javaparser.ast.modules.ModuleUsesDirective; -import com.github.javaparser.ast.stmt.AssertStmt; -import com.github.javaparser.ast.stmt.BlockStmt; -import com.github.javaparser.ast.stmt.BreakStmt; -import com.github.javaparser.ast.stmt.CatchClause; -import com.github.javaparser.ast.stmt.ContinueStmt; -import com.github.javaparser.ast.stmt.DoStmt; -import com.github.javaparser.ast.stmt.EmptyStmt; -import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; -import com.github.javaparser.ast.stmt.ExpressionStmt; -import com.github.javaparser.ast.stmt.ForEachStmt; -import com.github.javaparser.ast.stmt.ForStmt; -import com.github.javaparser.ast.stmt.IfStmt; -import com.github.javaparser.ast.stmt.LabeledStmt; -import com.github.javaparser.ast.stmt.LocalClassDeclarationStmt; -import com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt; -import com.github.javaparser.ast.stmt.ReturnStmt; -import com.github.javaparser.ast.stmt.SwitchEntry; -import com.github.javaparser.ast.stmt.SwitchStmt; -import com.github.javaparser.ast.stmt.SynchronizedStmt; -import com.github.javaparser.ast.stmt.ThrowStmt; -import com.github.javaparser.ast.stmt.TryStmt; -import com.github.javaparser.ast.stmt.UnparsableStmt; -import com.github.javaparser.ast.stmt.WhileStmt; -import com.github.javaparser.ast.stmt.YieldStmt; -import com.github.javaparser.ast.type.ArrayType; -import com.github.javaparser.ast.type.ClassOrInterfaceType; -import com.github.javaparser.ast.type.IntersectionType; -import com.github.javaparser.ast.type.PrimitiveType; -import com.github.javaparser.ast.type.TypeParameter; -import com.github.javaparser.ast.type.UnionType; -import com.github.javaparser.ast.type.UnknownType; -import com.github.javaparser.ast.type.VarType; -import com.github.javaparser.ast.type.VoidType; -import com.github.javaparser.ast.type.WildcardType; - -/* - * A visitor who applies a function (based on a range) on each node of the AST and retains the node selected by the function. - * An example usage might be to find the node that encompasses a range (the covering node). - */ -public class NodeFinderVisitor extends VoidVisitorAdapter { - - public static BiFunction fConveringNode = (Node n, Range range) -> { - return n.hasRange() && n.getRange().get().contains(range); - }; - - private Node selectedNode; - - /* - * A range-based function that is evaluated on each node of the AST until a node - * matches the function. - */ - private static BiFunction fn; - - public NodeFinderVisitor(BiFunction fn) { - this.fn = fn; - } - - /** - * Returns the covering node. If more than one nodes are covering the selection, - * the returned node is last covering node found in a top-down traversal of the - * AST - * - * @return Node - */ - public Node getSelectedNode() { - return selectedNode; - } - - @Override - public void visit(final AnnotationDeclaration n, final Range arg) { - - { - n.getMembers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final AnnotationMemberDeclaration n, final Range arg) { - - if (n.getDefaultValue().isPresent()) { - n.getDefaultValue().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ArrayAccessExpr n, final Range arg) { - - { - n.getIndex().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ArrayCreationExpr n, final Range arg) { - - { - n.getElementType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getInitializer().isPresent()) { - n.getInitializer().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getLevels().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ArrayInitializerExpr n, final Range arg) { - - { - n.getValues().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final AssertStmt n, final Range arg) { - - { - n.getCheck().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getMessage().isPresent()) { - n.getMessage().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final AssignExpr n, final Range arg) { - - { - n.getTarget().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getValue().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final BinaryExpr n, final Range arg) { - - { - n.getLeft().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getRight().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final BlockStmt n, final Range arg) { - - { - n.getStatements().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final BooleanLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final BreakStmt n, final Range arg) { - - if (n.getLabel().isPresent()) { - n.getLabel().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final CastExpr n, final Range arg) { - - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final CatchClause n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getParameter().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final CharLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - return; - } - - @Override - public void visit(final ClassExpr n, final Range arg) { - - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ClassOrInterfaceDeclaration n, final Range arg) { - - { - n.getExtendedTypes().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getImplementedTypes().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getPermittedTypes().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypeParameters().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getMembers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ClassOrInterfaceType n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getScope().isPresent()) { - n.getScope().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getTypeArguments().isPresent()) { - n.getTypeArguments().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final CompilationUnit n, final Range arg) { - - { - n.getImports().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getModule().isPresent()) { - n.getModule().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getPackageDeclaration().isPresent()) { - n.getPackageDeclaration().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypes().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ConditionalExpr n, final Range arg) { - - { - n.getCondition().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getElseExpr().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getThenExpr().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ConstructorDeclaration n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getParameters().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getReceiverParameter().isPresent()) { - n.getReceiverParameter().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getThrownExceptions().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypeParameters().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ContinueStmt n, final Range arg) { - - if (n.getLabel().isPresent()) { - n.getLabel().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final DoStmt n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getCondition().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final DoubleLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final EmptyStmt n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final EnclosedExpr n, final Range arg) { - - { - n.getInner().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final EnumConstantDeclaration n, final Range arg) { - - { - n.getArguments().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getClassBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final EnumDeclaration n, final Range arg) { - - { - n.getEntries().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getImplementedTypes().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getMembers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ExplicitConstructorInvocationStmt n, final Range arg) { - - { - n.getArguments().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getExpression().isPresent()) { - n.getExpression().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getTypeArguments().isPresent()) { - n.getTypeArguments().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ExpressionStmt n, final Range arg) { - - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final FieldAccessExpr n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getScope().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getTypeArguments().isPresent()) { - n.getTypeArguments().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final FieldDeclaration n, final Range arg) { - - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getVariables().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ForEachStmt n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getIterable().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getVariable().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ForStmt n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getCompare().isPresent()) { - n.getCompare().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getInitialization().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getUpdate().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final IfStmt n, final Range arg) { - - { - n.getCondition().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getElseStmt().isPresent()) { - n.getElseStmt().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getThenStmt().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final InitializerDeclaration n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final InstanceOfExpr n, final Range arg) { - - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getPattern().isPresent()) { - n.getPattern().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final IntegerLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - return; - } - - @Override - public void visit(final JavadocComment n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final LabeledStmt n, final Range arg) { - - { - n.getLabel().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getStatement().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final LongLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final MarkerAnnotationExpr n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final MemberValuePair n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getValue().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final MethodCallExpr n, final Range arg) { - - { - n.getArguments().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getScope().isPresent()) { - n.getScope().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getTypeArguments().isPresent()) { - n.getTypeArguments().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final MethodDeclaration n, final Range arg) { - - if (n.getBody().isPresent()) { - n.getBody().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getParameters().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getReceiverParameter().isPresent()) { - n.getReceiverParameter().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getThrownExceptions().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypeParameters().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final NameExpr n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final NormalAnnotationExpr n, final Range arg) { - - { - n.getPairs().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final NullLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ObjectCreationExpr n, final Range arg) { - - if (n.getAnonymousClassBody().isPresent()) { - n.getAnonymousClassBody().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getArguments().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getScope().isPresent()) { - n.getScope().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getTypeArguments().isPresent()) { - n.getTypeArguments().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final PackageDeclaration n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final Parameter n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getVarArgsAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final PrimitiveType n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final Name n, final Range arg) { - - if (n.getQualifier().isPresent()) { - n.getQualifier().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SimpleName n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ArrayType n, final Range arg) { - - { - n.getComponentType().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ArrayCreationLevel n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getDimension().isPresent()) { - n.getDimension().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final IntersectionType n, final Range arg) { - - { - n.getElements().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final UnionType n, final Range arg) { - - { - n.getElements().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ReturnStmt n, final Range arg) { - - if (n.getExpression().isPresent()) { - n.getExpression().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SingleMemberAnnotationExpr n, final Range arg) { - - { - n.getMemberValue().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final StringLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SuperExpr n, final Range arg) { - - if (n.getTypeName().isPresent()) { - n.getTypeName().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SwitchEntry n, final Range arg) { - - { - n.getLabels().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getStatements().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SwitchStmt n, final Range arg) { - - { - n.getEntries().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getSelector().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SynchronizedStmt n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ThisExpr n, final Range arg) { - - if (n.getTypeName().isPresent()) { - n.getTypeName().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ThrowStmt n, final Range arg) { - - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final TryStmt n, final Range arg) { - - { - n.getCatchClauses().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getFinallyBlock().isPresent()) { - n.getFinallyBlock().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getResources().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTryBlock().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final LocalClassDeclarationStmt n, final Range arg) { - - { - n.getClassDeclaration().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final LocalRecordDeclarationStmt n, final Range arg) { - - { - n.getRecordDeclaration().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final TypeParameter n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypeBound().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final UnaryExpr n, final Range arg) { - - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final UnknownType n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final VariableDeclarationExpr n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getVariables().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final VariableDeclarator n, final Range arg) { - - if (n.getInitializer().isPresent()) { - n.getInitializer().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final VoidType n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final WhileStmt n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getCondition().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final WildcardType n, final Range arg) { - - if (n.getExtendedType().isPresent()) { - n.getExtendedType().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getSuperType().isPresent()) { - n.getSuperType().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final LambdaExpr n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getParameters().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final MethodReferenceExpr n, final Range arg) { - - { - n.getScope().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getTypeArguments().isPresent()) { - n.getTypeArguments().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final TypeExpr n, final Range arg) { - - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ImportDeclaration n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final BlockComment n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final LineComment n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(NodeList n, final Range arg) { - for (final Object v : n) { - ((Node) v).accept(this, arg); - } - return; - } - - @Override - public void visit(final ModuleDeclaration n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getDirectives().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ModuleRequiresDirective n, final Range arg) { - - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override() - public void visit(final ModuleExportsDirective n, final Range arg) { - - { - n.getModuleNames().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override() - public void visit(final ModuleProvidesDirective n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getWith().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override() - public void visit(final ModuleUsesDirective n, final Range arg) { - - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ModuleOpensDirective n, final Range arg) { - - { - n.getModuleNames().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final UnparsableStmt n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final ReceiverParameter n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final VarType n, final Range arg) { - - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final Modifier n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final SwitchExpr n, final Range arg) { - - { - n.getEntries().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getSelector().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final YieldStmt n, final Range arg) { - - { - n.getExpression().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final TextBlockLiteralExpr n, final Range arg) { - - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final PatternExpr n, final Range arg) { - - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getType().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final RecordDeclaration n, final Range arg) { - - { - n.getImplementedTypes().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getParameters().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getReceiverParameter().isPresent()) { - n.getReceiverParameter().get().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypeParameters().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getMembers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - - @Override - public void visit(final CompactConstructorDeclaration n, final Range arg) { - - { - n.getBody().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getModifiers().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getName().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getThrownExceptions().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getTypeParameters().accept(this, arg); - if (selectedNode != null) - return; - } - { - n.getAnnotations().accept(this, arg); - if (selectedNode != null) - return; - } - if (n.getComment().isPresent()) { - n.getComment().get().accept(this, arg); - if (selectedNode != null) - return; - } - if (fn.apply(n, arg)) { - selectedNode = n; - } - return; - } - -} +import java.util.function.BiFunction; +import com.github.javaparser.Range; +import com.github.javaparser.ast.ArrayCreationLevel; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.CompactConstructorDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.ReceiverParameter; +import com.github.javaparser.ast.body.RecordDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.ArrayAccessExpr; +import com.github.javaparser.ast.expr.ArrayCreationExpr; +import com.github.javaparser.ast.expr.ArrayInitializerExpr; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.BinaryExpr; +import com.github.javaparser.ast.expr.BooleanLiteralExpr; +import com.github.javaparser.ast.expr.CastExpr; +import com.github.javaparser.ast.expr.CharLiteralExpr; +import com.github.javaparser.ast.expr.ClassExpr; +import com.github.javaparser.ast.expr.ConditionalExpr; +import com.github.javaparser.ast.expr.DoubleLiteralExpr; +import com.github.javaparser.ast.expr.EnclosedExpr; +import com.github.javaparser.ast.expr.FieldAccessExpr; +import com.github.javaparser.ast.expr.InstanceOfExpr; +import com.github.javaparser.ast.expr.IntegerLiteralExpr; +import com.github.javaparser.ast.expr.LambdaExpr; +import com.github.javaparser.ast.expr.LongLiteralExpr; +import com.github.javaparser.ast.expr.MarkerAnnotationExpr; +import com.github.javaparser.ast.expr.MemberValuePair; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.MethodReferenceExpr; +import com.github.javaparser.ast.expr.Name; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.NormalAnnotationExpr; +import com.github.javaparser.ast.expr.NullLiteralExpr; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.PatternExpr; +import com.github.javaparser.ast.expr.SimpleName; +import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.expr.SuperExpr; +import com.github.javaparser.ast.expr.SwitchExpr; +import com.github.javaparser.ast.expr.TextBlockLiteralExpr; +import com.github.javaparser.ast.expr.ThisExpr; +import com.github.javaparser.ast.expr.TypeExpr; +import com.github.javaparser.ast.expr.UnaryExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.modules.ModuleDeclaration; +import com.github.javaparser.ast.modules.ModuleExportsDirective; +import com.github.javaparser.ast.modules.ModuleOpensDirective; +import com.github.javaparser.ast.modules.ModuleProvidesDirective; +import com.github.javaparser.ast.modules.ModuleRequiresDirective; +import com.github.javaparser.ast.modules.ModuleUsesDirective; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForEachStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.LocalClassDeclarationStmt; +import com.github.javaparser.ast.stmt.LocalRecordDeclarationStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntry; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.UnparsableStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.stmt.YieldStmt; +import com.github.javaparser.ast.type.ArrayType; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.IntersectionType; +import com.github.javaparser.ast.type.PrimitiveType; +import com.github.javaparser.ast.type.TypeParameter; +import com.github.javaparser.ast.type.UnionType; +import com.github.javaparser.ast.type.UnknownType; +import com.github.javaparser.ast.type.VarType; +import com.github.javaparser.ast.type.VoidType; +import com.github.javaparser.ast.type.WildcardType; + +/* + * A visitor who applies a function (based on a range) on each node of the AST and retains the node selected by the function. + * An example usage might be to find the node that encompasses a range (the covering node). + */ +public class NodeFinderVisitor extends VoidVisitorAdapter { + + public static BiFunction fConveringNode = (Node n, Range range) -> { + return n.hasRange() && n.getRange().get().contains(range); + }; + + private Node selectedNode; + + /* + * A range-based function that is evaluated on each node of the AST until a node + * matches the function. + */ + private static BiFunction fn; + + public NodeFinderVisitor(BiFunction fn) { + this.fn = fn; + } + + /** + * Returns the covering node. If more than one nodes are covering the selection, + * the returned node is last covering node found in a top-down traversal of the + * AST + * + * @return Node + */ + public Node getSelectedNode() { + return selectedNode; + } + + @Override + public void visit(final AnnotationDeclaration n, final Range arg) { + { + n.getMembers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final AnnotationMemberDeclaration n, final Range arg) { + if (n.getDefaultValue().isPresent()) { + n.getDefaultValue().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ArrayAccessExpr n, final Range arg) { + { + n.getIndex().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ArrayCreationExpr n, final Range arg) { + { + n.getElementType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getInitializer().isPresent()) { + n.getInitializer().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getLevels().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ArrayInitializerExpr n, final Range arg) { + { + n.getValues().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final AssertStmt n, final Range arg) { + { + n.getCheck().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getMessage().isPresent()) { + n.getMessage().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final AssignExpr n, final Range arg) { + { + n.getTarget().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getValue().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final BinaryExpr n, final Range arg) { + { + n.getLeft().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getRight().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final BlockStmt n, final Range arg) { + { + n.getStatements().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final BooleanLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final BreakStmt n, final Range arg) { + if (n.getLabel().isPresent()) { + n.getLabel().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final CastExpr n, final Range arg) { + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final CatchClause n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getParameter().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final CharLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + return; + } + + @Override + public void visit(final ClassExpr n, final Range arg) { + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ClassOrInterfaceDeclaration n, final Range arg) { + { + n.getExtendedTypes().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getImplementedTypes().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getPermittedTypes().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypeParameters().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getMembers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ClassOrInterfaceType n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getScope().isPresent()) { + n.getScope().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getTypeArguments().isPresent()) { + n.getTypeArguments().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final CompilationUnit n, final Range arg) { + { + n.getImports().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getModule().isPresent()) { + n.getModule().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getPackageDeclaration().isPresent()) { + n.getPackageDeclaration().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypes().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ConditionalExpr n, final Range arg) { + { + n.getCondition().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getElseExpr().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getThenExpr().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ConstructorDeclaration n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getParameters().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getReceiverParameter().isPresent()) { + n.getReceiverParameter().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getThrownExceptions().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypeParameters().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ContinueStmt n, final Range arg) { + if (n.getLabel().isPresent()) { + n.getLabel().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final DoStmt n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getCondition().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final DoubleLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final EmptyStmt n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final EnclosedExpr n, final Range arg) { + { + n.getInner().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final EnumConstantDeclaration n, final Range arg) { + { + n.getArguments().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getClassBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final EnumDeclaration n, final Range arg) { + { + n.getEntries().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getImplementedTypes().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getMembers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ExplicitConstructorInvocationStmt n, final Range arg) { + { + n.getArguments().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getExpression().isPresent()) { + n.getExpression().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getTypeArguments().isPresent()) { + n.getTypeArguments().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ExpressionStmt n, final Range arg) { + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final FieldAccessExpr n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getScope().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getTypeArguments().isPresent()) { + n.getTypeArguments().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final FieldDeclaration n, final Range arg) { + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getVariables().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ForEachStmt n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getIterable().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getVariable().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ForStmt n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getCompare().isPresent()) { + n.getCompare().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getInitialization().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getUpdate().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final IfStmt n, final Range arg) { + { + n.getCondition().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getElseStmt().isPresent()) { + n.getElseStmt().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getThenStmt().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final InitializerDeclaration n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final InstanceOfExpr n, final Range arg) { + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getPattern().isPresent()) { + n.getPattern().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final IntegerLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + return; + } + + @Override + public void visit(final JavadocComment n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final LabeledStmt n, final Range arg) { + { + n.getLabel().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getStatement().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final LongLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final MarkerAnnotationExpr n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final MemberValuePair n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getValue().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final MethodCallExpr n, final Range arg) { + { + n.getArguments().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getScope().isPresent()) { + n.getScope().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getTypeArguments().isPresent()) { + n.getTypeArguments().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final MethodDeclaration n, final Range arg) { + if (n.getBody().isPresent()) { + n.getBody().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getParameters().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getReceiverParameter().isPresent()) { + n.getReceiverParameter().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getThrownExceptions().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypeParameters().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final NameExpr n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final NormalAnnotationExpr n, final Range arg) { + { + n.getPairs().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final NullLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ObjectCreationExpr n, final Range arg) { + if (n.getAnonymousClassBody().isPresent()) { + n.getAnonymousClassBody().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getArguments().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getScope().isPresent()) { + n.getScope().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getTypeArguments().isPresent()) { + n.getTypeArguments().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final PackageDeclaration n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final Parameter n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getVarArgsAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final PrimitiveType n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final Name n, final Range arg) { + if (n.getQualifier().isPresent()) { + n.getQualifier().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SimpleName n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ArrayType n, final Range arg) { + { + n.getComponentType().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ArrayCreationLevel n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getDimension().isPresent()) { + n.getDimension().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final IntersectionType n, final Range arg) { + { + n.getElements().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final UnionType n, final Range arg) { + { + n.getElements().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ReturnStmt n, final Range arg) { + if (n.getExpression().isPresent()) { + n.getExpression().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SingleMemberAnnotationExpr n, final Range arg) { + { + n.getMemberValue().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final StringLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SuperExpr n, final Range arg) { + if (n.getTypeName().isPresent()) { + n.getTypeName().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SwitchEntry n, final Range arg) { + { + n.getLabels().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getStatements().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SwitchStmt n, final Range arg) { + { + n.getEntries().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getSelector().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SynchronizedStmt n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ThisExpr n, final Range arg) { + if (n.getTypeName().isPresent()) { + n.getTypeName().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ThrowStmt n, final Range arg) { + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final TryStmt n, final Range arg) { + { + n.getCatchClauses().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getFinallyBlock().isPresent()) { + n.getFinallyBlock().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getResources().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTryBlock().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final LocalClassDeclarationStmt n, final Range arg) { + { + n.getClassDeclaration().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final LocalRecordDeclarationStmt n, final Range arg) { + { + n.getRecordDeclaration().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final TypeParameter n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypeBound().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final UnaryExpr n, final Range arg) { + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final UnknownType n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final VariableDeclarationExpr n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getVariables().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final VariableDeclarator n, final Range arg) { + if (n.getInitializer().isPresent()) { + n.getInitializer().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final VoidType n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final WhileStmt n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getCondition().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final WildcardType n, final Range arg) { + if (n.getExtendedType().isPresent()) { + n.getExtendedType().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getSuperType().isPresent()) { + n.getSuperType().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final LambdaExpr n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getParameters().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final MethodReferenceExpr n, final Range arg) { + { + n.getScope().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getTypeArguments().isPresent()) { + n.getTypeArguments().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final TypeExpr n, final Range arg) { + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ImportDeclaration n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final BlockComment n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final LineComment n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(NodeList n, final Range arg) { + for (final Object v : n) { + ((Node) v).accept(this, arg); + } + return; + } + + @Override + public void visit(final ModuleDeclaration n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getDirectives().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ModuleRequiresDirective n, final Range arg) { + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override() + public void visit(final ModuleExportsDirective n, final Range arg) { + { + n.getModuleNames().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override() + public void visit(final ModuleProvidesDirective n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getWith().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override() + public void visit(final ModuleUsesDirective n, final Range arg) { + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ModuleOpensDirective n, final Range arg) { + { + n.getModuleNames().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final UnparsableStmt n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final ReceiverParameter n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final VarType n, final Range arg) { + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final Modifier n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final SwitchExpr n, final Range arg) { + { + n.getEntries().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getSelector().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final YieldStmt n, final Range arg) { + { + n.getExpression().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final TextBlockLiteralExpr n, final Range arg) { + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final PatternExpr n, final Range arg) { + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getType().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final RecordDeclaration n, final Range arg) { + { + n.getImplementedTypes().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getParameters().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getReceiverParameter().isPresent()) { + n.getReceiverParameter().get().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypeParameters().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getMembers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } + + @Override + public void visit(final CompactConstructorDeclaration n, final Range arg) { + { + n.getBody().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getModifiers().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getName().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getThrownExceptions().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getTypeParameters().accept(this, arg); + if (selectedNode != null) + return; + } + { + n.getAnnotations().accept(this, arg); + if (selectedNode != null) + return; + } + if (n.getComment().isPresent()) { + n.getComment().get().accept(this, arg); + if (selectedNode != null) + return; + } + if (fn.apply(n, arg)) { + selectedNode = n; + } + return; + } +} diff --git a/javaparser-core/src/main/java/com/github/javaparser/jml/JmlDocSanitizer.java b/javaparser-core/src/main/java/com/github/javaparser/jml/JmlDocSanitizer.java index 616a0143c8..108d95920a 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/jml/JmlDocSanitizer.java +++ b/javaparser-core/src/main/java/com/github/javaparser/jml/JmlDocSanitizer.java @@ -6,7 +6,6 @@ import com.github.javaparser.Token; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.jml.doc.JmlDoc; - import java.util.Collection; import java.util.Optional; import java.util.Set; @@ -17,6 +16,7 @@ * @version 1 (11/23/21) */ public record JmlDocSanitizer(Set enabledKeys) { + public String asString(NodeList jmlDocs) { return asString(jmlDocs, true); } @@ -24,7 +24,6 @@ public String asString(NodeList jmlDocs) { public String asStringJT(Collection jmlDocs, boolean emulateGlobalPosition) { if (jmlDocs.isEmpty()) return ""; - StringConstructor s = new StringConstructor(); for (JavaToken tok : jmlDocs) { if (emulateGlobalPosition) { @@ -44,7 +43,6 @@ public String asStringJT(Collection jmlDocs, boolean emulateGlobalPos public String asString(Collection jmlDocs, boolean emulateGlobalPosition) { if (jmlDocs.isEmpty()) return ""; - StringConstructor s = new StringConstructor(); for (Token tok : jmlDocs) { if (emulateGlobalPosition) { @@ -57,7 +55,6 @@ public String asString(Collection jmlDocs, boolean emulateGlobalPosition) return toSanitizedString(s.getBuffer()); } - public String asString(NodeList jmlDocs, boolean emulateGlobalPosition) { return asStringJT(jmlDocs.stream().map(JmlDoc::getContent).toList(), emulateGlobalPosition); } @@ -204,4 +201,3 @@ private static boolean isPositive(String marker) { return marker.charAt(0) == '+'; } } - diff --git a/javaparser-core/src/main/java/com/github/javaparser/jml/StringConstructor.java b/javaparser-core/src/main/java/com/github/javaparser/jml/StringConstructor.java index d4fcb4e570..c91898678e 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/jml/StringConstructor.java +++ b/javaparser-core/src/main/java/com/github/javaparser/jml/StringConstructor.java @@ -1,6 +1,7 @@ package com.github.javaparser.jml; public class StringConstructor { + private final StringBuilder sb = new StringBuilder(1024); //JavaCC starts with 1/1 diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBeginStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBeginStmtMetaModel.java index 49763773df..9f69caf338 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBeginStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBeginStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBinaryInfixExprMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBinaryInfixExprMetaModel.java index bf3f374651..c6940fa0a4 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBinaryInfixExprMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBinaryInfixExprMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBodyDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBodyDeclarationMetaModel.java index dcbe87c1a6..33b3915ce9 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBodyDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlBodyDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlCallableClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlCallableClauseMetaModel.java index c7be8ee9bf..fa8133c40f 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlCallableClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlCallableClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassAccessibleDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassAccessibleDeclarationMetaModel.java index d2e1c4039f..4aec05e71a 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassAccessibleDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassAccessibleDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassExprDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassExprDeclarationMetaModel.java index 2225098c94..a0ca91e3ce 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassExprDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassExprDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassLevelMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassLevelMetaModel.java index de818a5712..35256e78af 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassLevelMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClassLevelMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseLabelMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseLabelMetaModel.java index 0e5e38e526..fb844d2c80 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseLabelMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseLabelMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseMetaModel.java index 99a172de5b..d2f5556aae 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlContractMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlContractMetaModel.java index 7cc6571e78..993efe6cc2 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlContractMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlContractMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocDeclarationMetaModel.java index 55390668cd..ac72a8263f 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocMetaModel.java index 853d271298..d8f4d6cc81 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocStmtMetaModel.java index b20e6b3b21..6ddb15962d 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocTypeMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocTypeMetaModel.java index 5d0706ceee..61dd17fce7 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocTypeMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlDocTypeMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlEndStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlEndStmtMetaModel.java index 8ec753714d..23a01b3c2a 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlEndStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlEndStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlExpressionStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlExpressionStmtMetaModel.java index a92feb529d..31755e5e40 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlExpressionStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlExpressionStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlFieldDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlFieldDeclarationMetaModel.java index ba66ec8f8d..4753467a5c 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlFieldDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlFieldDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlForallClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlForallClauseMetaModel.java index a73869c051..78dd442f6c 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlForallClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlForallClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlGhostStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlGhostStmtMetaModel.java index a62798aabf..aa8ca5972e 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlGhostStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlGhostStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelExprMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelExprMetaModel.java index 54af2b1a58..7ee44c1612 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelExprMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelExprMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelStmtMetaModel.java index 0d650c67db..4445a4ea6b 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLabelStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLetExprMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLetExprMetaModel.java index 48373052b6..b8645d357c 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLetExprMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlLetExprMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMethodDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMethodDeclarationMetaModel.java index ab9104ebce..81784c4728 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMethodDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMethodDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiCompareExprMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiCompareExprMetaModel.java index cc184c3d7c..3f465da67e 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiCompareExprMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiCompareExprMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiExprClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiExprClauseMetaModel.java index fe62e1674f..6435fb6bd6 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiExprClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlMultiExprClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlOldClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlOldClauseMetaModel.java index 3010c75c33..2bc5e8dafd 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlOldClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlOldClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlQuantifiedExprMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlQuantifiedExprMetaModel.java index 8c4caa67a7..fa6dde646c 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlQuantifiedExprMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlQuantifiedExprMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRefiningStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRefiningStmtMetaModel.java index f07c412628..cd59527579 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRefiningStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRefiningStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRepresentsDeclarationMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRepresentsDeclarationMetaModel.java index 8efba2da26..30c286d5ab 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRepresentsDeclarationMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlRepresentsDeclarationMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSetComprehensionMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSetComprehensionMetaModel.java index ed5ae64101..9fb7108338 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSetComprehensionMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSetComprehensionMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsClauseMetaModel.java index 755dda4cde..a6e47c8ec1 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsOnlyClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsOnlyClauseMetaModel.java index 90eff29856..8adf427978 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsOnlyClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSignalsOnlyClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSimpleExprClauseMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSimpleExprClauseMetaModel.java index b8786bb80a..1edab8a92c 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSimpleExprClauseMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlSimpleExprClauseMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlStatementMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlStatementMetaModel.java index 38450f5297..8eb9628861 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlStatementMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlStatementMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlTypeExprMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlTypeExprMetaModel.java index 84b78cdc0a..260398ca75 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlTypeExprMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlTypeExprMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlUnreachableStmtMetaModel.java b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlUnreachableStmtMetaModel.java index 823e613595..bf2703eee3 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlUnreachableStmtMetaModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/metamodel/JmlUnreachableStmtMetaModel.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2007-2010 Júlio Vilmar Gesser. - * Copyright (C) 2011, 2013-2023 The JavaParser Team. + * Copyright (C) 2011, 2013-2024 The JavaParser Team. * * This file is part of JavaParser. * diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/ConcreteSyntaxModel.java b/javaparser-core/src/main/java/com/github/javaparser/printer/ConcreteSyntaxModel.java index f09057f007..7137871eaf 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/ConcreteSyntaxModel.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/ConcreteSyntaxModel.java @@ -102,11 +102,11 @@ private static CsmElement typeArguments() { concreteSyntaxModelByClass.put(ReceiverParameter.class, sequence(comment(), list(ObservableProperty.ANNOTATIONS, space(), none(), space()), child(ObservableProperty.TYPE), space(), child(ObservableProperty.NAME))); // FIXME: we should introduce a derived property // FIXME: we should introduce a derived property + // FIXME: we should introduce a derived property concreteSyntaxModelByClass.// FIXME: we should introduce a derived property put(// FIXME: we should introduce a derived property - VariableDeclarator.class, // FIXME: we should introduce a derived property - sequence(// list(ObservableProperty.EXTRA_ARRAY_LEVELS), - comment(), child(ObservableProperty.NAME), conditional(ObservableProperty.INITIALIZER, IS_PRESENT, sequence(space(), token(GeneratedJavaParserConstants.ASSIGN), space(), child(ObservableProperty.INITIALIZER))))); + VariableDeclarator.class, // list(ObservableProperty.EXTRA_ARRAY_LEVELS), + sequence(comment(), child(ObservableProperty.NAME), conditional(ObservableProperty.INITIALIZER, IS_PRESENT, sequence(space(), token(GeneratedJavaParserConstants.ASSIGN), space(), child(ObservableProperty.INITIALIZER))))); // / // / Expressions // / @@ -210,11 +210,13 @@ private static CsmElement typeArguments() { concreteSyntaxModelByClass.put(JmlSimpleExprClause.class, sequence(child(ObservableProperty.KIND), child(HEAPS), space(), child(EXPRESSION), semicolon(), newline())); concreteSyntaxModelByClass.put(JmlMultiExprClause.class, sequence(child(ObservableProperty.KIND), child(HEAPS), space(), child(EXPRESSION), semicolon(), newline())); concreteSyntaxModelByClass.put(JmlClauseLabel.class, sequence(child(ObservableProperty.KIND), token(LPAREN), child(LABEL), token(RPAREN), space(), child(EXPRESSION), semicolon(), newline())); - concreteSyntaxModelByClass.put(JmlCallableClause.class, //space(), + //space(), + concreteSyntaxModelByClass.//space(), + put(//space(), + JmlCallableClause.class, //space(), sequence(//space(), - child(MODIFIERS), //space(), - token(CALLABLE), //child(EXPRESSION), - semicolon())); + child(MODIFIERS), //child(EXPRESSION), + token(CALLABLE), semicolon())); concreteSyntaxModelByClass.put(JmlClassExprDeclaration.class, sequence(child(MODIFIERS), attribute(KIND), space(), attribute(NAME), token(COLON), child(EXPRESSION), semicolon())); concreteSyntaxModelByClass.put(JmlBodyDeclaration.class, sequence()); concreteSyntaxModelByClass.put(JmlClassAccessibleDeclaration.class, sequence()); diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/DotPrinter.java b/javaparser-core/src/main/java/com/github/javaparser/printer/DotPrinter.java index c17f4a35a6..cb43b81308 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/DotPrinter.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/DotPrinter.java @@ -24,9 +24,7 @@ import com.github.javaparser.ast.NodeList; import com.github.javaparser.metamodel.NodeMetaModel; import com.github.javaparser.metamodel.PropertyMetaModel; - import java.util.List; - import static com.github.javaparser.utils.Utils.SYSTEM_EOL; import static com.github.javaparser.utils.Utils.assertNotNull; import static java.util.stream.Collectors.toList; diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LexicalPreservingPrinter.java b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LexicalPreservingPrinter.java index 00414440bf..123f186921 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LexicalPreservingPrinter.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LexicalPreservingPrinter.java @@ -26,12 +26,10 @@ import static com.github.javaparser.utils.Utils.decapitalize; import static java.util.Comparator.comparing; import static java.util.stream.Collectors.toList; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.util.*; - import com.github.javaparser.JavaToken; import com.github.javaparser.Range; import com.github.javaparser.ast.DataKey; @@ -110,7 +108,7 @@ public static N setup(N node) { * Returns true if the lexical preserving printer is initialized on the node */ public static boolean isAvailableOn(Node node) { - return node.containsData(NODE_TEXT_DATA); + return node.containsData(NODE_TEXT_DATA); } // @@ -134,10 +132,11 @@ public void concretePropertyChange(Node observedNode, ObservableProperty propert if (property == ObservableProperty.COMMENT) { Optional parentNode = observedNode.getParentNode(); NodeText nodeText = parentNode.map(parent -> getOrCreateNodeText(parentNode.get())).orElseGet(() -> getOrCreateNodeText(observedNode)); - if (oldValue == null) { // this case corresponds to the addition of a comment - int index = parentNode.isPresent() ? // Find the position of the comment node and put in front of it the [...] - nodeText.findChild(observedNode) : // - 0; + if (oldValue == null) { + // this case corresponds to the addition of a comment + int index = // Find the position of the comment node and put in front of it the [...] + parentNode.isPresent() ? // + nodeText.findChild(observedNode) : 0; /* Add the same indentation to the comment as the previous node * for example if we want to add a comment on the body of the method declaration : * Actual code @@ -163,7 +162,8 @@ public void concretePropertyChange(Node observedNode, ObservableProperty propert nodeText.addElement(index++, makeCommentToken((Comment) newValue)); nodeText.addToken(index, eolTokenKind(lineSeparator), lineSeparator.asRawString()); // code indentation after inserting an eol token may be wrong - } else if (newValue == null) { // this case corresponds to a deletion of a comment + } else if (newValue == null) { + // this case corresponds to a deletion of a comment if (oldValue instanceof Comment) { if (((Comment) oldValue).isOrphan()) { nodeText = getOrCreateNodeText(observedNode); @@ -171,18 +171,18 @@ public void concretePropertyChange(Node observedNode, ObservableProperty propert int index = getIndexOfComment((Comment) oldValue, nodeText); nodeText.removeElement(index); if (isCompleteLine(nodeText.getElements(), index)) { - removeAllExtraCharacters(nodeText.getElements(), index); + removeAllExtraCharacters(nodeText.getElements(), index); } else { - removeAllExtraCharactersStartingFrom(nodeText.getElements().listIterator(index)); + removeAllExtraCharactersStartingFrom(nodeText.getElements().listIterator(index)); } -// if (nodeText.getElements().get(index).isNewline()) { -// nodeText.removeElement(index); -// } + // if (nodeText.getElements().get(index).isNewline()) { + // nodeText.removeElement(index); + // } } else { throw new UnsupportedOperationException("Trying to remove something that is not a comment!"); } } else { - // this is a replacement of a comment + // this is a replacement of a comment List matchingTokens = findTokenTextElementForComment((Comment) oldValue, nodeText); if (matchingTokens.size() != 1) { throw new IllegalStateException("The matching comment to be replaced could not be found"); @@ -199,66 +199,71 @@ public void concretePropertyChange(Node observedNode, ObservableProperty propert LEXICAL_DIFFERENCE_CALCULATOR.calculatePropertyChange(nodeText, observedNode, property, oldValue, newValue); } - private boolean isCompleteLine(List elements , int index) { - if (index <= 0 || index >= elements.size()) return false; - boolean isCompleteLine=true; - ListIterator iterator = elements.listIterator(index); - // verify if elements after the index are only spaces or tabs - while(iterator.hasNext()) { - TextElement textElement = iterator.next(); - if (textElement.isNewline()) break; - if (textElement.isSpaceOrTab()) continue; - isCompleteLine=false; - break; - } - // verify if elements before the index are only spaces or tabs - iterator = elements.listIterator(index); - while(iterator.hasPrevious() && isCompleteLine) { - TextElement textElement = iterator.previous(); - if (textElement.isNewline()) break; - if (textElement.isSpaceOrTab()) continue; - isCompleteLine=false; - } - - return isCompleteLine; - } - - private void removeAllExtraCharacters(List elements , int index) { - if (index < 0 || index >= elements.size()) return; - removeAllExtraCharactersStartingFrom(elements.listIterator(index)); - removeAllExtraCharactersBeforePosition(elements.listIterator(index)); + private boolean isCompleteLine(List elements, int index) { + if (index <= 0 || index >= elements.size()) + return false; + boolean isCompleteLine = true; + ListIterator iterator = elements.listIterator(index); + // verify if elements after the index are only spaces or tabs + while (iterator.hasNext()) { + TextElement textElement = iterator.next(); + if (textElement.isNewline()) + break; + if (textElement.isSpaceOrTab()) + continue; + isCompleteLine = false; + break; + } + // verify if elements before the index are only spaces or tabs + iterator = elements.listIterator(index); + while (iterator.hasPrevious() && isCompleteLine) { + TextElement textElement = iterator.previous(); + if (textElement.isNewline()) + break; + if (textElement.isSpaceOrTab()) + continue; + isCompleteLine = false; + } + return isCompleteLine; + } + + private void removeAllExtraCharacters(List elements, int index) { + if (index < 0 || index >= elements.size()) + return; + removeAllExtraCharactersStartingFrom(elements.listIterator(index)); + removeAllExtraCharactersBeforePosition(elements.listIterator(index)); } /* * Removes all spaces,tabs characters before this position */ - private void removeAllExtraCharactersBeforePosition(ListIterator iterator) { - while(iterator.hasPrevious()) { - TextElement textElement = iterator.previous(); - if (textElement.isSpaceOrTab()) { - iterator.remove(); - continue; - } - break; - } - } - - /* + private void removeAllExtraCharactersBeforePosition(ListIterator iterator) { + while (iterator.hasPrevious()) { + TextElement textElement = iterator.previous(); + if (textElement.isSpaceOrTab()) { + iterator.remove(); + continue; + } + break; + } + } + + /* * Removes all spaces,tabs or new line characters starting from this position */ - private void removeAllExtraCharactersStartingFrom(ListIterator iterator) { - while(iterator.hasNext()) { - TextElement textElement = iterator.next(); - if (textElement.isSpaceOrTab()) { - iterator.remove(); - continue; - } - if (textElement.isNewline()) { - iterator.remove(); - } - break; - } - } + private void removeAllExtraCharactersStartingFrom(ListIterator iterator) { + while (iterator.hasNext()) { + TextElement textElement = iterator.next(); + if (textElement.isSpaceOrTab()) { + iterator.remove(); + continue; + } + if (textElement.isNewline()) { + iterator.remove(); + } + break; + } + } private TokenTextElement makeCommentToken(Comment newComment) { if (newComment.isJavadocComment()) { @@ -287,7 +292,7 @@ private int getIndexOfComment(Comment oldValue, NodeText nodeText) { private List findChildTextElementForComment(Comment oldValue, NodeText nodeText) { List matchingChildElements; - matchingChildElements = selectMatchingChildElements(oldValue, nodeText); + matchingChildElements = selectMatchingChildElements(oldValue, nodeText); if (matchingChildElements.size() > 1) { // Duplicate child nodes found, refine the result matchingChildElements = matchingChildElements.stream().filter(t -> isEqualRange(t.getChild().getRange(), oldValue.getRange())).collect(toList()); @@ -299,27 +304,26 @@ private List findChildTextElementForComment(Comment oldValue, } private List selectMatchingChildElements(Comment oldValue, NodeText nodeText) { - List result = new ArrayList<>(); - List childTextElements = nodeText.getElements().stream().filter(e -> e.isChild()) - .map(c -> (ChildTextElement) c).collect(toList()); - ListIterator iterator = childTextElements.listIterator(); - while(iterator.hasNext()) { - ChildTextElement textElement = iterator.next(); - if (textElement.isComment() && isSameComment(((Comment) textElement.getChild()), oldValue)) { - result.add(textElement); - continue; - } - Node node = textElement.getChild(); - if (node.getComment().isPresent() && isSameComment(node.getComment().get(), oldValue)) { - result.add(textElement); - continue; - } - } - return result; + List result = new ArrayList<>(); + List childTextElements = nodeText.getElements().stream().filter(e -> e.isChild()).map(c -> (ChildTextElement) c).collect(toList()); + ListIterator iterator = childTextElements.listIterator(); + while (iterator.hasNext()) { + ChildTextElement textElement = iterator.next(); + if (textElement.isComment() && isSameComment(((Comment) textElement.getChild()), oldValue)) { + result.add(textElement); + continue; + } + Node node = textElement.getChild(); + if (node.getComment().isPresent() && isSameComment(node.getComment().get(), oldValue)) { + result.add(textElement); + continue; + } + } + return result; } private boolean isSameComment(Comment childValue, Comment oldValue) { - return childValue.getContent().equals(oldValue.getContent()); + return childValue.getContent().equals(oldValue.getContent()); } private List findTokenTextElementForComment(Comment oldValue, NodeText nodeText) { @@ -345,14 +349,14 @@ private boolean isEqualRange(Optional range1, Optional range2) { return false; } - /** - * This method inserts new space tokens at the given {@code index}. If a new - * comment is added to the token list at the position following {@code index}, - * the new comment and the node will have the same indent. - * - * @param nodeText The text of the node - * @param index The position at which the analysis should start - */ + /** + * This method inserts new space tokens at the given {@code index}. If a new + * comment is added to the token list at the position following {@code index}, + * the new comment and the node will have the same indent. + * + * @param nodeText The text of the node + * @param index The position at which the analysis should start + */ private void fixIndentOfAddedNode(NodeText nodeText, int index) { if (index <= 0) { return; @@ -366,7 +370,7 @@ private void fixIndentOfAddedNode(NodeText nodeText, int index) { } if (!spaceCandidate.isSpaceOrTab()) { if (spaceCandidate.isNewline() && i != index) { - int numberOfIndentationCharacters = index - i; + int numberOfIndentationCharacters = index - i; for (int j = 0; j < numberOfIndentationCharacters; j++) { if (currentSpaceCandidate != null) { // use the current (or last) indentation character @@ -499,11 +503,10 @@ private static Iterator tokensPreceeding(final Node node) { * Print a Node into a String, preserving the lexical information. */ public static String print(Node node) { - LexicalPreservingVisitor visitor = new LexicalPreservingVisitor(); - final NodeText nodeText = getOrCreateNodeText(node); - nodeText.getElements().forEach(element -> element.accept(visitor)); + LexicalPreservingVisitor visitor = new LexicalPreservingVisitor(); + final NodeText nodeText = getOrCreateNodeText(node); + nodeText.getElements().forEach(element -> element.accept(visitor)); return visitor.toString(); - } // @@ -543,17 +546,17 @@ private static void prettyPrintingTextNode(Node node, NodeText nodeText) { return; } if (node instanceof JavadocComment) { - Comment comment = (JavadocComment) node; + Comment comment = (JavadocComment) node; nodeText.addToken(JAVADOC_COMMENT, comment.getHeader() + ((JavadocComment) node).getContent() + comment.getFooter()); return; } if (node instanceof BlockComment) { - Comment comment = (BlockComment) node; + Comment comment = (BlockComment) node; nodeText.addToken(MULTI_LINE_COMMENT, comment.getHeader() + ((BlockComment) node).getContent() + comment.getFooter()); return; } if (node instanceof LineComment) { - Comment comment = (LineComment) node; + Comment comment = (LineComment) node; nodeText.addToken(SINGLE_LINE_COMMENT, comment.getHeader() + comment.getContent()); return; } @@ -574,12 +577,12 @@ private static NodeText interpret(Node node, CsmElement csm, NodeText nodeText) boolean pendingIndentation = false; // Add a comment and line separator if necessary node.getComment().ifPresent(comment -> { - // new comment has no range so in this case we want to force the comment before the node - if (!comment.hasRange()) { - LineSeparator lineSeparator = node.getLineEndingStyleOrDefault(LineSeparator.SYSTEM); - calculatedSyntaxModel.elements.add(0,new CsmToken(eolTokenKind(lineSeparator), lineSeparator.asRawString())); - calculatedSyntaxModel.elements.add(0,new CsmChild(comment)); - } + // new comment has no range so in this case we want to force the comment before the node + if (!comment.hasRange()) { + LineSeparator lineSeparator = node.getLineEndingStyleOrDefault(LineSeparator.SYSTEM); + calculatedSyntaxModel.elements.add(0, new CsmToken(eolTokenKind(lineSeparator), lineSeparator.asRawString())); + calculatedSyntaxModel.elements.add(0, new CsmChild(comment)); + } }); for (CsmElement element : calculatedSyntaxModel.elements) { if (element instanceof CsmIndent) { diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LookaheadIterator.java b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LookaheadIterator.java index bf0b02fc13..0cece8c009 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LookaheadIterator.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LookaheadIterator.java @@ -17,14 +17,13 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ - package com.github.javaparser.printer.lexicalpreservation; import java.util.NoSuchElementException; public interface LookaheadIterator { - /** + /** * Returns the next element in iteration without advancing the underlying iterator. * If the iterator is already exhausted, null will be returned. *

@@ -46,5 +45,4 @@ public interface LookaheadIterator { * @throws NoSuchElementException if the iterator is already exhausted according to {@link #hasNext()} */ public E element(); - } diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/PeekingIterator.java b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/PeekingIterator.java index 52d95ab016..2678e34ee7 100755 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/PeekingIterator.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/PeekingIterator.java @@ -36,16 +36,24 @@ */ public class PeekingIterator implements ListIterator, LookaheadIterator { - /** The iterator being decorated. */ + /** + * The iterator being decorated. + */ private final ListIterator iterator; - /** Indicates that the decorated iterator is exhausted. */ + /** + * Indicates that the decorated iterator is exhausted. + */ private boolean exhausted; - /** Indicates if the lookahead slot is filled. */ + /** + * Indicates if the lookahead slot is filled. + */ private boolean slotFilled; - /** The current slot for lookahead. */ + /** + * The current slot for lookahead. + */ private E slot; /** @@ -67,7 +75,6 @@ public PeekingIterator peekingIterator(final ListIterator iterator) { return new PeekingIterator<>(iterator); } - /** * Constructor. * @@ -121,7 +128,7 @@ public boolean hasNext() { * @return the next element from the iterator */ @Override - public E peek() { + public E peek() { fill(); return exhausted ? null : slot; } @@ -134,7 +141,7 @@ public E peek() { * @throws NoSuchElementException if the iterator is already exhausted according to {@link #hasNext()} */ @Override - public E element() { + public E element() { fill(); if (exhausted) { throw new NoSuchElementException(); @@ -168,56 +175,50 @@ public void remove() { iterator.remove(); } + @Override + public boolean hasPrevious() { + return iterator.hasPrevious(); + } - @Override - public boolean hasPrevious() { - return iterator.hasPrevious(); - } - - - @Override - public E previous() { - return iterator.previous(); - } - + @Override + public E previous() { + return iterator.previous(); + } - @Override - public int nextIndex() { - return iterator.nextIndex(); - } + @Override + public int nextIndex() { + return iterator.nextIndex(); + } - /* + /* * Returns the index of the element that would be returned by the last call to next. * Returns list size - 1 if the listiterator is at the end of the list. * Returns -1 if the listiterator is at the beginning of the list. */ - public int currentIndex() { - if (!hasPrevious()) return previousIndex(); - return nextIndex() - 1; - } - - - @Override - public int previousIndex() { - return iterator.previousIndex(); - } + public int currentIndex() { + if (!hasPrevious()) + return previousIndex(); + return nextIndex() - 1; + } + @Override + public int previousIndex() { + return iterator.previousIndex(); + } - @Override - public void set(E e) { - if (slotFilled) { + @Override + public void set(E e) { + if (slotFilled) { throw new IllegalStateException("peek() or element() called before set()"); } - iterator.set(e); - } - + iterator.set(e); + } - @Override - public void add(E e) { - if (slotFilled) { + @Override + public void add(E e) { + if (slotFilled) { throw new IllegalStateException("peek() or element() called before add()"); } - iterator.add(e); - } - + iterator.add(e); + } } diff --git a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/ReshuffledDiffElementExtractor.java b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/ReshuffledDiffElementExtractor.java index 2375397922..b362b9f966 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/ReshuffledDiffElementExtractor.java +++ b/javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/ReshuffledDiffElementExtractor.java @@ -17,11 +17,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ - package com.github.javaparser.printer.lexicalpreservation; import java.util.*; - import com.github.javaparser.printer.concretesyntaxmodel.CsmElement; import com.github.javaparser.printer.concretesyntaxmodel.CsmMix; import com.github.javaparser.printer.concretesyntaxmodel.CsmToken; @@ -29,7 +27,7 @@ public class ReshuffledDiffElementExtractor { - private final NodeText nodeText; + private final NodeText nodeText; private enum MatchClassification { @@ -47,15 +45,15 @@ int getPriority() { } static ReshuffledDiffElementExtractor of(NodeText nodeText) { - return new ReshuffledDiffElementExtractor(nodeText); + return new ReshuffledDiffElementExtractor(nodeText); } - private ReshuffledDiffElementExtractor(NodeText nodeText) { - this.nodeText = nodeText; - } + private ReshuffledDiffElementExtractor(NodeText nodeText) { + this.nodeText = nodeText; + } - public void extract(List diffElements) { - ArrayIterator iterator = new ArrayIterator<>(diffElements); + public void extract(List diffElements) { + ArrayIterator iterator = new ArrayIterator<>(diffElements); while (iterator.hasNext()) { DifferenceElement diffElement = iterator.next(); if (diffElement instanceof Reshuffled) { @@ -70,9 +68,9 @@ public void extract(List diffElements) { PeekingIterator nodeTextIndexOfPreviousElementsIterator = new PeekingIterator<>(nodeTextIndexOfPreviousElements); Map nodeTextIndexToPreviousCSMIndex = new HashMap<>(); while (nodeTextIndexOfPreviousElementsIterator.hasNext()) { - int value = nodeTextIndexOfPreviousElementsIterator.next(); + int value = nodeTextIndexOfPreviousElementsIterator.next(); if (value != -1) { - nodeTextIndexToPreviousCSMIndex.put(value, nodeTextIndexOfPreviousElementsIterator.currentIndex()); + nodeTextIndexToPreviousCSMIndex.put(value, nodeTextIndexOfPreviousElementsIterator.currentIndex()); } } int lastNodeTextIndex = nodeTextIndexOfPreviousElements.stream().max(Integer::compareTo).orElse(-1); @@ -122,9 +120,9 @@ public void extract(List diffElements) { CsmElement originalCSMElement = elementsFromPreviousOrder.getElements().get(indexOfOriginalCSMElement); boolean toBeKept = correspondanceBetweenNextOrderAndPreviousOrder.containsValue(indexOfOriginalCSMElement); if (toBeKept) { - iterator.add(new Kept(originalCSMElement)); + iterator.add(new Kept(originalCSMElement)); } else { - iterator.add(new Removed(originalCSMElement)); + iterator.add(new Removed(originalCSMElement)); } } // else we have a simple node text element, without associated csm element, just keep ignore it @@ -133,13 +131,13 @@ public void extract(List diffElements) { // Finally we look for the remaining new elements that were not yet added and // add all of them for (CsmElement elementToAdd : elementsToBeAddedAtTheEnd) { - iterator.add(new Added(elementToAdd)); + iterator.add(new Added(elementToAdd)); } } } } - /* + /* * Considering that the lists of elements are ordered, We can find the common * elements by starting with the list before the modifications and, for each * element, by going through the list of elements containing the modifications. @@ -153,44 +151,39 @@ public void extract(List diffElements) { * case the search for the next element of the list L1 must start from the * position of the last element kept {@code syncNextIndex}. */ - private Map getCorrespondanceBetweenNextOrderAndPreviousOrder(CsmMix elementsFromPreviousOrder, - CsmMix elementsFromNextOrder) { - Map correspondanceBetweenNextOrderAndPreviousOrder = new HashMap<>(); - ArrayIterator previousOrderElementsIterator = new ArrayIterator<>( - elementsFromPreviousOrder.getElements()); - int syncNextIndex = 0; - while (previousOrderElementsIterator.hasNext()) { - CsmElement pe = previousOrderElementsIterator.next(); - ArrayIterator nextOrderElementsIterator = new ArrayIterator<>( - elementsFromNextOrder.getElements(), syncNextIndex); - while (nextOrderElementsIterator.hasNext()) { - CsmElement ne = nextOrderElementsIterator.next(); - if (!correspondanceBetweenNextOrderAndPreviousOrder.values().contains(previousOrderElementsIterator.index()) - && DifferenceElementCalculator.matching(ne, pe)) { - correspondanceBetweenNextOrderAndPreviousOrder.put(nextOrderElementsIterator.index(), - previousOrderElementsIterator.index()); - // set the position to start on the next {@code nextOrderElementsIterator} iteration - syncNextIndex = nextOrderElementsIterator.index(); - break; - } - } - } - return correspondanceBetweenNextOrderAndPreviousOrder; - } + private Map getCorrespondanceBetweenNextOrderAndPreviousOrder(CsmMix elementsFromPreviousOrder, CsmMix elementsFromNextOrder) { + Map correspondanceBetweenNextOrderAndPreviousOrder = new HashMap<>(); + ArrayIterator previousOrderElementsIterator = new ArrayIterator<>(elementsFromPreviousOrder.getElements()); + int syncNextIndex = 0; + while (previousOrderElementsIterator.hasNext()) { + CsmElement pe = previousOrderElementsIterator.next(); + ArrayIterator nextOrderElementsIterator = new ArrayIterator<>(elementsFromNextOrder.getElements(), syncNextIndex); + while (nextOrderElementsIterator.hasNext()) { + CsmElement ne = nextOrderElementsIterator.next(); + if (!correspondanceBetweenNextOrderAndPreviousOrder.values().contains(previousOrderElementsIterator.index()) && DifferenceElementCalculator.matching(ne, pe)) { + correspondanceBetweenNextOrderAndPreviousOrder.put(nextOrderElementsIterator.index(), previousOrderElementsIterator.index()); + // set the position to start on the next {@code nextOrderElementsIterator} iteration + syncNextIndex = nextOrderElementsIterator.index(); + break; + } + } + } + return correspondanceBetweenNextOrderAndPreviousOrder; + } - private List findIndexOfCorrespondingNodeTextElement(List elements, NodeText nodeText) { + private List findIndexOfCorrespondingNodeTextElement(List elements, NodeText nodeText) { List correspondingIndices = new ArrayList<>(); PeekingIterator csmElementListIterator = new PeekingIterator<>(elements); - while ( csmElementListIterator.hasNext() ) { - boolean isFirstIterationOnCsmElements = !csmElementListIterator.hasPrevious(); + while (csmElementListIterator.hasNext()) { + boolean isFirstIterationOnCsmElements = !csmElementListIterator.hasPrevious(); int previousCsmElementIndex = csmElementListIterator.previousIndex(); CsmElement csmElement = csmElementListIterator.next(); Map potentialMatches = new EnumMap<>(MatchClassification.class); PeekingIterator nodeTextListIterator = new PeekingIterator<>(nodeText.getElements()); while (nodeTextListIterator.hasNext()) { - boolean isFirstIterationOnNodeTextElements = !nodeTextListIterator.hasPrevious(); - TextElement textElement = nodeTextListIterator.next(); - int currentTextElementIndex = nodeTextListIterator.currentIndex(); + boolean isFirstIterationOnNodeTextElements = !nodeTextListIterator.hasPrevious(); + TextElement textElement = nodeTextListIterator.next(); + int currentTextElementIndex = nodeTextListIterator.currentIndex(); if (!correspondingIndices.contains(currentTextElementIndex)) { boolean isCorresponding = csmElement.isCorrespondingElement(textElement); if (isCorresponding) { diff --git a/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/Cache.java b/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/Cache.java index d0adde8061..076c97c0e4 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/Cache.java +++ b/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/Cache.java @@ -17,7 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ - package com.github.javaparser.resolution.cache; import java.util.Optional; @@ -89,13 +88,11 @@ public interface Cache { * @return {@code True} if is empty. */ boolean isEmpty(); - + /** * Returns a current snapshot of this cache's cumulative statistics, or a set of default values if * the cache is not recording statistics. All statistics begin at zero and never decrease over the * lifetime of the cache. - * */ CacheStats stats(); - } diff --git a/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/CacheStats.java b/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/CacheStats.java index 1923036fe1..b3a7609624 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/CacheStats.java +++ b/javaparser-core/src/main/java/com/github/javaparser/resolution/cache/CacheStats.java @@ -17,135 +17,134 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ +package com.github.javaparser.resolution.cache; -package com.github.javaparser.resolution.cache; - -public interface CacheStats { - - /** - * Returns the number of times lookup methods have returned either a cached or - * uncached value. This is defined as {@code hitCount + missCount}. - * - *

Note: the values of the metrics are undefined in case of overflow (though it is - * guaranteed not to throw an exception). If you require specific handling, we recommend - * implementing your own stats collector. - */ - long requestCount(); - - /** Returns the number of times lookup methods have returned a cached value. */ - long hitCount(); - - /** - * Returns the ratio of cache requests which were hits. This is defined as {@code hitCount / - * requestCount}, or {@code 1.0} when {@code requestCount == 0}. Note that {@code hitRate + - * missRate =~ 1.0}. - */ - double hitRate(); - - /** - * Returns the number of times lookup methods have returned an uncached (newly - * loaded) value, or null. Multiple concurrent calls to lookup methods on an absent - * value can result in multiple misses, all returning the results of a single cache load - * operation. - */ - long missCount(); - - /** - * Returns the ratio of cache requests which were misses. This is defined as {@code missCount / - * requestCount}, or {@code 0.0} when {@code requestCount == 0}. Note that {@code hitRate + - * missRate =~ 1.0}. Cache misses include all requests which weren't cache hits, including - * requests which resulted in either successful or failed loading attempts, and requests which - * waited for other threads to finish loading. It is thus the case that {@code missCount >= - * loadSuccessCount + loadExceptionCount}. Multiple concurrent misses for the same key will result - * in a single load operation. - */ - double missRate(); - - /** - * Returns the total number of times that lookup methods attempted to load new - * values. This includes both successful load operations and those that threw exceptions. This is - * defined as {@code loadSuccessCount + loadExceptionCount}. - * - *

Note: the values of the metrics are undefined in case of overflow (though it is - * guaranteed not to throw an exception). If you require specific handling, we recommend - * implementing your own stats collector. - */ - long loadCount(); - - /** - * Returns the number of times lookup methods have successfully loaded a new value. - * This is usually incremented in conjunction with {@link #missCount}, though {@code missCount} is - * also incremented when an exception is encountered during cache loading (see {@link - * #loadExceptionCount}). Multiple concurrent misses for the same key will result in a single load - * operation. This may be incremented not in conjunction with {@code missCount} if the load occurs - * as a result of a refresh or if the cache loader returned more items than was requested. {@code - * missCount} may also be incremented not in conjunction with this (nor {@link - * #loadExceptionCount}) on calls to {@code getIfPresent}. - */ - long loadSuccessCount(); - - /** - * Returns the number of times lookup methods threw an exception while loading a new - * value. This is usually incremented in conjunction with {@code missCount}, though {@code - * missCount} is also incremented when cache loading completes successfully (see {@link - * #loadSuccessCount}). Multiple concurrent misses for the same key will result in a single load - * operation. This may be incremented not in conjunction with {@code missCount} if the load occurs - * as a result of a refresh or if the cache loader returned more items than was requested. {@code - * missCount} may also be incremented not in conjunction with this (nor {@link #loadSuccessCount}) - * on calls to {@code getIfPresent}. - */ - long loadExceptionCount(); - - /** - * Returns the ratio of cache loading attempts which threw exceptions. This is defined as {@code - * loadExceptionCount / (loadSuccessCount + loadExceptionCount)}, or {@code 0.0} when {@code - * loadSuccessCount + loadExceptionCount == 0}. - * - *

Note: the values of the metrics are undefined in case of overflow (though it is - * guaranteed not to throw an exception). If you require specific handling, we recommend - * implementing your own stats collector. - */ - double loadExceptionRate(); - - /** - * Returns the total number of nanoseconds the cache has spent loading new values. This can be - * used to calculate the miss penalty. This value is increased every time {@code loadSuccessCount} - * or {@code loadExceptionCount} is incremented. - */ - long totalLoadTime(); - - /** - * Returns the average time spent loading new values. This is defined as {@code totalLoadTime / - * (loadSuccessCount + loadExceptionCount)}. - * - *

Note: the values of the metrics are undefined in case of overflow (though it is - * guaranteed not to throw an exception). If you require specific handling, we recommend - * implementing your own stats collector. - */ - double averageLoadPenalty(); - - /** - * Returns the number of times an entry has been evicted. This count does not include manual - * invalidations. - */ - long evictionCount(); - - /** - * Returns a new {@code ICacheStats} representing the difference between this {@code ICacheStats} - * and {@code other}. Negative values, which aren't supported by {@code ICacheStats} will be - * rounded up to zero. - */ - CacheStats minus(CacheStats other); - - /** - * Returns a new {@code ICacheStats} representing the sum of this {@code ICacheStats} and {@code - * other}. - * - *

Note: the values of the metrics are undefined in case of overflow (though it is - * guaranteed not to throw an exception). If you require specific handling, we recommend - * implementing your own stats collector. - * - */ - CacheStats plus(CacheStats other); - -} \ No newline at end of file +public interface CacheStats { + + /** + * Returns the number of times lookup methods have returned either a cached or + * uncached value. This is defined as {@code hitCount + missCount}. + * + *

Note: the values of the metrics are undefined in case of overflow (though it is + * guaranteed not to throw an exception). If you require specific handling, we recommend + * implementing your own stats collector. + */ + long requestCount(); + + /** + * Returns the number of times lookup methods have returned a cached value. + */ + long hitCount(); + + /** + * Returns the ratio of cache requests which were hits. This is defined as {@code hitCount / + * requestCount}, or {@code 1.0} when {@code requestCount == 0}. Note that {@code hitRate + + * missRate =~ 1.0}. + */ + double hitRate(); + + /** + * Returns the number of times lookup methods have returned an uncached (newly + * loaded) value, or null. Multiple concurrent calls to lookup methods on an absent + * value can result in multiple misses, all returning the results of a single cache load + * operation. + */ + long missCount(); + + /** + * Returns the ratio of cache requests which were misses. This is defined as {@code missCount / + * requestCount}, or {@code 0.0} when {@code requestCount == 0}. Note that {@code hitRate + + * missRate =~ 1.0}. Cache misses include all requests which weren't cache hits, including + * requests which resulted in either successful or failed loading attempts, and requests which + * waited for other threads to finish loading. It is thus the case that {@code missCount >= + * loadSuccessCount + loadExceptionCount}. Multiple concurrent misses for the same key will result + * in a single load operation. + */ + double missRate(); + + /** + * Returns the total number of times that lookup methods attempted to load new + * values. This includes both successful load operations and those that threw exceptions. This is + * defined as {@code loadSuccessCount + loadExceptionCount}. + * + *

Note: the values of the metrics are undefined in case of overflow (though it is + * guaranteed not to throw an exception). If you require specific handling, we recommend + * implementing your own stats collector. + */ + long loadCount(); + + /** + * Returns the number of times lookup methods have successfully loaded a new value. + * This is usually incremented in conjunction with {@link #missCount}, though {@code missCount} is + * also incremented when an exception is encountered during cache loading (see {@link + * #loadExceptionCount}). Multiple concurrent misses for the same key will result in a single load + * operation. This may be incremented not in conjunction with {@code missCount} if the load occurs + * as a result of a refresh or if the cache loader returned more items than was requested. {@code + * missCount} may also be incremented not in conjunction with this (nor {@link + * #loadExceptionCount}) on calls to {@code getIfPresent}. + */ + long loadSuccessCount(); + + /** + * Returns the number of times lookup methods threw an exception while loading a new + * value. This is usually incremented in conjunction with {@code missCount}, though {@code + * missCount} is also incremented when cache loading completes successfully (see {@link + * #loadSuccessCount}). Multiple concurrent misses for the same key will result in a single load + * operation. This may be incremented not in conjunction with {@code missCount} if the load occurs + * as a result of a refresh or if the cache loader returned more items than was requested. {@code + * missCount} may also be incremented not in conjunction with this (nor {@link #loadSuccessCount}) + * on calls to {@code getIfPresent}. + */ + long loadExceptionCount(); + + /** + * Returns the ratio of cache loading attempts which threw exceptions. This is defined as {@code + * loadExceptionCount / (loadSuccessCount + loadExceptionCount)}, or {@code 0.0} when {@code + * loadSuccessCount + loadExceptionCount == 0}. + * + *

Note: the values of the metrics are undefined in case of overflow (though it is + * guaranteed not to throw an exception). If you require specific handling, we recommend + * implementing your own stats collector. + */ + double loadExceptionRate(); + + /** + * Returns the total number of nanoseconds the cache has spent loading new values. This can be + * used to calculate the miss penalty. This value is increased every time {@code loadSuccessCount} + * or {@code loadExceptionCount} is incremented. + */ + long totalLoadTime(); + + /** + * Returns the average time spent loading new values. This is defined as {@code totalLoadTime / + * (loadSuccessCount + loadExceptionCount)}. + * + *

Note: the values of the metrics are undefined in case of overflow (though it is + * guaranteed not to throw an exception). If you require specific handling, we recommend + * implementing your own stats collector. + */ + double averageLoadPenalty(); + + /** + * Returns the number of times an entry has been evicted. This count does not include manual + * invalidations. + */ + long evictionCount(); + + /** + * Returns a new {@code ICacheStats} representing the difference between this {@code ICacheStats} + * and {@code other}. Negative values, which aren't supported by {@code ICacheStats} will be + * rounded up to zero. + */ + CacheStats minus(CacheStats other); + + /** + * Returns a new {@code ICacheStats} representing the sum of this {@code ICacheStats} and {@code + * other}. + * + *

Note: the values of the metrics are undefined in case of overflow (though it is + * guaranteed not to throw an exception). If you require specific handling, we recommend + * implementing your own stats collector. + */ + CacheStats plus(CacheStats other); +} diff --git a/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/FunctionalInterfaceLogic.java b/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/FunctionalInterfaceLogic.java index 462d56fe51..23eb88a9f9 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/FunctionalInterfaceLogic.java +++ b/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/FunctionalInterfaceLogic.java @@ -62,10 +62,11 @@ public static Optional getFunctionalMethod(ResolvedReferenceTypeDec //We need to find all abstract methods // Remove methods inherited by Object: Set // Remove methods inherited by Object: - methods = // Consider the case of Comparator which define equals. It would be considered a functional method. - typeDeclaration.getAllMethods().stream().filter(m -> m.getDeclaration().isAbstract()).filter(// TODO a functional interface can have multiple subsignature method with a return-type-substitutable - m -> !isPublicMemberOfObject(m)).// TODO a functional interface can have multiple subsignature method with a return-type-substitutable - collect(Collectors.toSet()); + // Consider the case of Comparator which define equals. It would be considered a functional method. + methods = // TODO a functional interface can have multiple subsignature method with a return-type-substitutable + typeDeclaration.getAllMethods().stream().filter(m -> m.getDeclaration().isAbstract()).// TODO a functional interface can have multiple subsignature method with a return-type-substitutable + filter(// TODO a functional interface can have multiple subsignature method with a return-type-substitutable + m -> !isPublicMemberOfObject(m)).collect(Collectors.toSet()); // see https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.8 if (methods.size() == 0) { return Optional.empty(); diff --git a/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/MethodResolutionLogic.java b/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/MethodResolutionLogic.java index 22c5124ff6..8720330235 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/MethodResolutionLogic.java +++ b/javaparser-core/src/main/java/com/github/javaparser/resolution/logic/MethodResolutionLogic.java @@ -510,11 +510,11 @@ public static SymbolReference findMostApplicable(List public static SymbolReference findMostApplicable(List methods, String name, List argumentsTypes, TypeSolver typeSolver, boolean wildcardTolerance) { // Only consider methods with a matching name List // Only consider methods with a matching name + // Filters out duplicate ResolvedMethodDeclaration by their signature. applicableMethods = // Filters out duplicate ResolvedMethodDeclaration by their signature. - methods.stream().// Filters out duplicate ResolvedMethodDeclaration by their signature. + methods.stream().// Checks if ResolvedMethodDeclaration is applicable to argumentsTypes. filter(// Checks if ResolvedMethodDeclaration is applicable to argumentsTypes. - m -> m.getName().equals(name)).// Checks if ResolvedMethodDeclaration is applicable to argumentsTypes. - filter(distinctByKey(ResolvedMethodDeclaration::getQualifiedSignature)).filter((m) -> isApplicable(m, name, argumentsTypes, typeSolver, wildcardTolerance)).collect(Collectors.toList()); + m -> m.getName().equals(name)).filter(distinctByKey(ResolvedMethodDeclaration::getQualifiedSignature)).filter((m) -> isApplicable(m, name, argumentsTypes, typeSolver, wildcardTolerance)).collect(Collectors.toList()); // If no applicable methods found, return as unsolved. if (applicableMethods.isEmpty()) { return SymbolReference.unsolved(); diff --git a/javaparser-core/src/main/java/com/github/javaparser/resolution/types/parametrization/ResolvedTypeParameterValueProvider.java b/javaparser-core/src/main/java/com/github/javaparser/resolution/types/parametrization/ResolvedTypeParameterValueProvider.java index 1c9b93c728..bd559bdee9 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/resolution/types/parametrization/ResolvedTypeParameterValueProvider.java +++ b/javaparser-core/src/main/java/com/github/javaparser/resolution/types/parametrization/ResolvedTypeParameterValueProvider.java @@ -46,13 +46,11 @@ default ResolvedType useThisTypeParametersOnTheGivenType(ResolvedType type) { if (typeParameter.declaredOnType()) { Optional typeParam = typeParamValue(typeParameter); if (typeParam.isPresent()) { - ResolvedType resolvedTypeParam = typeParam.get(); - // Try to avoid an infinite loop when the type is a wildcard type bounded by a type variable like "? super T" - if (resolvedTypeParam.isWildcard() && - ( !resolvedTypeParam.asWildcard().equals(ResolvedWildcard.UNBOUNDED) - && type.equals(resolvedTypeParam.asWildcard().getBoundedType()))) { - return type; - } + ResolvedType resolvedTypeParam = typeParam.get(); + // Try to avoid an infinite loop when the type is a wildcard type bounded by a type variable like "? super T" + if (resolvedTypeParam.isWildcard() && (!resolvedTypeParam.asWildcard().equals(ResolvedWildcard.UNBOUNDED) && type.equals(resolvedTypeParam.asWildcard().getBoundedType()))) { + return type; + } type = resolvedTypeParam; } } diff --git a/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorList.java b/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorList.java index b254528a53..6560d882bf 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorList.java +++ b/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorList.java @@ -24,7 +24,6 @@ import com.github.javaparser.ast.visitor.GenericVisitor; import com.github.javaparser.ast.visitor.Visitable; import com.github.javaparser.ast.visitor.VoidVisitor; - import java.util.*; import java.util.stream.Collectors; diff --git a/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorSet.java b/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorSet.java index c9bc71647d..151b594b6b 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorSet.java +++ b/javaparser-core/src/main/java/com/github/javaparser/utils/VisitorSet.java @@ -24,7 +24,6 @@ import com.github.javaparser.ast.visitor.GenericVisitor; import com.github.javaparser.ast.visitor.Visitable; import com.github.javaparser.ast.visitor.VoidVisitor; - import java.util.Collection; import java.util.HashSet; import java.util.Iterator; diff --git a/javaparser-symbol-solver-core/pom.xml b/javaparser-symbol-solver-core/pom.xml index cb54183721..24e69b843f 100644 --- a/javaparser-symbol-solver-core/pom.xml +++ b/javaparser-symbol-solver-core/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/javaparser-symbol-solver-testing/pom.xml b/javaparser-symbol-solver-testing/pom.xml index 52aeb0c547..54e199ddff 100644 --- a/javaparser-symbol-solver-testing/pom.xml +++ b/javaparser-symbol-solver-testing/pom.xml @@ -4,7 +4,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/jmlparser-jml-pretty/pom.xml b/jmlparser-jml-pretty/pom.xml index d7dce1c6c8..35a4cb6e60 100644 --- a/jmlparser-jml-pretty/pom.xml +++ b/jmlparser-jml-pretty/pom.xml @@ -7,7 +7,7 @@ io.github.jmltoolkit jmlparser-parent - 3.25.8 + 3.25.8-SNAPSHOT jmlparser-jml-pretty diff --git a/jmlparser-jml-tests/pom.xml b/jmlparser-jml-tests/pom.xml index fcb9cd4fdd..a1da4d3771 100644 --- a/jmlparser-jml-tests/pom.xml +++ b/jmlparser-jml-tests/pom.xml @@ -2,7 +2,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT 4.0.0 diff --git a/jmlparser-jml-tools/pom.xml b/jmlparser-jml-tools/pom.xml index 66f61f1adf..269f795c62 100644 --- a/jmlparser-jml-tools/pom.xml +++ b/jmlparser-jml-tools/pom.xml @@ -6,7 +6,7 @@ jmlparser-parent io.github.jmltoolkit - 3.25.8 + 3.25.8-SNAPSHOT jmlparser-jml-tools @@ -48,7 +48,7 @@ org.projectlombok lombok - 1.18.24 + 1.18.30 compile diff --git a/pom.xml b/pom.xml index 17eefe44a4..5768187466 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ io.github.jmltoolkit jmlparser-parent pom - 3.25.8 + 3.25.8-SNAPSHOT jmlparser-parent https://github.com/wadoon/jmlparser