Skip to content

javaparser.ast.stmt.SwitchEntry.clone doesn't copy the guard expression #4607

@DaniilSuchkov

Description

@DaniilSuchkov

CloneVisitor here https://github.com/javaparser/javaparser/blob/master/javaparser-core/src/main/java/com/github/javaparser/ast/visitor/CloneVisitor.java#L892 clones the guard expression, but it doesn't insert it into the newly created SwitchEntry:

    public Visitable visit(final SwitchEntry n, final Object arg) {
        Expression guard = cloneNode(n.getGuard(), arg);
        NodeList<Expression> labels = cloneList(n.getLabels(), arg);
        NodeList<Statement> statements = cloneList(n.getStatements(), arg);
        Comment comment = cloneNode(n.getComment(), arg);
        SwitchEntry r = new SwitchEntry(n.getTokenRange().orElse(null), labels, n.getType(), statements, n.isDefault());
        r.setComment(comment);
        n.getOrphanComments().stream().map(Comment::clone).forEach(r::addOrphanComment);
        copyData(n, r);
        return r;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions