file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
INode.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/INode.java
package jtree.nodes; import java.util.function.Consumer; public interface INode { String toCode(); INode clone(); /** * @param visitor the TreeVisitor * @param parent this Node's parent * @param replacer a function to replace this node with another in its parent */ <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer); }
373
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
BinaryExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/BinaryExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; @EqualsAndHashCode @Getter @Setter public class BinaryExpr extends Node implements Expression { protected @NonNull Expression left; protected @NonNull BinaryExpr.Op operation; private @NonNull Expression right; public BinaryExpr(Expression left, BinaryExpr.Op operation, Expression right) { setOperation(operation); setLeft(left); setRight(right); } @Override public Precedence precedence() { return operation.precedence; } @Override public BinaryExpr clone() { return new BinaryExpr(getLeft().clone(), getOperation(), getRight().clone()); } @Override public String toCode() { return wrap(getLeft()).toCode() + " " + getOperation() + " " + wrap(getRight()).toCode(); } @RequiredArgsConstructor public static enum Op { // @formatter:off OR ("||", Precedence.LOGIC_OR), AND ("&&", Precedence.LOGIC_AND), BIT_OR ("|", Precedence.BIT_OR), XOR ("^", Precedence.BIT_XOR), BIT_AND ("&", Precedence.BIT_AND), EQUAL ("==", Precedence.EQUALITY), NEQUAL ("!=", Precedence.EQUALITY), LTHAN ("<", Precedence.RELATIONAL), GTHAN (">", Precedence.RELATIONAL), LEQUAL ("<=", Precedence.RELATIONAL), GEQUAL (">=", Precedence.RELATIONAL), LSHIFT ("<<", Precedence.BIT_SHIFT), RSHIFT (">>", Precedence.BIT_SHIFT), URSHIFT (">>>", Precedence.BIT_SHIFT), PLUS ("+", Precedence.ADDITIVE), MINUS ("-", Precedence.ADDITIVE), TIMES ("*", Precedence.MULTIPLICATIVE), DIVIDE ("/", Precedence.MULTIPLICATIVE), MODULUS ("%", Precedence.MULTIPLICATIVE); // @formatter:on @Getter @Accessors(fluent = true) private final String toString; public final Precedence precedence; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitBinaryExpr(this, parent, cast(replacer))) { getLeft().accept(visitor, this, this::setLeft); getRight().accept(visitor, this, this::setRight); } } }
2,226
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AssignExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AssignExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; @EqualsAndHashCode @Getter @Setter public class AssignExpr extends Node implements Expression { protected @NonNull Expression assigned; protected @NonNull AssignExpr.Op operation; private @NonNull Expression value; public AssignExpr(Expression assigned, Expression value) { this(assigned, AssignExpr.Op.NONE, value); } public AssignExpr(Expression assigned, AssignExpr.Op operation, Expression value) { setAssigned(assigned); setOperation(operation); setValue(value); } @Override public Precedence precedence() { return Precedence.ASSIGNMENT; } @Override public AssignExpr clone() { return new AssignExpr(getAssigned().clone(), getOperation(), getValue().clone()); } @Override public String toCode() { return wrap(getAssigned()).toCode() + " " + getOperation() + " " + wrap(getValue()).toCode(); } @RequiredArgsConstructor public static enum Op { NONE("="), PLUS("+="), MINUS("-="), TIMES("*="), DIVIDE("/="), MODULUS("%="), XOR("^="), AND("&="), OR("|="), LSHIFT("<<="), RSHIFT(">>="), URSHIFT(">>>="); @Getter @Accessors(fluent = true) protected final String toString; public static Op fromString(String op) { return switch(op) { case "=" -> NONE; case "+=" -> PLUS; case "-=" -> MINUS; case "*=" -> TIMES; case "/=" -> DIVIDE; case "%=" -> MODULUS; case "^=" -> XOR; case "&=" -> AND; case "|=" -> OR; case "<<=" -> LSHIFT; case ">>=" -> RSHIFT; case ">>>=" -> URSHIFT; default -> throw new IllegalArgumentException("No operator corresponding to " + op + " found"); }; } } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitAssignExpr(this, parent, cast(replacer))) { getAssigned().accept(visitor, this, this::setAssigned); getValue().accept(visitor, this, this::setValue); } } }
2,147
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ClassDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ClassDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ClassDecl extends TypeDecl implements Statement { protected @NonNull Optional<GenericType> superClass; protected @NonNull List<GenericType> interfaces; public ClassDecl(Name name, List<TypeParameter> typeParameters, List<Member> members) { this(name, typeParameters, members, emptyList(), emptyList(), Optional.empty()); } public ClassDecl(Name name, List<? extends Member> members) { this(name, members, emptyList(), emptyList(), Optional.empty()); } public ClassDecl(Name name, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, emptyList(), members, modifiers, annotations, docComment); } public ClassDecl(Name name, List<TypeParameter> typeParameters, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, Optional.empty(), emptyList(), members, modifiers, annotations, docComment); } public ClassDecl(Name name, List<TypeParameter> typeParameters, Optional<GenericType> superClass, List<GenericType> interfaces, List<? extends Member> members) { this(name, typeParameters, superClass, interfaces, members, emptyList(), emptyList(), Optional.empty()); } public ClassDecl(Name name, Optional<GenericType> superClass, List<GenericType> interfaces, List<? extends Member> members) { this(name, superClass, interfaces, members, emptyList(), emptyList(), Optional.empty()); } public ClassDecl(Name name, Optional<GenericType> superClass, List<GenericType> interfaces, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, emptyList(), superClass, interfaces, members, modifiers, annotations, docComment); } public ClassDecl(Name name, List<TypeParameter> typeParameters, Optional<GenericType> superClass, List<? extends Member> members) { this(name, typeParameters, superClass, emptyList(), members, emptyList(), emptyList(), Optional.empty()); } public ClassDecl(Name name, Optional<GenericType> superClass, List<? extends Member> members) { this(name, superClass, emptyList(), members, emptyList(), emptyList(), Optional.empty()); } public ClassDecl(Name name, Optional<GenericType> superClass, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, emptyList(), superClass, emptyList(), members, modifiers, annotations, docComment); } public ClassDecl(Name name, List<TypeParameter> typeParameters, Optional<GenericType> superClass, List<GenericType> interfaces, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(name, typeParameters, members, modifiers, annotations, docComment); setSuperClass(superClass); setInterfaces(interfaces); } @Override public ClassDecl clone() { return new ClassDecl(getName(), clone(getTypeParameters()), clone(getSuperClass()), clone(getInterfaces()), clone(getMembers()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { var interfaces = getInterfaces(); return docString() + annotationString() + modifierString() + "class " + getName() + typeParameterString() + getSuperClass().map(superClass -> " extends " + superClass.toCode()).orElse("") + (interfaces.isEmpty()? "" : " implements " + joinNodes(", ", interfaces)) + " " + bodyString(); } public void setInterfaces(@NonNull List<GenericType> interfaces) { this.interfaces = newList(interfaces); } public final void setInterfaces(GenericType... interfaces) { setInterfaces(List.of(interfaces)); } public void setSuperClass(@NonNull Optional<GenericType> superClass) { this.superClass = superClass; } public final void setSuperClass(GenericType superClass) { setSuperClass(Optional.ofNullable(superClass)); } public final void setSuperClass() { setSuperClass(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitClassDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getTypeParameters()); getSuperClass().ifPresent(superClass -> superClass.<GenericType>accept(visitor, this, this::setSuperClass)); visitList(visitor, getInterfaces()); visitList(visitor, getMembers()); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
4,911
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
UsesDirective.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/UsesDirective.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class UsesDirective extends Directive { public UsesDirective(QualifiedName typeName) { super(typeName); } @Override public UsesDirective clone() { return new UsesDirective(getName()); } @Override public String toCode() { return "uses " + getName() + ";"; } @Override public void setName(@NonNull QualifiedName typeName) { if(typeName.lastName().equals("var")) { throw new IllegalArgumentException("\"var\" cannot be used as a type name"); } super.setName(typeName); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitUsesDirective(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); } } }
939
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
This.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/This.java
package jtree.nodes; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class This extends Node implements Expression { protected @NonNull Optional<QualifiedName> qualifier; public This() { this(Optional.empty()); } public This(QualifiedName qualifier) { this(Optional.ofNullable(qualifier)); } public This(Optional<QualifiedName> qualifier) { setQualifier(qualifier); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public This clone() { return new This(clone(getQualifier())); } @Override public String toCode() { return getQualifier().map(qualifier -> qualifier.toCode() + ".").orElse("") + "this"; } public void setQualifier(@NonNull Optional<QualifiedName> qualifier) { this.qualifier = qualifier; } public final void setQualifier(QualifiedName qualifier) { setQualifier(Optional.ofNullable(qualifier)); } public final void setQualifier() { setQualifier(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitThis(this, parent, cast(replacer))) { getQualifier().ifPresent(qualifier -> qualifier.<QualifiedName>accept(visitor, this, this::setQualifier)); } } }
1,416
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ProvidesDirective.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ProvidesDirective.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ProvidesDirective extends Directive { protected @NonNull List<QualifiedName> serviceProviders; public ProvidesDirective(QualifiedName serviceName, List<QualifiedName> serviceProviders) { super(serviceName); setServiceProviders(serviceProviders); } @Override public ProvidesDirective clone() { return new ProvidesDirective(getName(), clone(getServiceProviders())); } @Override public String toCode() { return "provides " + getName() + " with " + joinNodes(", ", getServiceProviders()) + ";"; } @Override public void setName(@NonNull QualifiedName typeName) { if(typeName.lastName().equals("var")) { throw new IllegalArgumentException("\"var\" cannot be used as a type name"); } super.setName(typeName); } public void setServiceProviders(@NonNull List<QualifiedName> serviceProviders) { if(serviceProviders.isEmpty()) { throw new IllegalArgumentException("No service providers given"); } this.serviceProviders = new ArrayList<>(serviceProviders.size()); for(var serviceProvider : serviceProviders) { if(serviceProvider.lastName().equals("var")) { throw new IllegalArgumentException("\"var\" cannot be used as a type name"); } else { this.serviceProviders.add(serviceProvider); } } } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitProvidesDirective(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getServiceProviders()); } } }
1,833
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
EmptyStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/EmptyStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class EmptyStmt extends Node implements Statement { @Override public EmptyStmt clone() { return this; } @Override public String toCode() { return ";"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { visitor.visitEmptyStmt(this, parent, cast(replacer)); } }
517
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
REPLEntry.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/REPLEntry.java
package jtree.nodes; public interface REPLEntry extends INode { @Override REPLEntry clone(); }
98
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
LambdaParameter.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/LambdaParameter.java
package jtree.nodes; import lombok.NonNull; public interface LambdaParameter extends INode { @Override LambdaParameter clone(); Name getName(); void setName(@NonNull Name name); }
193
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
FunctionCall.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/FunctionCall.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class FunctionCall extends Node implements Expression, TypeArgumentHolder { protected @NonNull Optional<? extends Expression> object; protected @NonNull Name name; private @NonNull List<? extends Expression> arguments; private @NonNull List<? extends TypeArgument> typeArguments; public FunctionCall(Name name, List<? extends Expression> arguments) { this(name, emptyList(), arguments); } public FunctionCall(Name name, Expression... arguments) { this(name, List.of(arguments)); } public FunctionCall(Name name, List<? extends TypeArgument> typeArguments, List<? extends Expression> arguments) { this(Optional.empty(), name, typeArguments, arguments); } public FunctionCall(Name name, List<? extends TypeArgument> typeArguments, Expression... arguments) { this(name, typeArguments, List.of(arguments)); } public FunctionCall(Optional<? extends Expression> object, Name name, List<? extends Expression> arguments) { this(object, name, emptyList(), arguments); } public FunctionCall(Optional<? extends Expression> object, Name name, Expression... arguments) { this(object, name, List.of(arguments)); } public FunctionCall(Expression object, Name name, List<? extends Expression> arguments) { this(Optional.ofNullable(object), name, arguments); } public FunctionCall(Expression object, Name name, Expression... arguments) { this(object, name, List.of(arguments)); } public FunctionCall(Optional<? extends Expression> object, Name name, List<? extends TypeArgument> typeArguments, Expression... arguments) { this(object, name, typeArguments, List.of(arguments)); } public FunctionCall(Expression object, Name name, List<? extends TypeArgument> typeArguments, List<? extends Expression> arguments) { this(Optional.ofNullable(object), name, typeArguments, arguments); } public FunctionCall(Expression object, Name name, List<? extends TypeArgument> typeArguments, Expression... arguments) { this(object, name, typeArguments, List.of(arguments)); } public FunctionCall(Optional<? extends Expression> object, Name name, List<? extends TypeArgument> typeArguments, List<? extends Expression> arguments) { setObject(object); setName(name); setTypeArguments(typeArguments); setArguments(arguments); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public FunctionCall clone() { return new FunctionCall(clone(getObject()), getName(), clone(getTypeArguments()), clone(getArguments())); } @Override public String toCode() { return getObject().map(object -> wrap(object).toCode() + ".").orElse("") + typeArgumentString() + getName() + "(" + joinNodes(", ", getArguments()) + ")"; } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } public void setArguments(@NonNull List<? extends Expression> arguments) { this.arguments = newList(arguments); } public final void setArguments(Expression... arguments) { setArguments(List.of(arguments)); } public void setObject(@NonNull Optional<? extends Expression> object) { this.object = object; } public final void setObject(Expression object) { setObject(Optional.ofNullable(object)); } public final void setObject() { setObject(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitFunctionCall(this, parent, cast(replacer))) { getObject().ifPresent(object -> object.<Expression>accept(visitor, this, this::setObject)); getName().accept(visitor, this, this::setName); visitList(visitor, getTypeArguments()); visitList(visitor, getArguments()); } } }
4,175
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ModuleCompilationUnit.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ModuleCompilationUnit.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ModuleCompilationUnit extends CompilationUnit implements Annotated, Documented { protected @NonNull QualifiedName name; protected boolean open; private @NonNull List<Annotation> annotations; private @NonNull List<? extends Directive> directives; private @NonNull Optional<String> docComment; public ModuleCompilationUnit(QualifiedName name, List<? extends Directive> directives) { this(name, false, directives); } public ModuleCompilationUnit(QualifiedName name, boolean open, List<? extends Directive> directives) { this(name, open, directives, emptyList(), Optional.empty()); } public ModuleCompilationUnit(QualifiedName name, boolean open, List<? extends Directive> directives, List<Annotation> annotations, Optional<String> docComment) { this(emptyList(), name, open, directives, annotations, docComment); } public ModuleCompilationUnit(List<ImportDecl> imports, QualifiedName name, boolean open, List<? extends Directive> directives, List<Annotation> annotations, Optional<String> docComment) { super(imports); setName(name); setOpen(open); setDirectives(directives); setAnnotations(annotations); setDocComment(docComment); } @Override public ModuleCompilationUnit clone() { return new ModuleCompilationUnit(clone(getImports()), getName(), isOpen(), clone(getDirectives()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { var directives = getDirectives(); return importString() + docString() + annotationString() + (isOpen()? "open module " : "module ") + getName() + " {" + (directives.isEmpty()? "}" : "\n" + join("", directives, directive -> directive.toCode().indent(4)) + "}" ); } public void setDirectives(@NonNull List<? extends Directive> directives) { this.directives = newList(directives); } public final void setDirectives(Directive... directives) { setDirectives(List.of(directives)); } @Override public void setAnnotations(@NonNull List<Annotation> annotations) { this.annotations = newList(annotations); } @Override public final void setAnnotations(Annotation... annotations) { setAnnotations(List.of(annotations)); } @Override public void setDocComment(@NonNull Optional<String> docComment) { this.docComment = docComment; } @Override public final void setDocComment(String docComment) { setDocComment(Optional.ofNullable(docComment)); } @Override public final void setDocComment() { setDocComment(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitModuleCompilationUnit(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getImports()); visitList(visitor, getDirectives()); visitList(visitor, getAnnotations()); } } }
3,131
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
VoidType.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/VoidType.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class VoidType extends Type { public VoidType() { super(emptyList()); } public VoidType(List<Annotation> annotations) { super(annotations); } @Override public VoidType clone() { return new VoidType(clone(getAnnotations())); } @Override public String toCode() { return annotationString(false) + "void"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitVoidType(this, parent, cast(replacer))) { visitList(visitor, getAnnotations()); } } }
786
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Statement.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Statement.java
package jtree.nodes; public interface Statement extends REPLEntry { @Override Statement clone(); }
102
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
CompoundStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/CompoundStmt.java
package jtree.nodes; public interface CompoundStmt extends Statement { @Override CompoundStmt clone(); default String bodyString(Statement body) { if(body instanceof Block) { return " " + body.toCode(); } else { return "\n" + body.toCode().indent(4).stripTrailing(); } } }
295
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ReturnStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ReturnStmt.java
package jtree.nodes; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ReturnStmt extends Node implements Statement { protected @NonNull Optional<? extends Expression> expression; public ReturnStmt() { this(Optional.empty()); } public ReturnStmt(Expression expression) { this(Optional.ofNullable(expression)); } public ReturnStmt(Optional<? extends Expression> expression) { setExpression(expression); } @Override public ReturnStmt clone() { return new ReturnStmt(clone(getExpression())); } @Override public String toCode() { return "return" + getExpression().map(expression -> " " + expression.toCode()).orElse("") + ";"; } public void setExpression(@NonNull Optional<? extends Expression> expression) { this.expression = expression; } public final void setExpression(Expression expression) { setExpression(Optional.ofNullable(expression)); } public final void setExpression() { setExpression(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitReturnStmt(this, parent, cast(replacer))) { getExpression().ifPresent(expr -> expr.<Expression>accept(visitor, this, this::setExpression)); } } }
1,410
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
SuperFunctionCall.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/SuperFunctionCall.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class SuperFunctionCall extends Node implements Expression, TypeArgumentHolder { protected @NonNull Optional<QualifiedName> object; protected @NonNull Name name; private @NonNull List<? extends Expression> arguments; private @NonNull List<? extends TypeArgument> typeArguments; public SuperFunctionCall(Name name, List<? extends Expression> arguments) { this(name, emptyList(), arguments); } public SuperFunctionCall(Name name, Expression... arguments) { this(name, List.of(arguments)); } public SuperFunctionCall(Name name, List<? extends TypeArgument> typeArguments, List<? extends Expression> arguments) { this(Optional.empty(), name, typeArguments, arguments); } public SuperFunctionCall(Name name, List<? extends TypeArgument> typeArguments, Expression... arguments) { this(name, typeArguments, List.of(arguments)); } public SuperFunctionCall(Optional<QualifiedName> object, Name name, List<? extends Expression> arguments) { this(object, name, emptyList(), arguments); } public SuperFunctionCall(Optional<QualifiedName> object, Name name, Expression... arguments) { this(object, name, List.of(arguments)); } public SuperFunctionCall(QualifiedName object, Name name, List<? extends Expression> arguments) { this(Optional.ofNullable(object), name, arguments); } public SuperFunctionCall(QualifiedName object, Name name, Expression... arguments) { this(Optional.ofNullable(object), name, List.of(arguments)); } public SuperFunctionCall(Optional<QualifiedName> object, Name name, List<? extends TypeArgument> typeArguments, Expression... arguments) { this(object, name, typeArguments, List.of(arguments)); } public SuperFunctionCall(QualifiedName object, Name name, List<? extends TypeArgument> typeArguments, List<? extends Expression> arguments) { this(Optional.ofNullable(object), name, typeArguments, arguments); } public SuperFunctionCall(QualifiedName object, Name name, List<? extends TypeArgument> typeArguments, Expression... arguments) { this(Optional.ofNullable(object), name, typeArguments, List.of(arguments)); } public SuperFunctionCall(Optional<QualifiedName> object, Name name, List<? extends TypeArgument> typeArguments, List<? extends Expression> arguments) { setObject(object); setName(name); setTypeArguments(typeArguments); setArguments(arguments); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public SuperFunctionCall clone() { return new SuperFunctionCall(clone(getObject()), getName(), clone(getTypeArguments()), clone(getArguments())); } @Override public String toCode() { return getObject().map(object -> object.toCode() + ".").orElse("") + "super." + typeArgumentString() + getName() + "(" + joinNodes(", ", getArguments()) + ")"; } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } public void setArguments(@NonNull List<? extends Expression> arguments) { this.arguments = newList(arguments); } public final void setArguments(Expression... arguments) { setArguments(List.of(arguments)); } public void setObject(@NonNull Optional<QualifiedName> object) { this.object = object; } public final void setObject(QualifiedName object) { setObject(Optional.ofNullable(object)); } public final void setObject() { setObject(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitSuperFunctionCall(this, parent, cast(replacer))) { getObject().ifPresent(name -> name.<QualifiedName>accept(visitor, this, this::setObject)); getName().accept(visitor, this, this::setName); visitList(visitor, getTypeArguments()); visitList(visitor, getArguments()); } } }
4,274
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
FunctionDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/FunctionDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class FunctionDecl extends GenericDecl implements Dimensioned, REPLEntry { protected @NonNull Type returnType; protected @NonNull Optional<ThisParameter> thisParameter; private @NonNull List<FormalParameter> parameters; private @NonNull List<GenericType> exceptions; private @NonNull Optional<Block> body; private @NonNull List<Dimension> dimensions; public FunctionDecl(Name name, Type returnType, List<FormalParameter> parameters, Optional<Block> body) { this(name, returnType, parameters, emptyList(), body); } public FunctionDecl(Name name, Type returnType, List<FormalParameter> parameters, Block body) { this(name, returnType, parameters, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, Optional<Block> body) { this(name, typeParameters, returnType, parameters, emptyList(), body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, Block body) { this(name, typeParameters, returnType, parameters, Optional.ofNullable(body)); } public FunctionDecl(Name name, Type returnType, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body) { this(name, emptyList(), returnType, parameters, exceptions, body, emptyList(), emptyList()); } public FunctionDecl(Name name, Type returnType, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, returnType, parameters, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body) { this(name, typeParameters, returnType, parameters, exceptions, body, emptyList(), emptyList()); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, typeParameters, returnType, parameters, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body, List<Modifier> modifiers, List<Annotation> annotations) { this(name, typeParameters, returnType, Optional.empty(), parameters, exceptions, body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations) { this(name, typeParameters, returnType, parameters, exceptions, Optional.ofNullable(body), modifiers, annotations); } public FunctionDecl(Name name, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, Optional<Block> body) { this(name, returnType, thisParameter, parameters, emptyList(), body); } public FunctionDecl(Name name, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, Block body) { this(name, returnType, thisParameter, parameters, Optional.ofNullable(body)); } public FunctionDecl(Name name, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, Optional<Block> body) { this(name, returnType, Optional.ofNullable(thisParameter), parameters, body); } public FunctionDecl(Name name, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, Block body) { this(name, returnType, Optional.ofNullable(thisParameter), parameters, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, Optional<Block> body) { this(name, typeParameters, returnType, thisParameter, parameters, emptyList(), body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, Block body) { this(name, typeParameters, returnType, thisParameter, parameters, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, Optional<Block> body) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, Block body) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, Optional.ofNullable(body)); } public FunctionDecl(Name name, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body) { this(name, emptyList(), returnType, thisParameter, parameters, exceptions, body, emptyList(), emptyList(), Optional.empty()); } public FunctionDecl(Name name, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, returnType, thisParameter, parameters, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body) { this(name, returnType, Optional.ofNullable(thisParameter), parameters, exceptions, body); } public FunctionDecl(Name name, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, returnType, Optional.ofNullable(thisParameter), parameters, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body) { this(name, typeParameters, returnType, thisParameter, parameters, exceptions, body, emptyList(), emptyList(), Optional.empty()); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, typeParameters, returnType, thisParameter, parameters, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, exceptions, body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, thisParameter, parameters, exceptions, Optional.ofNullable(body), modifiers, annotations, docComment); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, exceptions, body, modifiers, annotations, docComment); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, exceptions, Optional.ofNullable(body), modifiers, annotations, docComment); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Optional<Block> body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, thisParameter, parameters, emptyList(), exceptions, body, modifiers, annotations, docComment); } public FunctionDecl(Name name, Type returnType, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body) { this(name, emptyList(), returnType, parameters, dimensions, exceptions, body, emptyList(), emptyList()); } public FunctionDecl(Name name, Type returnType, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body) { this(name, returnType, parameters, dimensions, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body) { this(name, typeParameters, returnType, parameters, dimensions, exceptions, body, emptyList(), emptyList()); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body) { this(name, typeParameters, returnType, parameters, dimensions, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body, List<Modifier> modifiers, List<Annotation> annotations) { this(name, typeParameters, returnType, Optional.empty(), parameters, dimensions, exceptions, body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations) { this(name, typeParameters, returnType, parameters, dimensions, exceptions, Optional.ofNullable(body), modifiers, annotations); } public FunctionDecl(Name name, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body) { this(name, emptyList(), returnType, thisParameter, parameters, dimensions, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body) { this(name, emptyList(), returnType, Optional.ofNullable(thisParameter), parameters, dimensions, exceptions, body); } public FunctionDecl(Name name, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body) { this(name, emptyList(), returnType, Optional.ofNullable(thisParameter), parameters, dimensions, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body) { this(name, typeParameters, returnType, thisParameter, parameters, dimensions, exceptions, body, emptyList(), emptyList(), Optional.empty()); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body) { this(name, typeParameters, returnType, thisParameter, parameters, dimensions, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, dimensions, exceptions, body); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, dimensions, exceptions, Optional.ofNullable(body)); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, thisParameter, parameters, dimensions, exceptions, Optional.ofNullable(body), modifiers, annotations, docComment); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, dimensions, exceptions, body, modifiers, annotations, docComment); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, ThisParameter thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, returnType, Optional.ofNullable(thisParameter), parameters, dimensions, exceptions, Optional.ofNullable(body), modifiers, annotations, docComment); } public FunctionDecl(Name name, List<TypeParameter> typeParameters, Type returnType, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<Dimension> dimensions, List<GenericType> exceptions, Optional<Block> body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(name, typeParameters, modifiers, annotations, docComment); setReturnType(returnType); setExceptions(exceptions); setParameters(parameters); setBody(body); setThisParameter(thisParameter); setDimensions(dimensions); } @Override public FunctionDecl clone() { return new FunctionDecl(getName(), clone(getTypeParameters()), getReturnType().clone(), clone(getThisParameter()), clone(getParameters()), clone(getDimensions()), clone(getExceptions()), clone(getBody()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { var exceptions = getExceptions(); var parameters = getParameters(); var typeParameterString = typeParameterString(); if(!typeParameterString.isEmpty()) { typeParameterString += ' '; } var dimensionString = dimensionString(); if(dimensionString.startsWith("@")) { dimensionString = ' ' + dimensionString; } return docString() + annotationString() + modifierString() + typeParameterString + getReturnType().toCode() + " " + getName() + "(" + (parameters.isEmpty() ? getThisParameter().map(ThisParameter::toCode) .orElse("") : getThisParameter().map(thisParameter -> thisParameter.toCode() + ", ") .orElse("") + joinNodes(", ", parameters)) + ")" + dimensionString + (exceptions.isEmpty()? "" : " throws " + joinNodes(", ", exceptions)) + body.map(body -> " " + body.toCode()).orElse(";"); } public void setExceptions(@NonNull List<GenericType> exceptions) { this.exceptions = newList(exceptions); } public final void setExceptions(GenericType... exceptions) { setExceptions(List.of(exceptions)); } public void setParameters(@NonNull List<FormalParameter> parameters) { this.parameters = newList(parameters); } public final void setParameters(FormalParameter... parameters) { setParameters(List.of(parameters)); } public void setBody(@NonNull Optional<Block> body) { this.body = body; } public final void setBody(Block body) { setBody(Optional.ofNullable(body)); } public final void setBody() { setBody(Optional.empty()); } public void setThisParameter(@NonNull Optional<ThisParameter> thisParameter) { this.thisParameter = thisParameter; } public final void setThisParameter(ThisParameter thisParameter) { setThisParameter(Optional.ofNullable(thisParameter)); } public final void setThisParameter() { setThisParameter(Optional.empty()); } @Override public void setDimensions(@NonNull List<Dimension> dimensions) { this.dimensions = newList(dimensions); } @Override public final void setDimensions(Dimension... dimensions) { setDimensions(List.of(dimensions)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitFunctionDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getTypeParameters()); getReturnType().accept(visitor, this, this::setReturnType); getThisParameter().ifPresent(thisParameter -> thisParameter.<ThisParameter>accept(visitor, this, this::setThisParameter)); visitList(visitor, getParameters()); visitList(visitor, getExceptions()); getBody().ifPresent(body -> body.<Block>accept(visitor, this, this::setBody)); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
19,157
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
WhileStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/WhileStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class WhileStmt extends Node implements CompoundStmt { protected @NonNull Expression condition; protected @NonNull Statement body; public WhileStmt(Expression condition, Statement body) { setCondition(condition); setBody(body); } @Override public WhileStmt clone() { return new WhileStmt(getCondition().clone(), getBody().clone()); } @Override public String toCode() { return "while(" + getCondition().toCode() + ")" + bodyString(getBody()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitWhileStmt(this, parent, cast(replacer))) { getCondition().accept(visitor, this, this::setCondition); getBody().accept(visitor, this, this::setBody); } } }
962
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Modified.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Modified.java
package jtree.nodes; import java.util.List; import java.util.stream.Collectors; import lombok.NonNull; public interface Modified extends INode { @Override Modified clone(); List<Modifier> getModifiers(); void setModifiers(@NonNull List<Modifier> modifiers); void setModifiers(Modifier... modifiers); default String modifierString() { var modifiers = getModifiers(); if(modifiers.isEmpty()) { return ""; } else { return modifiers.stream() .map(Modifier::toCode) .collect(Collectors.joining(" ", "", " ")); } } default boolean hasModifier(Modifier modifier) { return getModifiers().contains(modifier); } default boolean hasModifier(CharSequence modifier) { for(var mod : getModifiers()) { if(mod.toString().contentEquals(modifier)) { return true; } } return false; } default boolean hasVisibilityModifier() { for(var mod : getModifiers()) { switch(mod.toString()) { case "public", "private", "protected", "package": return true; } } return false; } }
1,050
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
NormalCompilationUnit.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/NormalCompilationUnit.java
package jtree.nodes; import static jtree.util.Utils.*; import static lombok.AccessLevel.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class NormalCompilationUnit extends CompilationUnit { @Getter(NONE) @Setter(NONE) protected @NonNull Optional<PackageDecl> _package; protected @NonNull List<? extends TypeDecl> declarations; public NormalCompilationUnit(List<? extends TypeDecl> declarations) { this(Optional.empty(), declarations); } public NormalCompilationUnit(TypeDecl... declarations) { this(List.of(declarations)); } public NormalCompilationUnit(Optional<PackageDecl> _package, List<? extends TypeDecl> declarations) { this(_package, emptyList(), declarations); } public NormalCompilationUnit(PackageDecl _package, List<? extends TypeDecl> declarations) { this(Optional.ofNullable(_package), declarations); } public NormalCompilationUnit(Optional<PackageDecl> _package, TypeDecl... declarations) { this(_package, List.of(declarations)); } public NormalCompilationUnit(PackageDecl _package, TypeDecl... declarations) { this(Optional.ofNullable(_package), List.of(declarations)); } public NormalCompilationUnit(Optional<PackageDecl> _package, List<ImportDecl> imports, TypeDecl... declarations) { this(_package, imports, List.of(declarations)); } public NormalCompilationUnit(PackageDecl _package, List<ImportDecl> imports, List<? extends TypeDecl> declarations) { this(Optional.ofNullable(_package), imports, declarations); } public NormalCompilationUnit(PackageDecl _package, List<ImportDecl> imports, TypeDecl... declarations) { this(Optional.ofNullable(_package), imports, List.of(declarations)); } public NormalCompilationUnit(Optional<PackageDecl> _package, List<ImportDecl> imports, List<? extends TypeDecl> declarations) { super(imports); setPackage(_package); setDeclarations(declarations); } @Override public NormalCompilationUnit clone() { return new NormalCompilationUnit(clone(getPackage()), clone(getImports()), clone(getDeclarations())); } @Override public String toCode() { return (getPackage().map(pckg -> pckg.toCode() + "\n").orElse("") + importString() + joinNodes("\n\n", getDeclarations())).stripTrailing(); } public Optional<PackageDecl> getPackage() { return _package; } public void setPackage(@NonNull Optional<PackageDecl> _package) { this._package = _package; } public final void setPackage(PackageDecl _package) { setPackage(Optional.ofNullable(_package)); } public final void setPackage() { setPackage(Optional.empty()); } public void setDeclarations(@NonNull List<? extends TypeDecl> declarations) { this.declarations = newList(declarations); } public final void setDeclarations(TypeDecl... declarations) { setDeclarations(List.of(declarations)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitNormalCompilationUnit(this, parent, cast(replacer))) { getPackage().ifPresent(pckg -> pckg.<PackageDecl>accept(visitor, this, this::setPackage)); visitList(visitor, getImports()); visitList(visitor, getDeclarations()); } } }
3,362
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ArrayCreator.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ArrayCreator.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Objects; import java.util.function.Consumer; import jtree.util.Either; import jtree.util.Utils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ArrayCreator extends Node implements Expression, Dimensioned { protected @NonNull Type baseType; protected @NonNull Either<? extends List<Size>, ArrayInitializer<? extends Initializer>> sizesOrInitializer; private @NonNull List<Dimension> dimensions; public ArrayCreator(Type baseType, @NonNull List<Size> sizes) { this(baseType, Either.first(sizes)); } public ArrayCreator(Type baseType, Size... sizes) { this(baseType, List.of(sizes)); } public ArrayCreator(Type baseType, @NonNull ArrayInitializer<? extends Initializer> initializer) { this(baseType, Either.second(initializer)); } public ArrayCreator(Type baseType, @NonNull Initializer... initializers) { this(baseType, Either.second(new ArrayInitializer<>(initializers))); } public ArrayCreator(Type baseType, List<Size> sizes, List<Dimension> dimensions) { this(baseType, Either.first(sizes), dimensions); } public ArrayCreator(Type baseType, ArrayInitializer<? extends Initializer> initializer, List<Dimension> dimensions) { this(baseType, Either.second(initializer), dimensions); } public ArrayCreator(Type baseType, Either<? extends List<Size>, ArrayInitializer<? extends Initializer>> sizesOrInitializer) { this(baseType, sizesOrInitializer, List.of(new Dimension())); } public ArrayCreator(Type baseType, Either<? extends List<Size>, ArrayInitializer<? extends Initializer>> sizesOrInitializer, List<Dimension> dimensions) { setBaseType(baseType); setSizesOrInitializer(sizesOrInitializer); setDimensions(dimensions); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public ArrayCreator clone() { return new ArrayCreator(getBaseType().clone(), clone(getSizesOrInitializer()), clone(getDimensions())); } @Override public String toCode() { return "new " + getBaseType().toCode() + getSizesOrInitializer().unravel( sizes -> joinNodes("", sizes) + dimensionString(), initializer -> dimensionString() + " " + initializer.toCode() ); } public void setSizesOrInitializer(@NonNull Either<? extends List<Size>, ArrayInitializer<? extends Initializer>> sizesOrInitializer) { this.sizesOrInitializer = sizesOrInitializer.map(Utils::newList, Objects::requireNonNull); } public final void setSizes(@NonNull List<Size> sizes) { setSizesOrInitializer(Either.first(sizes)); } public final void setSizes(Size... sizes) { setSizes(List.of(sizes)); } public final void setInitializer(@NonNull ArrayInitializer<? extends Initializer> initializer) { setSizesOrInitializer(Either.second(initializer)); } public final void setInitializer(Initializer... initializers) { setInitializer(new ArrayInitializer<>(initializers)); } @Override public void setDimensions(@NonNull List<Dimension> dimensions) { this.dimensions = newList(dimensions); } @Override public final void setDimensions(Dimension... dimensions) { setDimensions(List.of(dimensions)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitArrayCreator(this, parent, cast(replacer))) { getBaseType().accept(visitor, this, this::setBaseType); getSizesOrInitializer().accept(sizes -> visitList(visitor, sizes), initializer -> initializer.<ArrayInitializer<? extends Initializer>>accept(visitor, this, this::setInitializer)); visitList(visitor, getDimensions()); } } }
3,759
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
EnumField.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/EnumField.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import jtree.util.Utils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class EnumField extends Node implements Member, Annotated, Documented { protected @NonNull Name name; protected @NonNull Optional<? extends List<? extends Expression>> arguments; protected @NonNull Optional<? extends List<? extends Member>> members; protected @NonNull List<Annotation> annotations; protected @NonNull Optional<String> docComment; public EnumField(Name name) { this(name, Optional.empty()); } public EnumField(Name name, Optional<? extends List<? extends Expression>> arguments) { this(name, arguments, Optional.empty()); } public EnumField(Name name, List<? extends Expression> arguments) { this(name, Optional.ofNullable(arguments)); } public EnumField(Name name, Expression... arguments) { this(name, List.of(arguments)); } public EnumField(Name name, Optional<? extends List<? extends Expression>> arguments, Optional<? extends List<? extends Member>> members) { this(name, arguments, members, emptyList(), Optional.empty()); } public EnumField(Name name, List<? extends Expression> arguments, Optional<? extends List<? extends Member>> members) { this(name, Optional.ofNullable(arguments), members); } public EnumField(Name name, List<? extends Expression> arguments, List<? extends Member> members) { this(name, Optional.ofNullable(arguments), Optional.ofNullable(members)); } public EnumField(Name name, List<? extends Expression> arguments, Optional<? extends List<? extends Member>> members, List<Annotation> annotations, Optional<String> docComment) { this(name, Optional.ofNullable(arguments), members, annotations, docComment); } public EnumField(Name name, List<? extends Expression> arguments, List<? extends Member> members, List<Annotation> annotations, Optional<String> docComment) { this(name, Optional.ofNullable(arguments), Optional.ofNullable(members), annotations, docComment); } public EnumField(Name name, Optional<? extends List<? extends Expression>> arguments, Optional<? extends List<? extends Member>> members, List<Annotation> annotations, Optional<String> docComment) { setName(name); setArguments(arguments); setMembers(members); setAnnotations(annotations); setDocComment(docComment); } @Override public EnumField clone() { return new EnumField(getName(), clone(getArguments()), clone(getMembers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { return docString() + annotationString() + getName() + getArguments().map(arguments -> "(" + joinNodes(", ", arguments) + ")") .orElse("") + getMembers().map(members -> members.isEmpty()? " {}" : " {\n" + join("", members, member -> member.toCode().indent(4)) + "}") .orElse(""); } public void setArguments(@NonNull Optional<? extends List<? extends Expression>> arguments) { this.arguments = arguments.map(Utils::newList); } public final void setArguments(List<? extends Expression> arguments) { setArguments(Optional.ofNullable(arguments)); } public final void setArguments(Expression... arguments) { setArguments(List.of(arguments)); } public void setMembers(@NonNull Optional<? extends List<? extends Member>> members) { this.members = members.map(Utils::newList); } public final void setMembers(List<? extends Member> members) { setMembers(Optional.ofNullable(members)); } public final void setMembers(Member... members) { setMembers(List.of(members)); } @Override public void setAnnotations(@NonNull List<Annotation> annotations) { this.annotations = newList(annotations); } @Override public final void setAnnotations(Annotation... annotations) { setAnnotations(List.of(annotations)); } @Override public void setDocComment(@NonNull Optional<String> docComment) { this.docComment = docComment; } @Override public final void setDocComment(String docComment) { setDocComment(Optional.ofNullable(docComment)); } @Override public final void setDocComment() { setDocComment(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitEnumField(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); getArguments().ifPresent(arguments -> visitList(visitor, arguments)); getMembers().ifPresent(members -> visitList(visitor, members)); visitList(visitor, getAnnotations()); } } }
4,726
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Documented.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Documented.java
package jtree.nodes; import java.util.Optional; import lombok.NonNull; public interface Documented extends INode { @Override Documented clone(); Optional<String> getDocComment(); void setDocComment(@NonNull Optional<String> docComment); void setDocComment(String docComment); void setDocComment(); default String docString() { return getDocComment().orElse(""); } }
393
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Variable.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Variable.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class Variable extends Node implements Expression { protected @NonNull Name name; public Variable(String name) { this(new Name(name)); } public Variable(Name name) { setName(name); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public Variable clone() { return new Variable(getName()); } @Override public String toCode() { return getName().toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitVariable(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); } } }
855
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Initializer.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Initializer.java
package jtree.nodes; public interface Initializer extends AnnotationValue { @Override Initializer clone(); }
112
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TryStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TryStmt.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class TryStmt extends Node implements CompoundStmt { protected @NonNull List<? extends ResourceSpecifier> resources; protected @NonNull Block body; private @NonNull List<Catch> catches; private @NonNull Optional<Block> finallyBody; public TryStmt(List<? extends ResourceSpecifier> resources, Block body) { this(resources, body, emptyList(), Optional.empty()); } public TryStmt(Block body, List<Catch> catches) { this(body, catches, Optional.empty()); } public TryStmt(Block body, List<Catch> catches, Optional<Block> finallyBody) { this(emptyList(), body, catches, finallyBody); } public TryStmt(Block body, List<Catch> catches, Block finallyBody) { this(body, catches, Optional.ofNullable(finallyBody)); } public TryStmt(List<? extends ResourceSpecifier> resources, Block body, List<Catch> catches, Block finallyBody) { this(resources, body, catches, Optional.ofNullable(finallyBody)); } public TryStmt(List<? extends ResourceSpecifier> resources, Block body, List<Catch> catches, Optional<Block> finallyBody) { setResources(resources); setBody(body); setCatches(catches); setFinallyBody(finallyBody); } @Override public TryStmt clone() { return new TryStmt(clone(getResources()), getBody().clone(), clone(getCatches()), clone(getFinallyBody())); } @Override public String toCode() { var resources = getResources(); String result = "try"; if(!resources.isEmpty()) { String joined = joinNodes(" ", resources); joined = joined.substring(0, joined.length() - 1); // removes trailing ';' result += "(" + joined + ")"; } return (result + " " + getBody().toCode() + " " + joinNodes(" ", getCatches())).stripTrailing() + getFinallyBody().map(finallyBody -> " finally " + finallyBody.toCode()).orElse(""); } public void setResources(@NonNull List<? extends ResourceSpecifier> resources) { this.resources = newList(resources); } public final void setResources(ResourceSpecifier... resources) { setResources(List.of(resources)); } public void setCatches(@NonNull List<Catch> catches) { this.catches = newList(catches); } public final void setCatches(Catch... catches) { setCatches(List.of(catches)); } public void setFinallyBody(@NonNull Optional<Block> finallyBody) { this.finallyBody = finallyBody; } public final void setFinallyBody(Block finallyBody) { setFinallyBody(Optional.ofNullable(finallyBody)); } public final void setFinallyBody() { setFinallyBody(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitTryStmt(this, parent, cast(replacer))) { visitList(visitor, getResources()); getBody().accept(visitor, this, this::setBody); visitList(visitor, getCatches()); getFinallyBody().ifPresent(body -> body.<Block>accept(visitor, this, this::setFinallyBody)); } } }
3,183
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
PostIncrementExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/PostIncrementExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class PostIncrementExpr extends Node implements ChangeExpr { protected @NonNull Expression expression; public PostIncrementExpr(Expression expression) { setExpression(expression); } @Override public Precedence precedence() { return Precedence.POST_UNARY; } @Override public PostIncrementExpr clone() { return new PostIncrementExpr(getExpression().clone()); } @Override public String toCode() { return wrap(getExpression()).toCode() + "++"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitPostIncrementExpr(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); } } }
923
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AnnotationProperty.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AnnotationProperty.java
package jtree.nodes; import static jtree.util.Utils.*; import static lombok.AccessLevel.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class AnnotationProperty extends Declaration implements Member { protected @NonNull Name name; protected @NonNull Type type; @Getter(NONE) @Setter(NONE) protected @NonNull Optional<? extends AnnotationValue> _default; public AnnotationProperty(Name name, Type type) { this(name, type, Optional.empty()); } public AnnotationProperty(Name name, Type type, AnnotationValue _default) { this(name, type, Optional.ofNullable(_default)); } public AnnotationProperty(Name name, Type type, Optional<? extends AnnotationValue> _default) { this(name, type, _default, emptyList(), emptyList(), Optional.empty()); } public AnnotationProperty(Name name, Type type, Optional<? extends AnnotationValue> _default, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(modifiers, annotations, docComment); setName(name); setType(type); setDefault(_default); } @Override public AnnotationProperty clone() { return new AnnotationProperty(getName(), getType().clone(), clone(getDefault()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { return docString() + annotationString() + modifierString() + getType().toCode() + " " + getName() + "()" + getDefault().map(_default -> " default " + _default.toCode()).orElse("") + ";"; } public void setDefault(@NonNull Optional<? extends AnnotationValue> _default) { this._default = _default; } public final void setDefault(AnnotationValue _default) { setDefault(Optional.ofNullable(_default)); } public final void setDefault() { setDefault(Optional.empty()); } public Optional<? extends AnnotationValue> getDefault() { return _default; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitAnnotationProperty(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); getType().accept(visitor, this, this::setType); getDefault().ifPresent(_default -> _default.<AnnotationValue>accept(visitor, this, this::setDefault)); } } }
2,447
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ResourceSpecifier.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ResourceSpecifier.java
package jtree.nodes; public interface ResourceSpecifier extends Statement { @Override ResourceSpecifier clone(); }
118
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ImportDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ImportDecl.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ImportDecl extends Node implements REPLEntry { protected @NonNull QualifiedName name; protected boolean isStatic, wildcard; public ImportDecl(QualifiedName name) { this(name, false, false); } public ImportDecl(QualifiedName name, boolean isStatic, boolean wildcard) { setName(name); setStatic(isStatic); setWildcard(wildcard); } @Override public ImportDecl clone() { return new ImportDecl(getName(), isStatic(), isWildcard()); } @Override public String toCode() { return "import " + (isStatic()? "static " : "") + getName() + (isWildcard()? ".*;" : ";"); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitImportDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); } } }
1,029
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Dimensioned.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Dimensioned.java
package jtree.nodes; import java.util.List; import java.util.stream.Collectors; import lombok.NonNull; public interface Dimensioned extends INode { @Override Dimensioned clone(); List<Dimension> getDimensions(); void setDimensions(@NonNull List<Dimension> dimensions); void setDimensions(Dimension... dimensions); default String dimensionString() { return getDimensions().stream() .map(Dimension::toCode) .collect(Collectors.joining()); } }
482
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ArrayInitializer.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ArrayInitializer.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ArrayInitializer<V extends AnnotationValue> extends Node implements Initializer { protected @NonNull List<? extends V> elements; public ArrayInitializer(List<? extends V> elements) { setElements(elements); } @SafeVarargs public ArrayInitializer(V... elements) { setElements(elements); } @Override public ArrayInitializer<V> clone() { return new ArrayInitializer<>(clone(elements)); } @Override public String toCode() { return "{" + joinNodes(", ", getElements()) + "}"; } public void setElements(@NonNull List<? extends V> elements) { this.elements = newList(elements); } @SafeVarargs public final void setElements(V... elements) { setElements(List.of(elements)); } @SuppressWarnings("unchecked") @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitArrayInitializer(this, parent, (Consumer<ArrayInitializer<V>>)replacer)) { visitList(visitor, getElements()); } } }
1,255
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
OpensDirective.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/OpensDirective.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class OpensDirective extends Directive { protected @NonNull List<QualifiedName> friendModules; public OpensDirective(QualifiedName packageName) { this(packageName, emptyList()); } public OpensDirective(QualifiedName packageName, QualifiedName... friendModules) { this(packageName, List.of(friendModules)); } public OpensDirective(QualifiedName packageName, List<QualifiedName> friendModules) { super(packageName); setFriendModules(friendModules); } @Override public OpensDirective clone() { return new OpensDirective(getName(), clone(getFriendModules())); } @Override public String toCode() { var friendModules = getFriendModules(); return "exports " + getName() + (friendModules.isEmpty()? ";" : " to " + joinNodes(", ", friendModules) + ";"); } public void setFriendModules(@NonNull List<QualifiedName> friendModules) { this.friendModules = newList(friendModules); } public final void setFriendModules(QualifiedName... friendModules) { setFriendModules(List.of(friendModules)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitOpensDirective(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getFriendModules()); } } }
1,570
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Annotation.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Annotation.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.function.Consumer; import jtree.util.Either; import jtree.util.Utils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class Annotation extends Node implements AnnotationValue { protected GenericType type; protected Optional<Either<? extends List<AnnotationArgument>, ? extends AnnotationValue>> arguments; public Annotation(GenericType type) { this(type, Optional.empty()); } public Annotation(GenericType type, @NonNull List<AnnotationArgument> arguments) { this(type, Either.first(arguments)); } public Annotation(GenericType type, @NonNull AnnotationValue value) { this(type, Either.second(value)); } public Annotation(GenericType type, Either<? extends List<AnnotationArgument>, ? extends AnnotationValue> arguments) { this(type, Optional.of(arguments)); } public Annotation(GenericType type, Optional<Either<? extends List<AnnotationArgument>, ? extends AnnotationValue>> arguments) { setType(type); setArguments(arguments); } @Override public Annotation clone() { return new Annotation(getType().clone(), clone(getArguments())); } @Override public String toCode() { return "@" + getType().toCode() + getArguments().map(either -> either.unravel(nodes -> "(" + joinNodes(", ", nodes) + ")", value -> "(" + value.toCode() + ")") ).orElse(""); } public void setArguments(@NonNull Optional<Either<? extends List<AnnotationArgument>, ? extends AnnotationValue>> arguments) { this.arguments = arguments.map(either -> either.map(Utils::newList, Objects::requireNonNull)); } public final void setArguments(Either<? extends List<AnnotationArgument>, ? extends AnnotationValue> arguments) { setArguments(Optional.of(arguments)); } public final void setArguments(@NonNull List<AnnotationArgument> arguments) { setArguments(Either.first(arguments)); } public final void setArguments(@NonNull AnnotationValue value) { setArguments(Either.second(value)); } public final void setArguments(AnnotationArgument... arguments) { setArguments(List.of(arguments)); } public final void setArguments() { setArguments(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitAnnotation(this, parent, cast(replacer))) { getType().accept(visitor, this, this::setType); getArguments().ifPresent(either -> either.accept( list -> visitList(visitor, list), value -> value.accept(visitor, this, (AnnotationValue replacement) -> setArguments(replacement)) )); } } }
2,859
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ClassCreator.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ClassCreator.java
package jtree.nodes; import static jtree.util.Utils.*; import static lombok.AccessLevel.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import jtree.util.Utils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; import lombok.experimental.Accessors; @EqualsAndHashCode @Getter @Setter public class ClassCreator extends Node implements Expression, TypeArgumentHolder { protected @NonNull Optional<? extends Expression> object; protected @NonNull List<? extends TypeArgument> typeArguments; private @NonNull GenericType type; @Setter(NONE) @Accessors(fluent = true) protected boolean hasDiamond; protected @NonNull List<? extends Expression> arguments; private @NonNull Optional<? extends List<? extends Member>> members; public ClassCreator(GenericType type, List<? extends Expression> arguments) { this(type, false, arguments); } public ClassCreator(GenericType type, Expression... arguments) { this(type, List.of(arguments)); } public ClassCreator(GenericType type, boolean hasDiamond, List<? extends Expression> arguments) { this(emptyList(), type, hasDiamond, arguments); } public ClassCreator(GenericType type, boolean hasDiamond, Expression... arguments) { this(type, hasDiamond, List.of(arguments)); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments) { this(Optional.empty(), typeArguments, type, hasDiamond, arguments); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments, List<? extends Member> members) { this(typeArguments, type, hasDiamond, arguments, Optional.ofNullable(members)); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments, Optional<? extends List<? extends Member>> members) { this(Optional.empty(), typeArguments, type, hasDiamond, arguments, members); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, List<? extends Expression> arguments) { this(typeArguments, type, false, arguments); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, List<? extends Expression> arguments, Optional<? extends List<? extends Member>> members) { this(Optional.empty(), typeArguments, type, false, arguments, members); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, Expression... arguments) { this(typeArguments, type, hasDiamond, List.of(arguments)); } public ClassCreator(List<? extends TypeArgument> typeArguments, GenericType type, Expression... arguments) { this(typeArguments, type, List.of(arguments)); } public ClassCreator(Expression object, List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments) { this(Optional.ofNullable(object), typeArguments, type, hasDiamond, arguments); } public ClassCreator(Expression object, List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, Expression... arguments) { this(object, typeArguments, type, hasDiamond, List.of(arguments)); } public ClassCreator(Expression object, List<? extends TypeArgument> typeArguments, GenericType type, List<? extends Expression> arguments) { this(object, typeArguments, type, false, arguments); } public ClassCreator(Expression object, List<? extends TypeArgument> typeArguments, GenericType type, Expression... arguments) { this(object, typeArguments, type, false, List.of(arguments)); } public ClassCreator(Expression object, GenericType type, boolean hasDiamond, List<? extends Expression> arguments) { this(object, emptyList(), type, hasDiamond, arguments); } public ClassCreator(Expression object, GenericType type, boolean hasDiamond, Expression... arguments) { this(object, emptyList(), type, hasDiamond, List.of(arguments)); } public ClassCreator(Expression object, GenericType type, List<? extends Expression> arguments) { this(object, emptyList(), type, false, arguments); } public ClassCreator(Expression object, GenericType type, Expression... arguments) { this(object, emptyList(), type, false, List.of(arguments)); } public ClassCreator(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, Expression... arguments) { this(object, typeArguments, type, hasDiamond, List.of(arguments)); } public ClassCreator(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, GenericType type, List<? extends Expression> arguments) { this(object, typeArguments, type, false, arguments); } public ClassCreator(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, GenericType type, Expression... arguments) { this(object, typeArguments, type, false, List.of(arguments)); } public ClassCreator(Optional<? extends Expression> object, GenericType type, boolean hasDiamond, List<? extends Expression> arguments) { this(object, emptyList(), type, hasDiamond, arguments); } public ClassCreator(Optional<? extends Expression> object, GenericType type, boolean hasDiamond, Expression... arguments) { this(object, emptyList(), type, hasDiamond, List.of(arguments)); } public ClassCreator(Optional<? extends Expression> object, GenericType type, List<? extends Expression> arguments) { this(object, emptyList(), type, false, arguments); } public ClassCreator(Optional<? extends Expression> object, GenericType type, Expression... arguments) { this(object, emptyList(), type, false, List.of(arguments)); } public ClassCreator(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments) { this(object, typeArguments, type, hasDiamond, arguments, Optional.empty()); } public ClassCreator(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments, List<? extends Member> members) { this(object, typeArguments, type, hasDiamond, arguments, Optional.ofNullable(members)); } public ClassCreator(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, GenericType type, boolean hasDiamond, List<? extends Expression> arguments, Optional<? extends List<? extends Member>> members) { setObject(object); setTypeArguments(typeArguments); setType(type); setHasDiamond(hasDiamond); setArguments(arguments); setMembers(members); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public ClassCreator clone() { return new ClassCreator(clone(getObject()), clone(getTypeArguments()), getType().clone(), hasDiamond(), clone(getArguments()), clone(getMembers())); } @Override public String toCode() { var typeArguments = getTypeArguments(); var type = getType(); return getObject().map(object -> wrap(object).toCode() + ".").orElse("") + "new " + (typeArguments.isEmpty()? "" : typeArgumentString(typeArguments) + " ") + type.toCode() + (hasDiamond() && type.getTypeArguments().isEmpty()? "<>" : "") + "(" + joinNodes(", ", getArguments()) + ")" + getMembers().map(members -> members.isEmpty()? " {}" : " {\n" + join("", members, member -> member.toCode().indent(4)) + "}").orElse(""); } public void setHasDiamond(boolean hasDiamond) { this.hasDiamond = hasDiamond; } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } public void setArguments(@NonNull List<? extends Expression> arguments) { this.arguments = newList(arguments); } public final void setArguments(Expression... arguments) { setArguments(List.of(arguments)); } public void setObject(@NonNull Optional<? extends Expression> object) { this.object = object; } public final void setObject(Expression object) { setObject(Optional.ofNullable(object)); } public final void setObject() { setObject(Optional.empty()); } public void setMembers(@NonNull Optional<? extends List<? extends Member>> members) { this.members = members.map(Utils::newList); } public final void setMembers(List<? extends Member> members) { setMembers(Optional.ofNullable(members)); } public final void setMembers() { setMembers(Optional.empty()); } public final void setMembers(Member... members) { setMembers(List.of(members)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitClassCreator(this, parent, cast(replacer))) { getObject().ifPresent(object -> object.<Expression>accept(visitor, this, this::setObject)); visitList(visitor, getTypeArguments()); getType().accept(visitor, this, this::setType); visitList(visitor, getArguments()); getMembers().ifPresent(members -> visitList(visitor, members)); } } }
9,376
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
LabeledStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/LabeledStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class LabeledStmt extends Node implements CompoundStmt { protected @NonNull Name label; protected @NonNull Statement statement; public LabeledStmt(Name label, Statement statement) { setLabel(label); setStatement(statement); } @Override public LabeledStmt clone() { return new LabeledStmt(getLabel(), getStatement().clone()); } @Override public String toCode() { return getLabel() + ":" + bodyString(getStatement()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitLabeledStmt(this, parent, cast(replacer))) { getLabel().accept(visitor, this, this::setLabel); getStatement().accept(visitor, this, this::setStatement); } } }
940
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Declaration.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Declaration.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public abstract class Declaration extends Node implements Annotated, Modified, Documented { protected @NonNull List<Annotation> annotations; protected @NonNull List<Modifier> modifiers; protected @NonNull Optional<String> docComment; public Declaration(List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { setAnnotations(annotations); setModifiers(modifiers); setDocComment(docComment); } @Override public abstract Declaration clone(); @Override public void setAnnotations(@NonNull List<Annotation> annotations) { this.annotations = newList(annotations); } @Override public final void setAnnotations(Annotation... annotations) { setAnnotations(List.of(annotations)); } @Override public void setModifiers(@NonNull List<Modifier> modifiers) { this.modifiers = newList(modifiers); } @Override public final void setModifiers(Modifier... modifiers) { setModifiers(List.of(modifiers)); } @Override public void setDocComment(@NonNull Optional<String> docComment) { this.docComment = docComment; } @Override public final void setDocComment(String docComment) { setDocComment(Optional.ofNullable(docComment)); } @Override public final void setDocComment() { setDocComment(Optional.empty()); } }
1,532
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Lambda.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Lambda.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Objects; import java.util.function.Consumer; import jtree.util.Either; import jtree.util.Utils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class Lambda extends Node implements Expression { protected @NonNull Either<? extends List<FormalParameter>, ? extends List<InformalParameter>> parameters; protected @NonNull Either<Block, ? extends Expression> body; public Lambda(List<? extends LambdaParameter> parameters, Block body) { this(makeParameters(parameters), body); } public Lambda(List<? extends LambdaParameter> parameters, Expression body) { this(makeParameters(parameters), body); } public Lambda(List<? extends LambdaParameter> parameters, Either<Block, ? extends Expression> body) { this(makeParameters(parameters), body); } public Lambda(Either<? extends List<FormalParameter>, ? extends List<InformalParameter>> parameters, Block body) { this(parameters, Either.first(body)); } public Lambda(Either<? extends List<FormalParameter>, ? extends List<InformalParameter>> parameters, Expression body) { this(parameters, Either.second(body)); } public Lambda(Either<? extends List<FormalParameter>, ? extends List<InformalParameter>> parameters, Either<Block, ? extends Expression> body) { setParameters(parameters); setBody(body); } @SuppressWarnings("unchecked") private static Either<? extends List<FormalParameter>, ? extends List<InformalParameter>> makeParameters(List<? extends LambdaParameter> parameters) { if(parameters.isEmpty()) { return Either.second(emptyList()); } else { var first = parameters.get(0); if(first instanceof InformalParameter) { for(int i = 1; i < parameters.size(); i++) { InformalParameter.class.cast(parameters.get(i)); } return Either.second((List<InformalParameter>)parameters); } else { for(var param : parameters) { FormalParameter.class.cast(param); } return Either.first((List<FormalParameter>)parameters); } } } @Override public Precedence precedence() { return Precedence.ASSIGNMENT; } @Override public Lambda clone() { return new Lambda(clone(getParameters()), clone(getBody())); } @Override public String toCode() { String result; var eitherParameters = getParameters(); if(eitherParameters.isFirst()) { result = "(" + joinNodes(", ", eitherParameters.first()) + ")"; } else { var parameters = eitherParameters.second(); if(parameters.size() == 1) { result = parameters.get(0).toCode(); } else { result = "(" + joinNodes(", ", parameters) + ")"; } } result += " -> "; var body = getBody(); if(body.isFirst()) { var block = body.first(); result += block.isEmpty()? "{}" : block.toCode(); } else { result += body.second().toCode(); } return result; } public void setParameters(@NonNull Either<? extends List<FormalParameter>, ? extends List<InformalParameter>> parameters) { this.parameters = parameters.map(Utils::newList, Utils::newList); } public void setBody(@NonNull Either<Block, ? extends Expression> body) { Objects.requireNonNull(body.getValue()); this.body = body; } public final void setBody(Block body) { setBody(Either.first(body)); } public final void setBody(Expression body) { setBody(Either.second(body)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitLambda(this, parent, cast(replacer))) { getParameters().accept(params -> visitList(visitor, params), params -> visitList(visitor, params)); getBody().accept(block -> block.<Block>accept(visitor, this, this::setBody), expr -> expr.<Expression>accept(visitor, this, this::setBody)); } } }
3,892
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TypeIntersection.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TypeIntersection.java
package jtree.nodes; import static jtree.util.Utils.*; import static lombok.AccessLevel.*; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class TypeIntersection extends ReferenceType { @Getter(NONE) @Setter(NONE) protected @NonNull List<ReferenceType> types; public TypeIntersection(List<? extends ReferenceType> types) { this(types, emptyList()); } public TypeIntersection(ReferenceType... types) { this(List.of(types)); } public TypeIntersection(List<? extends ReferenceType> types, List<Annotation> annotations) { super(annotations); setTypes(types); } @Override public TypeIntersection clone() { return new TypeIntersection(clone(getTypes()), clone(getAnnotations())); } @Override public String toCode() { return annotationString(false) + joinNodes(" & ", getTypes()); } public void setTypes(@NonNull List<? extends ReferenceType> types) { if(types.size() < 2) { throw new IllegalArgumentException("Not enough types given"); } this.types = new ArrayList<>(types.size()); for(var type : types) { if(type instanceof TypeIntersection) { this.types.addAll(((TypeIntersection)type).getTypes()); } else { this.types.add(type); } } } public final void setTypes(ReferenceType... types) { setTypes(List.of(types)); } public List<? extends ReferenceType> getTypes() { return types; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitTypeIntersection(this, parent, cast(replacer))) { visitList(visitor, getTypes()); visitList(visitor, getAnnotations()); } } }
1,808
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TypeUnion.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TypeUnion.java
package jtree.nodes; import static jtree.util.Utils.*; import static lombok.AccessLevel.*; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class TypeUnion extends ReferenceType { @Getter(NONE) @Setter(NONE) protected @NonNull List<ReferenceType> types; public TypeUnion(List<? extends ReferenceType> types) { this(types, emptyList()); } public TypeUnion(ReferenceType... types) { this(List.of(types)); } public TypeUnion(List<? extends ReferenceType> types, List<Annotation> annotations) { super(annotations); setTypes(types); } @Override public TypeUnion clone() { return new TypeUnion(clone(getTypes()), clone(getAnnotations())); } @Override public String toCode() { return annotationString(false) + joinNodes(" | ", getTypes()); } public void setTypes(@NonNull List<? extends ReferenceType> types) { if(types.size() < 2) { throw new IllegalArgumentException("Not enough types given"); } this.types = new ArrayList<>(types.size()); for(var type : types) { if(type instanceof TypeUnion) { this.types.addAll(((TypeUnion)type).getTypes()); } else { this.types.add(type); } } } public final void setTypes(ReferenceType... types) { setTypes(List.of(types)); } public List<? extends ReferenceType> getTypes() { return types; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitTypeUnion(this, parent, cast(replacer))) { visitList(visitor, getTypes()); visitList(visitor, getAnnotations()); } } }
1,745
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Size.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Size.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class Size extends Node implements Annotated { protected @NonNull List<Annotation> annotations; protected @NonNull Expression expression; public Size(Expression expression) { this(expression, emptyList()); } public Size(Expression expression, List<Annotation> annotations) { setExpression(expression); setAnnotations(annotations); } @Override public Size clone() { return new Size(getExpression().clone(), clone(getAnnotations())); } @Override public String toCode() { return annotationString() + "[" + getExpression().toCode() + "]"; } @Override public void setAnnotations(@NonNull List<Annotation> annotations) { this.annotations = newList(annotations); } @Override public final void setAnnotations(Annotation... annotations) { setAnnotations(List.of(annotations)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitSize(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); visitList(visitor, getAnnotations()); } } }
1,353
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AnnotationValue.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AnnotationValue.java
package jtree.nodes; public interface AnnotationValue extends INode { @Override AnnotationValue clone(); }
110
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ClassInitializer.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ClassInitializer.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ClassInitializer extends Node implements Member { protected @NonNull Block block; protected boolean isStatic; public ClassInitializer(boolean isStatic, Block block) { setStatic(isStatic); setBlock(block); } @Override public ClassInitializer clone() { return new ClassInitializer(isStatic(), getBlock()); } @Override public String toCode() { return (isStatic()? "static " : "") + getBlock().toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitClassInitializer(this, parent, cast(replacer))) { getBlock().accept(visitor, this, this::setBlock); } } }
874
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
PostDecrementExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/PostDecrementExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class PostDecrementExpr extends Node implements ChangeExpr { protected @NonNull Expression expression; public PostDecrementExpr(Expression expression) { setExpression(expression); } @Override public Precedence precedence() { return Precedence.POST_UNARY; } @Override public PostDecrementExpr clone() { return new PostDecrementExpr(getExpression().clone()); } @Override public String toCode() { return wrap(getExpression()).toCode() + "--"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitPostDecrementExpr(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); } } }
923
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Annotated.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Annotated.java
package jtree.nodes; import java.util.List; import java.util.stream.Collectors; import lombok.NonNull; public interface Annotated extends INode { @Override Annotated clone(); List<Annotation> getAnnotations(); void setAnnotations(@NonNull List<Annotation> annotations); void setAnnotations(Annotation... annotations); default String annotationString(boolean newlines) { var annotations = getAnnotations(); if(annotations.isEmpty()) { return ""; } else { String sep = newlines? "\n" : " "; return annotations.stream() .map(Annotation::toCode) .collect(Collectors.joining(sep, "", sep)); } } default String annotationString() { return annotationString(true); } }
724
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ChangeExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ChangeExpr.java
package jtree.nodes; public interface ChangeExpr extends Expression { @Override default Expression wrap(Expression expr) { if(expr instanceof CastExpr || expr instanceof ClassCreator || expr instanceof ArrayCreator || expr.precedence().isGreaterThan(this.precedence())) { return new ParensExpr(expr); } else { return expr; } } }
348
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
YieldStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/YieldStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class YieldStmt extends Node implements Statement { protected @NonNull Expression expression; public YieldStmt(Expression expression) { setExpression(expression); } @Override public YieldStmt clone() { return new YieldStmt(getExpression().clone()); } @Override public String toCode() { return "yield " + expression.toCode() + ";"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitYieldStmt(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); } } }
799
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
SwitchCase.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/SwitchCase.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import jtree.util.Either; import jtree.util.Utils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class SwitchCase extends Node { protected @NonNull List<? extends Expression> labels; protected @NonNull Either<? extends List<? extends Statement>, ? extends Statement> body; public SwitchCase(Either<? extends List<? extends Statement>, ? extends Statement> body) { this(emptyList(), body); } public SwitchCase(@NonNull List<? extends Statement> body) { this(Either.first(body)); } public SwitchCase(@NonNull Statement body) { this(Either.second(body)); } public SwitchCase(List<? extends Expression> labels, @NonNull List<? extends Statement> body) { this(labels, Either.first(body)); } public SwitchCase(List<? extends Expression> labels, @NonNull Statement body) { this(labels, Either.second(body)); } public SwitchCase(List<? extends Expression> labels, Either<? extends List<? extends Statement>, ? extends Statement> body) { setLabels(labels); setBody(body); } @Override public SwitchCase clone() { return new SwitchCase(clone(getLabels()), clone(getBody())); } @Override public String toCode() { var labels = getLabels(); return (labels.isEmpty()? "default" : "case " + joinNodes(", ", labels)) + body.unravel(stmts -> ":" + (stmts.isEmpty() ? "" : stmts.size() == 1 && stmts.get(0) instanceof Block ? " " + stmts.get(0).toCode() : "\n" + join("", stmts, stmt -> stmt.toCode().indent(4))), stmt -> " -> " + stmt.toCode()); } public void setBody(Either<? extends List<? extends Statement>, ? extends Statement> body) { this.body = body.map(Utils::newList, (@NonNull var stmt) -> { if(!(stmt instanceof Block || stmt instanceof ThrowStmt || stmt instanceof ExpressionStmt)) { throw new IllegalArgumentException("single-statement case bodies can only be blocks, throw statements, or expression statements."); } return stmt; }); } public final void setBody(@NonNull List<? extends Statement> body) { setBody(Either.first(body)); } public final void setBody(@NonNull Block body) { setBody(Either.second(body)); } public final void setBody(@NonNull ThrowStmt body) { setBody(Either.second(body)); } public final void setBody(@NonNull ExpressionStmt body) { setBody(Either.second(body)); } public final void setBody(Expression body) { setBody(Either.second(new ExpressionStmt(body))); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitSwitchCase(this, parent, cast(replacer))) { visitList(visitor, getLabels()); getBody().accept(stmts -> visitList(visitor, stmts), stmt -> stmt.<Statement>accept(visitor, this, newstmt -> setBody(Either.second(newstmt)))); } } }
3,046
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ConditionalExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ConditionalExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ConditionalExpr extends Node implements Expression { protected @NonNull Expression condition, truePart, falsePart; public ConditionalExpr(Expression condition, Expression truePart, Expression falsePart) { setCondition(condition); setTruePart(truePart); setFalsePart(falsePart); } @Override public Precedence precedence() { return Precedence.TERNARY; } @Override public ConditionalExpr clone() { return new ConditionalExpr(getCondition().clone(), getTruePart().clone(), getFalsePart().clone()); } @Override public String toCode() { return wrap(getCondition()).toCode() + "? " + getTruePart().toCode() + " : " + wrap(getFalsePart()).toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitConditionalExpr(this, parent, cast(replacer))) { getCondition().accept(visitor, this, this::setCondition); getTruePart().accept(visitor, this, this::setTruePart); getFalsePart().accept(visitor, this, this::setFalsePart); } } }
1,250
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TypeTest.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TypeTest.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class TypeTest extends Node implements Expression { protected @NonNull Expression expression; protected @NonNull Type type; public TypeTest(Expression expression, Type type) { setExpression(expression); setType(type); } @Override public Precedence precedence() { return Precedence.RELATIONAL; } @Override public TypeTest clone() { return new TypeTest(getExpression().clone(), getType().clone()); } @Override public String toCode() { return getExpression().toCode() + " instanceof " + getType().toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitTypeTest(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); getType().accept(visitor, this, this::setType); } } }
1,032
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TypeParameterHolder.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TypeParameterHolder.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import lombok.NonNull; public interface TypeParameterHolder extends INode { @Override TypeParameterHolder clone(); List<TypeParameter> getTypeParameters(); void setTypeParameters(@NonNull List<TypeParameter> typeParameters); void setTypeParameters(TypeParameter... typeParameters); default String typeParameterString() { var typeParameters = getTypeParameters(); if(typeParameters.isEmpty()) { return ""; } else { return "<" + joinNodes(", ", typeParameters) + ">"; } } }
586
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AbstractTreeVisitor.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AbstractTreeVisitor.java
package jtree.nodes; import java.util.function.Consumer; import jtree.nodes.WildcardTypeArgument.Bound; public abstract class AbstractTreeVisitor implements TreeVisitor { @Override public boolean visitAnnotation(Annotation node, Node parent, Consumer<Annotation> replacer) { return true; } @Override public boolean visitAnnotationArgument(AnnotationArgument node, Node parent, Consumer<AnnotationArgument> replacer) { return true; } @Override public boolean visitAnnotationDecl(AnnotationDecl node, Node parent, Consumer<AnnotationDecl> replacer) { return true; } @Override public boolean visitAnnotationProperty(AnnotationProperty node, Node parent, Consumer<AnnotationProperty> replacer) { return true; } @Override public boolean visitArrayCreator(ArrayCreator node, Node parent, Consumer<ArrayCreator> replacer) { return true; } @Override public <T extends AnnotationValue> boolean visitArrayInitializer(ArrayInitializer<T> node, Node parent, Consumer<ArrayInitializer<T>> replacer) { return true; } @Override public boolean visitArrayType(ArrayType node, Node parent, Consumer<ArrayType> replacer) { return true; } @Override public boolean visitAssertStmt(AssertStmt node, Node parent, Consumer<AssertStmt> replacer) { return true; } @Override public boolean visitAssignExpr(AssignExpr node, Node parent, Consumer<AssignExpr> replacer) { return true; } @Override public boolean visitBinaryExpr(BinaryExpr node, Node parent, Consumer<BinaryExpr> replacer) { return true; } @Override public boolean visitBlock(Block node, Node parent, Consumer<Block> replacer) { return true; } @Override public boolean visitBreakStmt(BreakStmt node, Node parent, Consumer<BreakStmt> replacer) { return true; } @Override public boolean visitCastExpr(CastExpr node, Node parent, Consumer<CastExpr> replacer) { return true; } @Override public boolean visitCatch(Catch node, Node parent, Consumer<Catch> replacer) { return true; } @Override public boolean visitClassCreator(ClassCreator node, Node parent, Consumer<ClassCreator> replacer) { return true; } @Override public boolean visitClassDecl(ClassDecl node, Node parent, Consumer<ClassDecl> replacer) { return true; } @Override public boolean visitClassInitializer(ClassInitializer node, Node parent, Consumer<ClassInitializer> replacer) { return true; } @Override public boolean visitClassLiteral(ClassLiteral node, Node parent, Consumer<ClassLiteral> replacer) { return true; } @Override public boolean visitConditionalExpr(ConditionalExpr node, Node parent, Consumer<ConditionalExpr> replacer) { return true; } @Override public boolean visitConstructorCall(ConstructorCall node, Node parent, Consumer<ConstructorCall> replacer) { return true; } @Override public boolean visitConstructorDecl(ConstructorDecl node, Node parent, Consumer<ConstructorDecl> replacer) { return true; } @Override public boolean visitContinueStmt(ContinueStmt node, Node parent, Consumer<ContinueStmt> replacer) { return true; } @Override public boolean visitDimension(Dimension node, Node parent, Consumer<Dimension> replacer) { return true; } @Override public boolean visitDoStmt(DoStmt node, Node parent, Consumer<DoStmt> replacer) { return true; } @Override public boolean visitEmptyStmt(EmptyStmt node, Node parent, Consumer<EmptyStmt> replacer) { return true; } @Override public boolean visitEnumDecl(EnumDecl node, Node parent, Consumer<EnumDecl> replacer) { return true; } @Override public boolean visitEnumField(EnumField node, Node parent, Consumer<EnumField> replacer) { return true; } @Override public boolean visitExportsDirective(ExportsDirective node, Node parent, Consumer<ExportsDirective> replacer) { return true; } @Override public boolean visitExpressionStmt(ExpressionStmt node, Node parent, Consumer<ExpressionStmt> replacer) { return true; } @Override public boolean visitForEachStmt(ForEachStmt node, Node parent, Consumer<ForEachStmt> replacer) { return true; } @Override public boolean visitForStmt(ForStmt node, Node parent, Consumer<ForStmt> replacer) { return true; } @Override public boolean visitFormalParameter(FormalParameter node, Node parent, Consumer<FormalParameter> replacer) { return true; } @Override public boolean visitFunctionCall(FunctionCall node, Node parent, Consumer<FunctionCall> replacer) { return true; } @Override public boolean visitFunctionDecl(FunctionDecl node, Node parent, Consumer<FunctionDecl> replacer) { return true; } @Override public boolean visitGenericType(GenericType node, Node parent, Consumer<GenericType> replacer) { return true; } @Override public boolean visitIfStmt(IfStmt node, Node parent, Consumer<IfStmt> replacer) { return true; } @Override public boolean visitImportDecl(ImportDecl node, Node parent, Consumer<ImportDecl> replacer) { return true; } @Override public boolean visitIndexExpr(IndexExpr node, Node parent, Consumer<IndexExpr> replacer) { return true; } @Override public boolean visitInformalParameter(InformalParameter node, Node parent, Consumer<InformalParameter> replacer) { return true; } @Override public boolean visitInterfaceDecl(InterfaceDecl node, Node parent, Consumer<InterfaceDecl> replacer) { return true; } @Override public boolean visitLabeledStmt(LabeledStmt node, Node parent, Consumer<LabeledStmt> replacer) { return true; } @Override public boolean visitLambda(Lambda node, Node parent, Consumer<Lambda> replacer) { return true; } @Override public boolean visitLiteral(Literal node, Node parent, Consumer<Literal> replacer) { return true; } @Override public boolean visitMemberAccess(MemberAccess node, Node parent, Consumer<MemberAccess> replacer) { return true; } @Override public boolean visitMethodReference(MethodReference node, Node parent, Consumer<MethodReference> replacer) { return true; } @Override public boolean visitModifier(Modifier node, Node parent, Consumer<Modifier> replacer) { return false; } @Override public boolean visitModuleCompilationUnit(ModuleCompilationUnit node, Node parent, Consumer<ModuleCompilationUnit> replacer) { return true; } @Override public boolean visitName(Name node, Node parent, Consumer<Name> replacer) { return false; } @Override public boolean visitNormalCompilationUnit(NormalCompilationUnit node, Node parent, Consumer<NormalCompilationUnit> replacer) { return true; } @Override public boolean visitOpensDirective(OpensDirective node, Node parent, Consumer<OpensDirective> replacer) { return true; } @Override public boolean visitPackageDecl(PackageDecl node, Node parent, Consumer<PackageDecl> replacer) { return true; } @Override public boolean visitParensExpr(ParensExpr node, Node parent, Consumer<ParensExpr> replacer) { return true; } @Override public boolean visitPostIncrementExpr(PostIncrementExpr node, Node parent, Consumer<PostIncrementExpr> replacer) { return true; } @Override public boolean visitPostDecrementExpr(PostDecrementExpr node, Node parent, Consumer<PostDecrementExpr> replacer) { return true; } @Override public boolean visitPreIncrementExpr(PreIncrementExpr node, Node parent, Consumer<PreIncrementExpr> replacer) { return true; } @Override public boolean visitPreDecrementExpr(PreDecrementExpr node, Node parent, Consumer<PreDecrementExpr> replacer) { return true; } @Override public boolean visitPrimitiveType(PrimitiveType node, Node parent, Consumer<PrimitiveType> replacer) { return true; } @Override public boolean visitProvidesDirective(ProvidesDirective node, Node parent, Consumer<ProvidesDirective> replacer) { return true; } @Override public boolean visitQualifiedName(QualifiedName node, Node parent, Consumer<QualifiedName> replacer) { return false; } @Override public boolean visitRequiresDirective(RequiresDirective node, Node parent, Consumer<RequiresDirective> replacer) { return true; } @Override public boolean visitReturnStmt(ReturnStmt node, Node parent, Consumer<ReturnStmt> replacer) { return true; } @Override public boolean visitSize(Size node, Node parent, Consumer<Size> replacer) { return true; } @Override public boolean visitSuperFunctionCall(SuperFunctionCall node, Node parent, Consumer<SuperFunctionCall> replacer) { return true; } @Override public boolean visitSuperMethodReference(SuperMethodReference node, Node parent, Consumer<SuperMethodReference> replacer) { return true; } @Override public boolean visitSwitch(Switch node, Node parent, Consumer<Switch> replacer) { return true; } @Override public boolean visitSwitchCase(SwitchCase node, Node parent, Consumer<SwitchCase> replacer) { return true; } @Override public boolean visitSynchronizedStmt(SynchronizedStmt node, Node parent, Consumer<SynchronizedStmt> replacer) { return true; } @Override public boolean visitThis(This node, Node parent, Consumer<This> replacer) { return true; } @Override public boolean visitThisParameter(ThisParameter node, Node parent, Consumer<ThisParameter> replacer) { return true; } @Override public boolean visitThrowStmt(ThrowStmt node, Node parent, Consumer<ThrowStmt> replacer) { return true; } @Override public boolean visitTryStmt(TryStmt node, Node parent, Consumer<TryStmt> replacer) { return true; } @Override public boolean visitTypeUnion(TypeUnion node, Node parent, Consumer<TypeUnion> replacer) { return true; } @Override public boolean visitTypeIntersection(TypeIntersection node, Node parent, Consumer<TypeIntersection> replacer) { return true; } @Override public boolean visitTypeParameter(TypeParameter node, Node parent, Consumer<TypeParameter> replacer) { return true; } @Override public boolean visitTypeTest(TypeTest node, Node parent, Consumer<TypeTest> replacer) { return true; } @Override public boolean visitUnaryExpr(UnaryExpr node, Node parent, Consumer<UnaryExpr> replacer) { return true; } @Override public boolean visitUsesDirective(UsesDirective node, Node parent, Consumer<UsesDirective> replacer) { return true; } @Override public boolean visitVariable(Variable node, Node parent, Consumer<Variable> replacer) { return true; } @Override public boolean visitVariableDecl(VariableDecl node, Node parent, Consumer<VariableDecl> replacer) { return true; } @Override public boolean visitVariableDeclarator(VariableDeclarator node, Node parent, Consumer<VariableDeclarator> replacer) { return true; } @Override public boolean visitVoidType(VoidType node, Node parent, Consumer<VoidType> replacer) { return true; } @Override public boolean visitWhileStmt(WhileStmt node, Node parent, Consumer<WhileStmt> replacer) { return true; } @Override public boolean visitWildcardTypeArgument(WildcardTypeArgument node, Node parent, Consumer<WildcardTypeArgument> replacer) { return true; } @Override public boolean visitWildcardTypeArgumentBound(Bound node, Node parent, Consumer<Bound> replacer) { return true; } @Override public boolean visitYieldStmt(YieldStmt node, Node parent, Consumer<YieldStmt> replacer) { return true; } }
11,395
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
BreakStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/BreakStmt.java
package jtree.nodes; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class BreakStmt extends Node implements Statement { protected @NonNull Optional<Name> label; public BreakStmt() { this(Optional.empty()); } public BreakStmt(Name label) { this(Optional.ofNullable(label)); } public BreakStmt(Optional<Name> label) { setLabel(label); } @Override public BreakStmt clone() { return new BreakStmt(clone(getLabel())); } @Override public String toCode() { return "break" + getLabel().map(label -> " " + label.toCode()).orElse("") + ";"; } public void setLabel(@NonNull Optional<Name> label) { this.label = label; } public final void setLabel(Name label) { setLabel(Optional.ofNullable(label)); } public final void setLabel() { setLabel(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitBreakStmt(this, parent, cast(replacer))) { getLabel().ifPresent(label -> label.<Name>accept(visitor, this, this::setLabel)); } } }
1,228
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Node.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Node.java
package jtree.nodes; import static jtree.util.Utils.*; import static lombok.AccessLevel.*; import java.lang.reflect.*; import java.lang.reflect.Type; import java.util.*; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import org.apache.commons.text.StringEscapeUtils; import jtree.util.Either; import lombok.Getter; import lombok.SneakyThrows; public abstract class Node implements INode { @Override public abstract String toCode(); @Override public abstract Node clone(); @SuppressWarnings("unchecked") public static <T> Optional<T> clone(Optional<T> optional) { return (Optional<T>)optional.map(Node::clone); } @SuppressWarnings("unchecked") public static <T> List<T> clone(List<T> list) { return (List<T>)list.stream().map(Node::clone).collect(Collectors.toList()); } @SuppressWarnings("unchecked") public static <F,S> Either<F,S> clone(Either<F,S> either) { return (Either<F,S>)either.map(Node::clone, Node::clone); } private static <T> Object clone(T t) { if(t instanceof Optional) { return clone((Optional<?>)t); } else if(t instanceof List) { return clone((List<?>)t); } else if(t instanceof INode) { return ((INode)t).clone(); } else { return t; } } @SneakyThrows private static Class<?> resolve(Type type) { if(type instanceof Class) { return (Class<?>)type; } else if(type instanceof GenericArrayType) { return Class.forName("[" + resolve(((GenericArrayType)type).getGenericComponentType())); } else if(type instanceof ParameterizedType) { return resolve(((ParameterizedType)type).getRawType()); } else if(type instanceof WildcardType) { return resolve(((WildcardType)type).getUpperBounds()[0]); } else if(type instanceof TypeVariable) { return resolve(((TypeVariable<?>)type).getBounds()[0]); } else { throw new IllegalArgumentException("Don't know how to resolve " + type.getClass().getName() + " " + type.getTypeName()); } } private static Type resolveType(Type type) { if(type instanceof TypeVariable) { return resolveType(((TypeVariable<?>)type).getBounds()[0]); } else if(type instanceof WildcardType) { return resolveType(((WildcardType)type).getUpperBounds()[0]); } else { return type; } } @SuppressWarnings("unchecked") private static Function<?, String> selectToStringFuncFromType(Type type) { if(type == null) { return obj -> obj == null? "null" : ((Function<Object,String>)selectToStringFuncFromType(obj.getClass())).apply(obj); } type = resolveType(type); Class<?> normalType = resolve(type); if(List.class.isAssignableFrom(normalType)) { Type componentType; if(type instanceof ParameterizedType) { componentType = ((ParameterizedType)type).getActualTypeArguments()[0]; } else { componentType = null; } var componentToStringFunc = (Function<Object,String>)selectToStringFuncFromType(componentType); return (List<?> list) -> { var sb = new StringBuilder("["); boolean first = true; for(var elem : list) { if(first) { first = false; } else { sb.append(", "); } sb.append(componentToStringFunc.apply(elem)); } sb.append(']'); return sb.toString(); }; } else if(Set.class.isAssignableFrom(normalType)) { Type componentType; if(type instanceof ParameterizedType) { componentType = ((ParameterizedType)type).getActualTypeArguments()[0]; } else { componentType = null; } var componentToStringFunc = (Function<Object,String>)selectToStringFuncFromType(componentType); return (Set<?> list) -> { var sb = new StringBuilder("{"); boolean first = true; for(var elem : list) { if(first) { first = false; } else { sb.append(", "); } sb.append(componentToStringFunc.apply(elem)); } sb.append('}'); return sb.toString(); }; } else if(normalType.isArray()) { Type componentType; if(type instanceof GenericArrayType) { componentType = ((GenericArrayType)type).getGenericComponentType(); } else { componentType = normalType.getComponentType(); } var componentToStringFunc = (Function<Object,String>)selectToStringFuncFromType(componentType); return (Object array) -> { var sb = new StringBuilder("["); int length = Array.getLength(array); for(int i = 0; i < length; i++) { if(i != 0) { sb.append(", "); } sb.append(componentToStringFunc.apply(Array.get(array, i))); } sb.append(']'); return sb.toString(); }; } else if(Map.class.isAssignableFrom(normalType)) { Type keyType, valueType; if(type instanceof ParameterizedType) { var typeArgs = ((ParameterizedType)type).getActualTypeArguments(); keyType = typeArgs[0]; valueType = typeArgs[1]; } else { keyType = Object.class; valueType = null; } Function<Object,String> keyToStringFunc, valueToStringFunc; if(keyType == String.class) { keyToStringFunc = obj -> { String key = obj.toString(); if(key.matches("[\\w$]+")) { return key; } else { return '"' + StringEscapeUtils.escapeJava(key) + '"'; } }; } else { keyToStringFunc = (Function<Object,String>)selectToStringFuncFromType(keyType); } valueToStringFunc = (Function<Object,String>)selectToStringFuncFromType(valueType); return (Map<Object,Object> map) -> { var sb = new StringBuilder("{"); boolean first = true; for(var entry : map.entrySet()) { if(first) { first = false; } else { sb.append(", "); } sb.append(keyToStringFunc.apply(entry.getKey())).append("=").append(valueToStringFunc.apply(entry.getValue())); } sb.append("}"); return sb.toString(); }; } else if(normalType == Optional.class) { Type componentType; if(type instanceof ParameterizedType) { componentType = ((ParameterizedType)type).getActualTypeArguments()[0]; } else { componentType = null; } var valueToStringFunc = (Function<Object,String>)selectToStringFuncFromType(componentType); return (Optional<?> opt) -> opt.map(value -> "Optional[" + valueToStringFunc.apply(value) + "]").orElse("Optional.empty()"); } else if(INode.class.isAssignableFrom(normalType)) { return Object::toString; } else if(CharSequence.class.isAssignableFrom(normalType)) { return (CharSequence cseq) -> '"' + StringEscapeUtils.escapeJava(cseq.toString()) + '"'; } else if(normalType == char.class || normalType == Character.class) { return (Character ch) -> "'" + (ch == '\''? "\\'" : StringEscapeUtils.escapeJava(ch.toString())) + "'"; } else if(normalType == byte.class || normalType == Byte.class) { return (Byte b) -> "(byte)" + b; } else if(normalType == short.class || normalType == Short.class) { return (Short s) -> "(short)" + s; } else if(normalType == long.class || normalType == Long.class) { return (Long l) -> l + "L"; } else if(normalType == float.class || normalType == Float.class) { return (Float f) -> f + "f"; } else { return Object::toString; } } private class ToStringFieldGetter<T> { private final Method method; @Getter private final String name; private final Function<? super T, String> toStringFunc; @SuppressWarnings("unchecked") protected ToStringFieldGetter(Method method) { this.method = method; String name = method.getName(); if(name.startsWith("get")) { this.name = Character.toLowerCase(name.charAt(3)) + name.substring(4); } else { this.name = name; } this.toStringFunc = (Function<? super T,String>)selectToStringFuncFromType(method.getReturnType()); } @SuppressWarnings("unchecked") @SneakyThrows public T getValue() { try { return (T)method.invoke(Node.this); } catch(InvocationTargetException e) { throw e.getCause(); } } public String getValueString() { return toStringFunc.apply(getValue()); } @Override public int hashCode() { return name.hashCode(); } @Override public boolean equals(Object obj) { return obj instanceof ToStringFieldGetter && ((ToStringFieldGetter<?>)obj).name.equals(name); } @Override public String toString() { return getName() + "=" + getValueString(); } } @Getter(value = PRIVATE, lazy = true) private final Set<ToStringFieldGetter<?>> fieldGetters = getFields(); private Set<ToStringFieldGetter<?>> getFields() { var fields = new HashSet<ToStringFieldGetter<?>>(); findFields(fields, getClass()); return fields; } @SuppressWarnings({ "unchecked" }) private void findFields(HashSet<ToStringFieldGetter<?>> fields, Class<? extends Node> type) { fields.addAll(Arrays.stream(type.getMethods()) .filter(method -> !java.lang.reflect.Modifier.isStatic(method.getModifiers()) && method.getParameterCount() == 0 && method.getReturnType() != void.class && !method.getName().equals("getClass") && method.getName().matches("(get|is|has)[A-Z]\\w*")) .map(ToStringFieldGetter::new) .collect(Collectors.toList())); type = (Class<? extends Node>)type.getSuperclass(); if(type != Node.class) { findFields(fields, type); } } @Override public String toString() { Set<ToStringFieldGetter<?>> getters = getFieldGetters(); return getClass().getSimpleName() + "(" + join(", ", getters, ToStringFieldGetter::toString) + ")"; } protected static Iterable<Integer> reverseRange(int end) { return () -> new PrimitiveIterator.OfInt() { int index = end-1; @Override public boolean hasNext() { return index >= 0; } @Override public int nextInt() { return index--; } }; } protected static Iterable<Integer> range(int end) { return () -> new PrimitiveIterator.OfInt() { int index = 0; @Override public boolean hasNext() { return index < end; } @Override public int nextInt() { return index++; } }; } @SuppressWarnings("unchecked") protected static final <N extends INode, R extends INode> Consumer<R> cast(Consumer<N> consumer) { return (Consumer<R>)consumer; } protected final <N extends INode> void visitList(TreeVisitor visitor, List<N> list) { for(int i : reverseRange(list.size())) { list.get(i).accept(visitor, this, (N node) -> { if(node == null) { list.remove(i); } else { list.set(i, node); } }); } } /*public Stream<Node> stream() { var methods = Arrays.stream(getClass().getMethods()); return methods .filter(method -> { if(isStatic(method.getModifiers())) { return false; } return true; }) .map(method -> { try { return (Node)method.invoke(this); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } }); } @Override public final Iterator<Node> iterator() { return this.stream().iterator(); } @SuppressWarnings({ "unchecked", "resource" }) protected static Stream<Node> stream(@NonNull Object... children) { Stream<Node> stream = Stream.empty(); int start = 0; for(int i = 0; i < children.length; i++) { var child = children[i]; Objects.requireNonNull(child); if(!(child instanceof Node)) { if(child instanceof List) { var list = (List<Node>)child; for(Node child2 : list) { Objects.requireNonNull(child2); } if(i != start) { if(i == start+1) { stream = Stream.concat(stream, Stream.of((Node)children[start])); } else { stream = Stream.concat(stream, (Stream<Node>)(Stream<?>)Arrays.stream(children, start, i)); } } stream = Stream.concat(stream, list.stream()); start = i+1; } else { throw new ClassCastException(child.getClass() + " cannot be cast to " + Node.class + " or " + List.class); } } } if(start != children.length) { if(start+1 == children.length) { stream = Stream.concat(stream, Stream.of((Node)children[start])); } else { stream = Stream.concat(stream, (Stream<Node>)(Stream<?>)Arrays.stream(children, start, children.length)); } } return stream; }*/ }
12,283
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AnnotationDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AnnotationDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class AnnotationDecl extends TypeDecl { public AnnotationDecl(Name name, List<? extends Member> members) { this(name, members, emptyList(), emptyList(), Optional.empty()); } public AnnotationDecl(Name name, Member... members) { this(name, List.of(members)); } public AnnotationDecl(Name name, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(name, emptyList(), members, modifiers, annotations, docComment); } @Override public AnnotationDecl clone() { return new AnnotationDecl(getName(), clone(getMembers()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { return docString() + annotationString() + modifierString() + "@interface " + getName() + " " + bodyString(); } @Override public void setTypeParameters(@NonNull List<TypeParameter> typeParameters) { if(!typeParameters.isEmpty()) { throw new IllegalArgumentException("Annotation declarations cannot have type parameters"); } } @Override public List<TypeParameter> getTypeParameters() { return emptyList(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitAnnotationDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getMembers()); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
1,791
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Literal.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Literal.java
package jtree.nodes; import static lombok.AccessLevel.*; import java.util.Objects; import java.util.function.Consumer; import org.apache.commons.text.StringEscapeUtils; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class Literal extends Node implements Expression { @Setter(NONE) protected Object value; @Getter(NONE) @Setter(NONE) protected @NonNull String stringRep; public Literal(int value, @NonNull String stringRep) { this.value = value; this.stringRep = stringRep; } public Literal(long value, @NonNull String stringRep) { this.value = value; this.stringRep = stringRep; } public Literal(float value, @NonNull String stringRep) { this.value = value; this.stringRep = stringRep; } public Literal(double value, @NonNull String stringRep) { this.value = value; this.stringRep = stringRep; } public Literal(char value, @NonNull String stringRep) { this.value = value; this.stringRep = stringRep; } public Literal(@NonNull String value, @NonNull String stringRep) { this.value = value; this.stringRep = stringRep; } public Literal(int value) { setValue(value); } public Literal(long value) { setValue(value); } public Literal(float value) { setValue(value); } public Literal(double value) { setValue(value); } public Literal(boolean value) { setValue(value); } public Literal(char value) { setValue(value); } public Literal() { setValue((Void)null); } public Literal(String value) { setValue(value); } protected Literal(Object value, String stringRep) { this.value = value; this.stringRep = stringRep; } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public Literal clone() { return new Literal(value, stringRep); } public void setValue(int value) { this.value = value; this.stringRep = Objects.toString(value); } public void setValue(long value) { this.value = value; this.stringRep = value + "L"; } public void setValue(float value) { this.value = value; this.stringRep = value + "f"; } public void setValue(double value) { this.value = value; this.stringRep = Objects.toString(value); } public void setValue(boolean value) { this.value = value; this.stringRep = Objects.toString(value); } public void setValue(char value) { this.value = value; String valueStr = Objects.toString(value); if(valueStr.equals("'")) { this.stringRep = "'\\''"; } else { this.stringRep = "'" + StringEscapeUtils.escapeJava(valueStr) + "'"; } } public void setValue(@NonNull String value) { this.value = value; this.stringRep = '"' + StringEscapeUtils.escapeJava(value) + '"'; } public void setValue(Void value) { this.value = value; this.stringRep = "null"; } @Override public String toCode() { return stringRep; } @Override public String toString() { return "Literal(" + toCode() + ")"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { visitor.visitLiteral(this, parent, cast(replacer)); } }
3,190
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AssertStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AssertStmt.java
package jtree.nodes; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class AssertStmt extends Node implements Statement { protected @NonNull Expression condition; protected @NonNull Optional<? extends Expression> message; public AssertStmt(Expression condition) { this(condition, Optional.empty()); } public AssertStmt(Expression condition, Expression message) { this(condition, Optional.ofNullable(message)); } public AssertStmt(Expression condition, Optional<? extends Expression> message) { setCondition(condition); setMessage(message); } @Override public AssertStmt clone() { return new AssertStmt(getCondition().clone(), clone(getMessage())); } @Override public String toCode() { return "assert " + getCondition().toCode() + getMessage().map(message -> " : " + message.toCode()).orElse("") + ";"; } public void setMessage(@NonNull Optional<? extends Expression> message) { this.message = message; } public final void setMessage(Expression message) { setMessage(Optional.ofNullable(message)); } public final void setMessage() { setMessage(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitAssertStmt(this, parent, cast(replacer))) { getCondition().accept(visitor, this, this::setCondition); getMessage().ifPresent(message -> message.<Expression>accept(visitor, this, this::setMessage)); } } }
1,619
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
IndexExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/IndexExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class IndexExpr extends Node implements Expression { protected @NonNull Expression index, indexed; public IndexExpr(Expression indexed, Expression index) { setIndexed(indexed); setIndex(index); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public IndexExpr clone() { return new IndexExpr(getIndexed(), getIndex()); } @Override public String toCode() { return wrap(getIndexed()).toCode() + "[" + getIndex().toCode() + "]"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitIndexExpr(this, parent, cast(replacer))) { getIndexed().accept(visitor, this, this::setIndexed); getIndex().accept(visitor, this, this::setIndex); } } }
984
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Directive.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Directive.java
package jtree.nodes; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public abstract class Directive extends Node { protected @NonNull QualifiedName name; public Directive(QualifiedName name) { setName(name); } @Override public abstract Directive clone(); }
360
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ConstructorDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ConstructorDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ConstructorDecl extends GenericDecl implements REPLEntry { protected @NonNull Optional<ThisParameter> thisParameter; protected @NonNull List<FormalParameter> parameters; private @NonNull List<GenericType> exceptions; private @NonNull Block body; public ConstructorDecl(Name name, List<FormalParameter> parameters, Block body) { this(name, parameters, emptyList(), body); } public ConstructorDecl(Name name, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, emptyList(), parameters, exceptions, body, emptyList(), emptyList()); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, typeParameters, parameters, exceptions, body, emptyList(), emptyList()); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, List<FormalParameter> parameters, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations) { this(name, typeParameters, Optional.empty(), parameters, exceptions, body); } public ConstructorDecl(Name name, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, Block body) { this(name, thisParameter, parameters, emptyList(), body); } public ConstructorDecl(Name name, ThisParameter thisParameter, List<FormalParameter> parameters, Block body) { this(name, Optional.ofNullable(thisParameter), parameters, body); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, Block body) { this(name, typeParameters, thisParameter, parameters, emptyList(), body); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, ThisParameter thisParameter, List<FormalParameter> parameters, Block body) { this(name, typeParameters, Optional.ofNullable(thisParameter), parameters, body); } public ConstructorDecl(Name name, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, emptyList(), thisParameter, parameters, exceptions, body, emptyList(), emptyList(), Optional.empty()); } public ConstructorDecl(Name name, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, Optional.ofNullable(thisParameter), parameters, exceptions, body); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, typeParameters, thisParameter, parameters, exceptions, body, emptyList(), emptyList(), Optional.empty()); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body) { this(name, typeParameters, Optional.ofNullable(thisParameter), parameters, exceptions, body); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, ThisParameter thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, Optional.ofNullable(thisParameter), parameters, exceptions, body, modifiers, annotations, docComment); } public ConstructorDecl(Name name, List<TypeParameter> typeParameters, Optional<ThisParameter> thisParameter, List<FormalParameter> parameters, List<GenericType> exceptions, Block body, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(name, typeParameters, modifiers, annotations, docComment); setExceptions(exceptions); setParameters(parameters); setBody(body); setThisParameter(thisParameter); } @Override public ConstructorDecl clone() { return new ConstructorDecl(getName(), clone(getTypeParameters()), clone(getThisParameter()), clone(getParameters()), clone(getExceptions()), getBody().clone(), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { var exceptions = getExceptions(); var parameters = getParameters(); return docString() + annotationString() + modifierString() + getName() + "(" + (parameters.isEmpty() ? getThisParameter().map(ThisParameter::toCode) .orElse("") : getThisParameter().map(thisParameter -> thisParameter.toCode() + ", ") .orElse("") + joinNodes(", ", parameters)) + ")" + (exceptions.isEmpty()? "" : " throws " + joinNodes(", ", exceptions)) + " " + getBody().toCode(); } public void setExceptions(@NonNull List<GenericType> exceptions) { this.exceptions = newList(exceptions); } public final void setExceptions(GenericType... exceptions) { setExceptions(List.of(exceptions)); } public void setParameters(@NonNull List<FormalParameter> parameters) { this.parameters = newList(parameters); } public final void setParameters(FormalParameter... parameters) { setParameters(List.of(parameters)); } public void setThisParameter(@NonNull Optional<ThisParameter> thisParameter) { this.thisParameter = thisParameter; } public final void setThisParameter(ThisParameter thisParameter) { setThisParameter(Optional.ofNullable(thisParameter)); } public final void setThisParameter() { setThisParameter(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitConstructorDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getTypeParameters()); getThisParameter().ifPresent(thisParameter -> thisParameter.<ThisParameter>accept(visitor, this, this::setThisParameter)); visitList(visitor, getParameters()); visitList(visitor, getExceptions()); getBody().accept(visitor, this, this::setBody); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
6,438
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TreeVisitor.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TreeVisitor.java
package jtree.nodes; import java.util.function.Consumer; public interface TreeVisitor { default boolean visitNode(Node node, Node parent, Consumer<Node> replacer) { throw new IllegalArgumentException("Unsupported Node type: " + node.getClass().getSimpleName()); } boolean visitAnnotation(Annotation node, Node parent, Consumer<Annotation> replacer); boolean visitAnnotationArgument(AnnotationArgument node, Node parent, Consumer<AnnotationArgument> replacer); boolean visitAnnotationDecl(AnnotationDecl node, Node parent, Consumer<AnnotationDecl> replacer); boolean visitAnnotationProperty(AnnotationProperty node, Node parent, Consumer<AnnotationProperty> replacer); boolean visitArrayCreator(ArrayCreator node, Node parent, Consumer<ArrayCreator> replacer); <T extends AnnotationValue> boolean visitArrayInitializer(ArrayInitializer<T> node, Node parent, Consumer<ArrayInitializer<T>> replacer); boolean visitArrayType(ArrayType node, Node parent, Consumer<ArrayType> replacer); boolean visitAssertStmt(AssertStmt node, Node parent, Consumer<AssertStmt> replacer); boolean visitAssignExpr(AssignExpr node, Node parent, Consumer<AssignExpr> replacer); boolean visitBinaryExpr(BinaryExpr node, Node parent, Consumer<BinaryExpr> replacer); boolean visitBlock(Block node, Node parent, Consumer<Block> replacer); boolean visitBreakStmt(BreakStmt node, Node parent, Consumer<BreakStmt> replacer); boolean visitCastExpr(CastExpr node, Node parent, Consumer<CastExpr> replacer); boolean visitCatch(Catch node, Node parent, Consumer<Catch> replacer); boolean visitClassCreator(ClassCreator node, Node parent, Consumer<ClassCreator> replacer); boolean visitClassDecl(ClassDecl node, Node parent, Consumer<ClassDecl> replacer); boolean visitClassInitializer(ClassInitializer node, Node parent, Consumer<ClassInitializer> replacer); boolean visitClassLiteral(ClassLiteral node, Node parent, Consumer<ClassLiteral> replacer); boolean visitConditionalExpr(ConditionalExpr node, Node parent, Consumer<ConditionalExpr> replacer); boolean visitConstructorCall(ConstructorCall node, Node parent, Consumer<ConstructorCall> replacer); boolean visitConstructorDecl(ConstructorDecl node, Node parent, Consumer<ConstructorDecl> replacer); boolean visitContinueStmt(ContinueStmt node, Node parent, Consumer<ContinueStmt> replacer); boolean visitDimension(Dimension node, Node parent, Consumer<Dimension> replacer); boolean visitDoStmt(DoStmt node, Node parent, Consumer<DoStmt> replacer); boolean visitEmptyStmt(EmptyStmt node, Node parent, Consumer<EmptyStmt> replacer); boolean visitEnumDecl(EnumDecl node, Node parent, Consumer<EnumDecl> replacer); boolean visitEnumField(EnumField node, Node parent, Consumer<EnumField> replacer); boolean visitExportsDirective(ExportsDirective node, Node parent, Consumer<ExportsDirective> replacer); boolean visitExpressionStmt(ExpressionStmt node, Node parent, Consumer<ExpressionStmt> replacer); boolean visitForEachStmt(ForEachStmt node, Node parent, Consumer<ForEachStmt> replacer); boolean visitForStmt(ForStmt node, Node parent, Consumer<ForStmt> replacer); boolean visitFormalParameter(FormalParameter node, Node parent, Consumer<FormalParameter> replacer); boolean visitFunctionCall(FunctionCall node, Node parent, Consumer<FunctionCall> replacer); boolean visitFunctionDecl(FunctionDecl node, Node parent, Consumer<FunctionDecl> replacer); boolean visitGenericType(GenericType node, Node parent, Consumer<GenericType> replacer); boolean visitIfStmt(IfStmt node, Node parent, Consumer<IfStmt> replacer); boolean visitImportDecl(ImportDecl node, Node parent, Consumer<ImportDecl> replacer); boolean visitIndexExpr(IndexExpr node, Node parent, Consumer<IndexExpr> replacer); boolean visitInformalParameter(InformalParameter node, Node parent, Consumer<InformalParameter> replacer); boolean visitInterfaceDecl(InterfaceDecl node, Node parent, Consumer<InterfaceDecl> replacer); boolean visitLabeledStmt(LabeledStmt node, Node parent, Consumer<LabeledStmt> replacer); boolean visitLambda(Lambda node, Node parent, Consumer<Lambda> replacer); boolean visitLiteral(Literal node, Node parent, Consumer<Literal> replacer); boolean visitMemberAccess(MemberAccess node, Node parent, Consumer<MemberAccess> replacer); boolean visitMethodReference(MethodReference node, Node parent, Consumer<MethodReference> replacer); boolean visitModifier(Modifier node, Node parent, Consumer<Modifier> replacer); boolean visitModuleCompilationUnit(ModuleCompilationUnit node, Node parent, Consumer<ModuleCompilationUnit> replacer); boolean visitName(Name node, Node parent, Consumer<Name> replacer); boolean visitNormalCompilationUnit(NormalCompilationUnit node, Node parent, Consumer<NormalCompilationUnit> replacer); boolean visitOpensDirective(OpensDirective node, Node parent, Consumer<OpensDirective> replacer); boolean visitPackageDecl(PackageDecl node, Node parent, Consumer<PackageDecl> replacer); boolean visitParensExpr(ParensExpr node, Node parent, Consumer<ParensExpr> replacer); boolean visitPostIncrementExpr(PostIncrementExpr node, Node parent, Consumer<PostIncrementExpr> replacer); boolean visitPostDecrementExpr(PostDecrementExpr node, Node parent, Consumer<PostDecrementExpr> replacer); boolean visitPreIncrementExpr(PreIncrementExpr node, Node parent, Consumer<PreIncrementExpr> replacer); boolean visitPreDecrementExpr(PreDecrementExpr node, Node parent, Consumer<PreDecrementExpr> replacer); boolean visitPrimitiveType(PrimitiveType node, Node parent, Consumer<PrimitiveType> replacer); boolean visitProvidesDirective(ProvidesDirective node, Node parent, Consumer<ProvidesDirective> replacer); boolean visitQualifiedName(QualifiedName node, Node parent, Consumer<QualifiedName> replacer); boolean visitRequiresDirective(RequiresDirective node, Node parent, Consumer<RequiresDirective> replacer); boolean visitReturnStmt(ReturnStmt node, Node parent, Consumer<ReturnStmt> replacer); boolean visitSize(Size node, Node parent, Consumer<Size> replacer); boolean visitSuperFunctionCall(SuperFunctionCall node, Node parent, Consumer<SuperFunctionCall> replacer); boolean visitSuperMethodReference(SuperMethodReference node, Node parent, Consumer<SuperMethodReference> replacer); boolean visitSwitch(Switch node, Node parent, Consumer<Switch> replacer); boolean visitSwitchCase(SwitchCase node, Node parent, Consumer<SwitchCase> replacer); boolean visitSynchronizedStmt(SynchronizedStmt node, Node parent, Consumer<SynchronizedStmt> replacer); boolean visitThis(This node, Node parent, Consumer<This> replacer); boolean visitThisParameter(ThisParameter node, Node parent, Consumer<ThisParameter> replacer); boolean visitThrowStmt(ThrowStmt node, Node parent, Consumer<ThrowStmt> replacer); boolean visitTryStmt(TryStmt node, Node parent, Consumer<TryStmt> replacer); boolean visitTypeUnion(TypeUnion node, Node parent, Consumer<TypeUnion> replacer); boolean visitTypeIntersection(TypeIntersection node, Node parent, Consumer<TypeIntersection> replacer); boolean visitTypeParameter(TypeParameter node, Node parent, Consumer<TypeParameter> replacer); boolean visitTypeTest(TypeTest node, Node parent, Consumer<TypeTest> replacer); boolean visitUnaryExpr(UnaryExpr node, Node parent, Consumer<UnaryExpr> replacer); boolean visitUsesDirective(UsesDirective node, Node parent, Consumer<UsesDirective> replacer); boolean visitVariable(Variable node, Node parent, Consumer<Variable> replacer); boolean visitVariableDecl(VariableDecl node, Node parent, Consumer<VariableDecl> replacer); boolean visitVariableDeclarator(VariableDeclarator node, Node parent, Consumer<VariableDeclarator> replacer); boolean visitVoidType(VoidType node, Node parent, Consumer<VoidType> replacer); boolean visitWhileStmt(WhileStmt node, Node parent, Consumer<WhileStmt> replacer); boolean visitWildcardTypeArgument(WildcardTypeArgument node, Node parent, Consumer<WildcardTypeArgument> replacer); boolean visitWildcardTypeArgumentBound(WildcardTypeArgument.Bound node, Node parent, Consumer<WildcardTypeArgument.Bound> replacer); boolean visitYieldStmt(YieldStmt node, Node parent, Consumer<YieldStmt> replacer); }
8,279
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Name.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Name.java
package jtree.nodes; import java.util.Arrays; import java.util.function.Consumer; import java.util.stream.Stream; import lombok.NonNull; public final class Name extends Node implements CharSequence { public static boolean isValidName(String str) { if(str.isEmpty()) { return false; } if(!Character.isJavaIdentifierStart(str.codePoints().findFirst().orElseThrow())) { return false; } return str.codePoints().allMatch(Character::isJavaIdentifierPart); } private final String stringValue; /** * @param string the name * @throws IllegalArgumentException If the argument is not a valid name. */ public Name(@NonNull String string) { if(!isValidName(string)) { throw new IllegalArgumentException("Not a valid name: '" + string + "'"); } this.stringValue = string; } @Override public Name clone() { return this; } public QualifiedName toQualifiedName() { return new QualifiedName(this); } public QualifiedName append(Name other) { return new QualifiedName(this, other); } public QualifiedName append(Name... names) { Name[] newnames = new Name[names.length+1]; System.arraycopy(names, 0, newnames, 1, names.length); newnames[0] = this; return new QualifiedName(newnames); } public QualifiedName append(QualifiedName other) { return Stream.concat(Stream.of(this), other.stream()).collect(QualifiedName.collector()); } public QualifiedName append(QualifiedName... names) { return Stream.concat(Stream.of(this), Arrays.stream(names)).collect(QualifiedName.collector()); } public QualifiedName append(CharSequence... names) { return Stream.concat(Stream.of(this), Arrays.stream(names)).collect(QualifiedName.collector()); } @Override public String toString() { return stringValue; } @Override public String toCode() { return stringValue; } @Override public int hashCode() { return stringValue.hashCode(); } @Override public boolean equals(Object obj) { return obj == this || obj instanceof CharSequence && stringValue.contentEquals((CharSequence)obj); } public boolean equals(CharSequence cseq) { return stringValue.contentEquals(cseq); } @Override public int length() { return stringValue.length(); } @Override public char charAt(int index) { return stringValue.charAt(index); } @Override public CharSequence subSequence(int start, int end) { return stringValue.subSequence(start, end); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { visitor.visitName(this, parent, cast(replacer)); } }
2,586
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Catch.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Catch.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class Catch extends Node { protected @NonNull FormalParameter parameter; protected @NonNull Block body; public Catch(FormalParameter parameter, Block body) { setParameter(parameter); setBody(body); } @Override public Catch clone() { return new Catch(getParameter().clone(), getBody().clone()); } @Override public String toCode() { return "catch(" + getParameter().toCode() + ") " + body.toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitCatch(this, parent, cast(replacer))) { getParameter().accept(visitor, this, this::setParameter); getBody().accept(visitor, this, this::setBody); } } }
914
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
InterfaceDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/InterfaceDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class InterfaceDecl extends TypeDecl { protected @NonNull List<GenericType> superInterfaces; public InterfaceDecl(Name name, List<? extends Member> members) { this(name, emptyList(), members); } public InterfaceDecl(Name name, Member... members) { this(name, List.of(members)); } public InterfaceDecl(Name name, List<GenericType> superInterfaces, List<? extends Member> members) { this(name, emptyList(), superInterfaces, members, emptyList(), emptyList(), Optional.empty()); } public InterfaceDecl(Name name, List<GenericType> superInterfaces, Member... members) { this(name, superInterfaces, List.of(members)); } public InterfaceDecl(Name name, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, emptyList(), members, modifiers, annotations, docComment); } public InterfaceDecl(Name name, List<TypeParameter> typeParameters, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, typeParameters, emptyList(), members, modifiers, annotations, docComment); } public InterfaceDecl(Name name, List<TypeParameter> typeParameters, List<GenericType> superInterfaces, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(name, typeParameters, members, modifiers, annotations, docComment); setSuperInterfaces(superInterfaces); } @Override public InterfaceDecl clone() { return new InterfaceDecl(getName(), clone(getTypeParameters()), clone(getSuperInterfaces()), clone(getMembers()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { var superInterfaces = getSuperInterfaces(); return docString() + annotationString() + modifierString() + "interface " + getName() + typeParameterString() + (superInterfaces.isEmpty()? "" : " extends " + joinNodes(", ", superInterfaces)) + " " + bodyString(); } public void setSuperInterfaces(@NonNull List<GenericType> superInterfaces) { this.superInterfaces = newList(superInterfaces); } public final void setSuperInterfaces(GenericType... superInterfaces) { setSuperInterfaces(List.of(superInterfaces)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitInterfaceDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getTypeParameters()); visitList(visitor, getSuperInterfaces()); visitList(visitor, getMembers()); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
3,029
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ExportsDirective.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ExportsDirective.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ExportsDirective extends Directive { protected @NonNull List<QualifiedName> friendModules; public ExportsDirective(QualifiedName packageName) { this(packageName, emptyList()); } public ExportsDirective(QualifiedName packageName, QualifiedName... friendModules) { this(packageName, List.of(friendModules)); } public ExportsDirective(QualifiedName packageName, List<QualifiedName> friendModules) { super(packageName); setFriendModules(friendModules); } @Override public ExportsDirective clone() { return new ExportsDirective(getName(), clone(getFriendModules())); } @Override public String toCode() { var friendModules = getFriendModules(); return "exports " + getName() + (friendModules.isEmpty()? ";" : " to " + joinNodes(", ", friendModules) + ";"); } public void setFriendModules(@NonNull List<QualifiedName> friendModules) { this.friendModules = newList(friendModules); } public final void setFriendModules(QualifiedName... friendModules) { setFriendModules(List.of(friendModules)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitExportsDirective(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getFriendModules()); } } }
1,584
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
VariableDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/VariableDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class VariableDecl extends Declaration implements ResourceSpecifier, Member { protected @NonNull Type type; protected @NonNull List<VariableDeclarator> declarators; public VariableDecl(Type type, Name name) { this(type, new VariableDeclarator(name)); } public VariableDecl(Type type, Name name, Optional<? extends Initializer> initializer) { this(type, new VariableDeclarator(name, initializer)); } public VariableDecl(Type type, Name name, Initializer initializer) { this(type, name, Optional.ofNullable(initializer)); } public VariableDecl(Type type, Name name, List<Dimension> dimensions) { this(type, new VariableDeclarator(name, dimensions)); } public VariableDecl(Type type, Name name, Dimension... dimensions) { this(type, name, List.of(dimensions)); } public VariableDecl(Type type, Name name, List<Dimension> dimensions, Optional<? extends Initializer> initializer) { this(type, name, dimensions, initializer, emptyList(), emptyList(), Optional.empty()); } public VariableDecl(Type type, Name name, List<Dimension> dimensions, Initializer initializer, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(type, name, dimensions, Optional.ofNullable(initializer), modifiers, annotations, docComment); } public VariableDecl(Type type, Name name, List<Dimension> dimensions, Initializer initializer, List<Modifier> modifiers, List<Annotation> annotations) { this(type, name, dimensions, Optional.ofNullable(initializer), modifiers, annotations, Optional.empty()); } public VariableDecl(Type type, Name name, List<Dimension> dimensions, Optional<? extends Initializer> initializer, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(type, List.of(new VariableDeclarator(name, dimensions, initializer)), modifiers, annotations, docComment); } public VariableDecl(Type type, Name name, List<Dimension> dimensions, Initializer initializer) { this(type, name, dimensions, Optional.ofNullable(initializer)); } public VariableDecl(Type type, VariableDeclarator... declarators) { this(type, List.of(declarators)); } public VariableDecl(Type type, List<VariableDeclarator> declarators) { this(type, declarators, emptyList(), emptyList(), Optional.empty()); } public VariableDecl(Type type, VariableDeclarator declarator, List<Modifier> modifiers, List<Annotation> annotations) { this(type, List.of(declarator), modifiers, annotations, Optional.empty()); } public VariableDecl(Type type, VariableDeclarator declarator, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(type, List.of(declarator), modifiers, annotations, docComment); } public VariableDecl(Type type, List<VariableDeclarator> declarators, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(modifiers, annotations, docComment); setType(type); setDeclarators(declarators); } @Override public VariableDecl clone() { return new VariableDecl(getType().clone(), clone(getDeclarators()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } public String toCode(boolean newlines) { return (newlines? docString() : "") + annotationString(newlines) + modifierString() + getType().toCode() + " " + joinNodes(", ", getDeclarators()) + ";"; } @Override public String toCode() { return toCode(true); } public void setDeclarators(@NonNull List<VariableDeclarator> declarators) { if(declarators.isEmpty()) { throw new IllegalArgumentException("No declarators given"); } this.declarators = newList(declarators); } public final void setDeclarators(VariableDeclarator... declarators) { setDeclarators(List.of(declarators)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitVariableDecl(this, parent, cast(replacer))) { getType().accept(visitor, this, this::setType); visitList(visitor, getDeclarators()); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
4,424
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
IfStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/IfStmt.java
package jtree.nodes; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class IfStmt extends Node implements CompoundStmt { protected @NonNull Expression condition; protected @NonNull Statement body; private @NonNull Optional<? extends Statement> elseBody; public IfStmt(Expression condition, Statement body) { this(condition, body, Optional.empty()); } public IfStmt(Expression condition, Statement body, Statement elseBody) { this(condition, body, Optional.ofNullable(elseBody)); } public IfStmt(Expression condition, Statement body, Optional<? extends Statement> elseBody) { setCondition(condition); setBody(body); setElseBody(elseBody); } @Override public IfStmt clone() { return new IfStmt(getCondition().clone(), getBody().clone(), clone(getElseBody())); } @Override public String toCode() { return "if(" + condition.toCode() + ")" + bodyString(body) + elseBody.map(body -> (getBody() instanceof Block? " else" : "\nelse") + (body instanceof IfStmt? " " + body.toCode() : bodyString(body))) .orElse(""); } public void setElseBody(@NonNull Optional<? extends Statement> elseBody) { this.elseBody = elseBody; } public final void setElseBody(Statement elseBody) { setElseBody(Optional.ofNullable(elseBody)); } public final void setElseBody() { setElseBody(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitIfStmt(this, parent, cast(replacer))) { getCondition().accept(visitor, this, this::setCondition); getBody().accept(visitor, this, this::setBody); getElseBody().ifPresent(body -> body.<Statement>accept(visitor, this, this::setElseBody)); } } }
1,909
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
CompilationUnit.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/CompilationUnit.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public abstract class CompilationUnit extends Node implements REPLEntry { protected @NonNull List<ImportDecl> imports; public CompilationUnit(List<ImportDecl> imports) { setImports(imports); } @Override public abstract CompilationUnit clone(); public String importString() { var imports = getImports(); return imports.isEmpty()? "" : joinNodes("\n", imports) + "\n\n"; } public void setImports(@NonNull List<ImportDecl> imports) { this.imports = newList(imports); } public final void setImports(ImportDecl... imports) { setImports(List.of(imports)); } }
804
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TypeArgument.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/TypeArgument.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public abstract class TypeArgument extends Node implements Annotated { protected @NonNull List<Annotation> annotations; protected TypeArgument(List<Annotation> annotations) { setAnnotations(annotations); } @Override public abstract TypeArgument clone(); @Override public void setAnnotations(@NonNull List<Annotation> annotations) { this.annotations = newList(annotations); } @Override public final void setAnnotations(Annotation... annotations) { setAnnotations(List.of(annotations)); } }
733
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
SynchronizedStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/SynchronizedStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class SynchronizedStmt extends Node implements CompoundStmt { protected @NonNull Expression lock; protected @NonNull Block body; public SynchronizedStmt(Expression lock, Block body) { setLock(lock); setBody(body); } @Override public SynchronizedStmt clone() { return new SynchronizedStmt(getLock().clone(), getBody().clone()); } @Override public String toCode() { return "synchronized(" + getLock().toCode() + ") " + getBody().toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitSynchronizedStmt(this, parent, cast(replacer))) { getLock().accept(visitor, this, this::setLock); getBody().accept(visitor, this, this::setBody); } } }
954
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Type.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Type.java
package jtree.nodes; import java.util.List; public abstract class Type extends TypeArgument { protected Type(List<Annotation> annotations) { super(annotations); } @Override public abstract Type clone(); }
217
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
SuperMethodReference.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/SuperMethodReference.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class SuperMethodReference extends Node implements Expression, TypeArgumentHolder { protected @NonNull Optional<QualifiedName> qualifier; protected @NonNull List<? extends TypeArgument> typeArguments; private @NonNull Name name; public SuperMethodReference(Name name) { this(Optional.empty(), name); } public SuperMethodReference(List<? extends TypeArgument> typeArguments, Name name) { this(Optional.empty(), typeArguments, name); } public SuperMethodReference(QualifiedName qualifier, Name name) { this(Optional.ofNullable(qualifier), name); } public SuperMethodReference(QualifiedName qualifier, List<? extends TypeArgument> typeArguments, Name name) { this(Optional.ofNullable(qualifier), typeArguments, name); } public SuperMethodReference(Optional<QualifiedName> qualifier, Name name) { this(qualifier, emptyList(), name); } public SuperMethodReference(Optional<QualifiedName> qualifier, List<? extends TypeArgument> typeArguments, Name name) { setQualifier(qualifier); setName(name); setTypeArguments(typeArguments); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public SuperMethodReference clone() { return new SuperMethodReference(clone(getQualifier()), clone(getTypeArguments()), getName()); } @Override public String toCode() { return getQualifier().map(qualifier -> qualifier.toCode() + ".").orElse("") + "super::" + typeArgumentString() + getName(); } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } public void setQualifier(@NonNull Optional<QualifiedName> qualifier) { this.qualifier = qualifier; } public final void setQualifier(QualifiedName qualifier) { setQualifier(Optional.ofNullable(qualifier)); } public final void setQualifier() { setQualifier(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitSuperMethodReference(this, parent, cast(replacer))) { getQualifier().ifPresent(qualifier -> qualifier.<QualifiedName>accept(visitor, this, this::setQualifier)); getName().accept(visitor, this, this::setName); visitList(visitor, getTypeArguments()); } } }
2,724
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
PreIncrementExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/PreIncrementExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class PreIncrementExpr extends Node implements ChangeExpr { protected @NonNull Expression expression; public PreIncrementExpr(Expression expression) { setExpression(expression); } @Override public Precedence precedence() { return Precedence.UNARY_AND_CAST; } @Override public PreIncrementExpr clone() { return new PreIncrementExpr(wrap(getExpression()).clone()); } @Override public String toCode() { return "++" + getExpression().toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitPreIncrementExpr(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); } } }
922
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
AnnotationArgument.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/AnnotationArgument.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class AnnotationArgument extends Node { protected Name name; protected AnnotationValue value; public AnnotationArgument(Name name, AnnotationValue value) { setName(name); setValue(value); } @Override public AnnotationArgument clone() { return new AnnotationArgument(getName(), getValue().clone()); } @Override public String toCode() { return getName() + " = " + getValue().toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitAnnotationArgument(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); getValue().accept(visitor, this, this::setValue); } } }
881
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
MethodReference.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/MethodReference.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Objects; import java.util.function.Consumer; import jtree.util.Either; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class MethodReference extends Node implements Expression, TypeArgumentHolder { protected @NonNull Either<? extends Expression, ? extends Type> object; protected @NonNull Name name; private @NonNull List<? extends TypeArgument> typeArguments; public MethodReference(Expression object, List<? extends TypeArgument> typeArguments, Name name) { this(Either.first(object), typeArguments, name); } public MethodReference(Type object, List<? extends TypeArgument> typeArguments, Name name) { this(Either.second(object), typeArguments, name); } public MethodReference(Either<? extends Expression, ? extends Type> object, List<? extends TypeArgument> typeArguments, Name name) { setObject(object); setName(name); setTypeArguments(typeArguments); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public MethodReference clone() { return new MethodReference(clone(getObject()), clone(getTypeArguments()), getName()); } @Override public String toCode() { return getObject().unravel(expr -> wrap(expr).toCode(), Type::toCode) + "::" + typeArgumentString() + getName(); } public void setObject(@NonNull Either<? extends Expression, ? extends Type> object) { Objects.requireNonNull(object.getValue()); this.object = object; } public final void setObject(Expression object) { setObject(Either.first(object)); } public final void setObject(Type object) { setObject(Either.second(object)); } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitMethodReference(this, parent, cast(replacer))) { getObject().accept(expr -> expr.<Expression>accept(visitor, this, this::setObject), type -> type.<Type>accept(visitor, this, this::setObject)); getName().accept(visitor, this, this::setName); visitList(visitor, getTypeArguments()); } } }
2,494
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
PrimitiveType.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/PrimitiveType.java
package jtree.nodes; import static java.util.Collections.*; import java.util.List; import java.util.Set; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class PrimitiveType extends Type { public static final Name BOOLEAN = new Name("boolean"), BYTE = new Name("byte"), SHORT = new Name("short"), CHAR = new Name("char"), INT = new Name("int"), LONG = new Name("long"), FLOAT = new Name("float"), DOUBLE = new Name("double"); public static final Set<Name> VALUES = Set.of(BOOLEAN, BYTE, SHORT, CHAR, INT, LONG, FLOAT, DOUBLE); protected @NonNull Name name; public PrimitiveType(String name) { this(new Name(name)); } public PrimitiveType(Name name) { this(name, emptyList()); } public PrimitiveType(String name, List<Annotation> annotations) { this(new Name(name), annotations); } public PrimitiveType(Name name, List<Annotation> annotations) { super(annotations); setName(name); } @Override public PrimitiveType clone() { return new PrimitiveType(getName(), clone(getAnnotations())); } @Override public String toCode() { return annotationString(false) + getName(); } public void setName(@NonNull Name name) { if(!VALUES.contains(name)) { throw new IllegalArgumentException("'" + name + "' is not a primitive type"); } this.name = name; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitPrimitiveType(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); } } }
1,722
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ReferenceType.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ReferenceType.java
package jtree.nodes; import java.util.List; public abstract class ReferenceType extends Type { protected ReferenceType(List<Annotation> annotations) { super(annotations); } @Override public abstract ReferenceType clone(); }
237
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ThisParameter.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ThisParameter.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ThisParameter extends Declaration { protected @NonNull Type type; protected @NonNull Optional<Name> qualifier; public ThisParameter(Type type) { this(type, emptyList()); } public ThisParameter(Type type, List<Annotation> annotations) { this(type, Optional.empty(), annotations); } public ThisParameter(Type type, Optional<Name> qualifier) { this(type, qualifier, emptyList()); } public ThisParameter(Type type, Name qualifier) { this(type, Optional.ofNullable(qualifier)); } public ThisParameter(Type type, Optional<Name> qualifier, List<Annotation> annotations) { super(emptyList(), annotations, Optional.empty()); setType(type); setQualifier(qualifier); } @Override public ThisParameter clone() { return new ThisParameter(getType().clone(), clone(getQualifier()), clone(getAnnotations())); } @Override public String toCode() { return annotationString(false) + getType().toCode() + " " + getQualifier().map(qualifier -> qualifier.toCode() + ".").orElse("") + "this"; } @Override public List<Modifier> getModifiers() { return emptyList(); } public void setQualifier(@NonNull Optional<Name> qualifier) { this.qualifier = qualifier; } public final void setQualifier(Name qualifier) { setQualifier(Optional.ofNullable(qualifier)); } public final void setQualifier() { setQualifier(Optional.empty()); } @Override public void setDocComment(@NonNull Optional<String> docComment) { if(!docComment.isEmpty()) { throw new IllegalArgumentException("Formal parameters cannot have doc comments"); } } @Override public Optional<String> getDocComment() { return Optional.empty(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitThisParameter(this, parent, cast(replacer))) { getType().accept(visitor, this, this::setType); getQualifier().ifPresent(qualifier -> qualifier.<Name>accept(visitor, this, this::setQualifier)); visitList(visitor, getAnnotations()); } } }
2,332
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Switch.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Switch.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class Switch extends Node implements Expression, CompoundStmt { protected @NonNull Expression expression; protected @NonNull List<SwitchCase> cases; public Switch(Expression expression, SwitchCase... cases) { this(expression, List.of(cases)); } public Switch(Expression expression, List<SwitchCase> cases) { setExpression(expression); setCases(cases); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public Switch clone() { return new Switch(getExpression().clone(), clone(getCases())); } @Override public String toCode() { return "switch(" + expression.toCode() + ") {\n" + join("", getCases(), aCase -> aCase.toCode().indent(4)) + "}"; } public void setCases(@NonNull List<SwitchCase> cases) { this.cases = newList(cases); } public final void setCases(SwitchCase... cases) { setCases(List.of(cases)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitSwitch(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); visitList(visitor, getCases()); } } }
1,425
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ForEachStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ForEachStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ForEachStmt extends Node implements CompoundStmt { protected @NonNull FormalParameter variable; protected @NonNull Expression iterable; private @NonNull Statement body; public ForEachStmt(FormalParameter variable, Expression iterable, Statement body) { setVariable(variable); setIterable(iterable); setBody(body); } @Override public ForEachStmt clone() { return new ForEachStmt(getVariable().clone(), getIterable().clone(), getBody().clone()); } @Override public String toCode() { return "for(" + getVariable().toCode() + " : " + getIterable().toCode() + ")" + bodyString(getBody()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitForEachStmt(this, parent, cast(replacer))) { getVariable().accept(visitor, this, this::setVariable); getIterable().accept(visitor, this, this::setIterable); getBody().accept(visitor, this, this::setBody); } } }
1,172
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
DoStmt.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/DoStmt.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class DoStmt extends Node implements CompoundStmt { protected @NonNull Statement body; protected @NonNull Expression condition; public DoStmt(Statement body, Expression condition) { setBody(body); setCondition(condition); } @Override public DoStmt clone() { return new DoStmt(getBody().clone(), getCondition().clone()); } @Override public String toCode() { var body = getBody(); return "do" + bodyString(body) + (body instanceof Block? " " : "\n") + "while(" + getCondition().toCode() + ");"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitDoStmt(this, parent, cast(replacer))) { getBody().accept(visitor, this, this::setBody); getCondition().accept(visitor, this, this::setCondition); } } }
1,012
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ArrayType.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ArrayType.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ArrayType extends ReferenceType implements Dimensioned { protected @NonNull Type baseType; protected @NonNull List<Dimension> dimensions; public ArrayType(Type baseType) { this(baseType, List.of(new Dimension())); } public ArrayType(Type baseType, List<Dimension> dimensions) { this(baseType, dimensions, emptyList()); } public ArrayType(Type baseType, Dimension... dimensions) { this(baseType, List.of(dimensions)); } public ArrayType(Type baseType, List<Dimension> dimensions, List<Annotation> annotations) { super(annotations); setBaseType(baseType); setDimensions(dimensions); } @Override public ArrayType clone() { return new ArrayType(getBaseType().clone(), clone(getDimensions()), clone(getAnnotations())); } @Override public String toCode() { return annotationString(false) + getBaseType().toCode() + dimensionString(); } @Override public void setDimensions(@NonNull List<Dimension> dimensions) { this.dimensions = newList(dimensions); } @Override public final void setDimensions(Dimension... dimensions) { setDimensions(List.of(dimensions)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitArrayType(this, parent, cast(replacer))) { getBaseType().accept(visitor, this, this::setBaseType); visitList(visitor, getDimensions()); visitList(visitor, getAnnotations()); } } }
1,698
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
PreDecrementExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/PreDecrementExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class PreDecrementExpr extends Node implements ChangeExpr { protected @NonNull Expression expression; public PreDecrementExpr(Expression expression) { setExpression(expression); } @Override public Precedence precedence() { return Precedence.UNARY_AND_CAST; } @Override public PreDecrementExpr clone() { return new PreDecrementExpr(getExpression().clone()); } @Override public String toCode() { return "--" + wrap(getExpression()).toCode(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitPreDecrementExpr(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); } } }
922
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ConstructorCall.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ConstructorCall.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ConstructorCall extends Node implements Statement, TypeArgumentHolder { protected @NonNull Optional<? extends Expression> object; protected @NonNull List<? extends TypeArgument> typeArguments; private @NonNull ConstructorCall.Type type; private @NonNull List<? extends Expression> arguments; public ConstructorCall(ConstructorCall.Type type, List<? extends Expression> arguments) { this(emptyList(), type, arguments); } public ConstructorCall(ConstructorCall.Type type, Expression... arguments) { this(type, List.of(arguments)); } public ConstructorCall(List<? extends TypeArgument> typeArguments, ConstructorCall.Type type, List<? extends Expression> arguments) { this(Optional.empty(), typeArguments, type, arguments); } public ConstructorCall(List<? extends TypeArgument> typeArguments, ConstructorCall.Type type, Expression... arguments) { this(Optional.empty(), typeArguments, type, List.of(arguments)); } public ConstructorCall(Expression object, List<? extends TypeArgument> typeArguments, ConstructorCall.Type type, List<? extends Expression> arguments) { this(Optional.ofNullable(object), typeArguments, type, arguments); } public ConstructorCall(Expression object, List<? extends TypeArgument> typeArguments, ConstructorCall.Type type, Expression... arguments) { this(object, typeArguments, type, List.of(arguments)); } public ConstructorCall(Optional<? extends Expression> object, ConstructorCall.Type type, List<? extends Expression> arguments) { this(object, emptyList(), type, arguments); } public ConstructorCall(Optional<? extends Expression> object, ConstructorCall.Type type, Expression... arguments) { this(object, type, List.of(arguments)); } public ConstructorCall(Expression object, ConstructorCall.Type type, List<? extends Expression> arguments) { this(Optional.ofNullable(object), type, arguments); } public ConstructorCall(Expression object, ConstructorCall.Type type, Expression... arguments) { this(object, type, List.of(arguments)); } public ConstructorCall(Optional<? extends Expression> object, List<? extends TypeArgument> typeArguments, ConstructorCall.Type type, List<? extends Expression> arguments) { setObject(object); setTypeArguments(typeArguments); setType(type); setArguments(arguments); } @Override public ConstructorCall clone() { return new ConstructorCall(clone(getObject()), clone(getTypeArguments()), getType(), clone(getArguments())); } @Override public String toCode() { return getObject().map(object -> object.toCode() + ".").orElse("") + typeArgumentString() + getType().toString() + "(" + joinNodes(", ", getArguments()) + ");"; } public void setArguments(@NonNull List<? extends Expression> arguments) { this.arguments = newList(arguments); } public final void setArguments(Expression... arguments) { setArguments(List.of(arguments)); } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } public void setObject(@NonNull Optional<? extends Expression> object) { this.object = object; } public final void setObject(Expression object) { setObject(Optional.ofNullable(object)); } public final void setObject() { setObject(Optional.empty()); } public static enum Type { THIS, SUPER; @Override public String toString() { return name().toLowerCase(); } } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitConstructorCall(this, parent, cast(replacer))) { getObject().ifPresent(object -> object.<Expression>accept(visitor, this, this::setObject)); visitList(visitor, getTypeArguments()); visitList(visitor, getArguments()); } } }
4,224
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
UnaryExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/UnaryExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; @EqualsAndHashCode @Getter @Setter public class UnaryExpr extends Node implements Expression { protected @NonNull UnaryExpr.Op operation; protected @NonNull Expression operand; public UnaryExpr(UnaryExpr.Op operation, Expression operand) { setOperation(operation); setOperand(operand); } @Override public Precedence precedence() { return Precedence.UNARY_AND_CAST; } @Override public UnaryExpr clone() { return new UnaryExpr(getOperation(), getOperand().clone()); } @Override public String toCode() { return getOperation() + wrap(getOperand()).toCode(); } @RequiredArgsConstructor public static enum Op { NEGATE("-"), POSITIVE("+"), INVERT("~"), NOT("!"); @Getter @Accessors(fluent = true) protected final String toString; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitUnaryExpr(this, parent, cast(replacer))) { getOperand().accept(visitor, this, this::setOperand); } } }
1,253
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
EnumDecl.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/EnumDecl.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @EqualsAndHashCode @Getter @Setter public class EnumDecl extends TypeDecl { protected @NonNull List<GenericType> interfaces; protected @NonNull List<EnumField> constants; public EnumDecl(Name name, List<EnumField> constants, List<? extends Member> members) { this(name, emptyList(), constants, members); } public EnumDecl(Name name, List<GenericType> interfaces, List<EnumField> constants, List<? extends Member> members) { this(name, interfaces, constants, members, emptyList(), emptyList(), Optional.empty()); } public EnumDecl(Name name, List<EnumField> constants, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { this(name, emptyList(), constants, members, modifiers, annotations, docComment); } public EnumDecl(Name name, List<GenericType> interfaces, List<EnumField> constants, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) { super(name, emptyList(), members, modifiers, annotations, docComment); setInterfaces(interfaces); setConstants(constants); } @Override public EnumDecl clone() { return new EnumDecl(getName(), clone(getInterfaces()), clone(getConstants()), clone(getMembers()), clone(getModifiers()), clone(getAnnotations()), getDocComment()); } @Override public String toCode() { var interfaces = getInterfaces(); var constants = getConstants(); var members = getMembers(); var result = docString() + annotationString() + modifierString() + "enum " + getName() + (interfaces.isEmpty()? "" : " implements " + joinNodes(", ", interfaces)) + " {"; if(!constants.isEmpty() || !members.isEmpty()) { if(!constants.isEmpty()) { result += "\n" + join("", constants, constant -> constant.toCode().indent(4)); } if(!members.isEmpty()) { if(!constants.isEmpty() && result.endsWith("\n")) { result = result.substring(0, result.length()-1); } else { result += "\n "; } result += ";\n\n" + join("", members, member -> member.toCode().indent(4)); } } return result + "}"; } public void setInterfaces(@NonNull List<GenericType> interfaces) { this.interfaces = newList(interfaces); } public final void setInterfaces(GenericType... interfaces) { setInterfaces(List.of(interfaces)); } public void setConstants(@NonNull List<EnumField> constants) { this.constants = newList(constants); } public final void setConstants(EnumField... constants) { setConstants(List.of(constants)); } @Override public void setTypeParameters(@NonNull List<TypeParameter> typeParameters) { if(!typeParameters.isEmpty()) { throw new IllegalArgumentException("Enums cannot have type parameters"); } } @Override public List<TypeParameter> getTypeParameters() { return emptyList(); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitEnumDecl(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getInterfaces()); visitList(visitor, getConstants()); visitList(visitor, getMembers()); visitList(visitor, getModifiers()); visitList(visitor, getAnnotations()); } } }
3,527
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ParensExpr.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/ParensExpr.java
package jtree.nodes; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class ParensExpr extends Node implements Expression { protected @NonNull Expression expression; public ParensExpr(Expression expression) { setExpression(expression); } @Override public Precedence precedence() { return Precedence.PRIMARY; } @Override public ParensExpr clone() { return new ParensExpr(getExpression().clone()); } @Override public String toCode() { return "(" + getExpression().toCode() + ")"; } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitParensExpr(this, parent, cast(replacer))) { getExpression().accept(visitor, this, this::setExpression); } } }
884
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
GenericType.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/GenericType.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class GenericType extends ReferenceType implements TypeArgumentHolder { protected @NonNull QualifiedName name; protected @NonNull List<? extends TypeArgument> typeArguments; private @NonNull Optional<GenericType> container; public GenericType(QualifiedName name) { this(name, emptyList()); } public GenericType(QualifiedName name, Optional<GenericType> container) { this(name, emptyList(), container); } public GenericType(QualifiedName name, GenericType container) { this(name, Optional.ofNullable(container)); } public GenericType(QualifiedName name, List<? extends TypeArgument> typeArguments) { this(name, typeArguments, emptyList()); } public GenericType(QualifiedName name, List<? extends TypeArgument> typeArguments, Optional<GenericType> container) { this(name, typeArguments, container, emptyList()); } public GenericType(QualifiedName name, List<? extends TypeArgument> typeArguments, GenericType container) { this(name, typeArguments, Optional.ofNullable(container)); } public GenericType(QualifiedName name, List<? extends TypeArgument> typeArguments, List<Annotation> annotations) { this(name, typeArguments, Optional.empty(), annotations); } public GenericType(QualifiedName name, List<? extends TypeArgument> typeArguments, GenericType container, List<Annotation> annotations) { this(name, typeArguments, Optional.ofNullable(container), annotations); } public GenericType(QualifiedName name, List<? extends TypeArgument> typeArguments, Optional<GenericType> container, List<Annotation> annotations) { super(annotations); setName(name); setContainer(container); setTypeArguments(typeArguments); } @Override public GenericType clone() { return new GenericType(getName(), clone(getTypeArguments()), clone(getContainer()), clone(getAnnotations())); } @Override public String toCode() { return getContainer().map(container -> container.toCode() + ".").orElse("") + annotationString(false) + getName() + typeArgumentString(); } @Override public void setTypeArguments(@NonNull List<? extends TypeArgument> typeArguments) { this.typeArguments = newList(typeArguments); } @Override public final void setTypeArguments(TypeArgument... typeArguments) { setTypeArguments(List.of(typeArguments)); } public void setName(QualifiedName name) { /*if(name.lastName().equals("var")) { throw new IllegalArgumentException("\"var\" cannot be used as a type name"); }*/ this.name = name; } public void setContainer(@NonNull Optional<GenericType> container) { this.container = container; } public final void setContainer(GenericType container) { setContainer(Optional.ofNullable(container)); } public final void setContainer() { setContainer(Optional.empty()); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitGenericType(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); getContainer().ifPresent(container -> container.<GenericType>accept(visitor, this, this::setContainer)); visitList(visitor, getTypeArguments()); visitList(visitor, getAnnotations()); } } }
3,490
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
QualifiedName.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/QualifiedName.java
package jtree.nodes; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.function.Consumer; import java.util.stream.Collector; import java.util.stream.Stream; import lombok.Getter; import lombok.NonNull; import lombok.experimental.Accessors; public final class QualifiedName extends Node implements Iterable<Name>, CharSequence { private final Name[] names; private final String stringValue; @Getter(lazy = true) @Accessors(fluent = true) private final int hashCode = Objects.hash(names, stringValue); /** * @param string the qualified name * @throws IllegalArgumentException If the argument is not a valid qualified * name. */ public QualifiedName(@NonNull String string) { String[] strs = string.split("\\."); this.names = Arrays.stream(strs).map(Name::new).toArray(Name[]::new); this.stringValue = string; } /** * @param strings the names * @throws IllegalArgumentException If the argument is not a valid qualified * name. */ public QualifiedName(@NonNull String... strings) { this.names = Arrays.stream(strings).map(Name::new).toArray(Name[]::new); this.stringValue = String.join(".", strings); } public QualifiedName(@NonNull Name... names) { if(names.length == 0) { throw new IllegalArgumentException("No names given"); } for(var name : names) { Objects.requireNonNull(name); } this.names = names; this.stringValue = String.join(".", names); } public QualifiedName(@NonNull CharSequence... stuffs) { if(stuffs.length == 0) { throw new IllegalArgumentException("No names given"); } var names = new ArrayList<Name>(stuffs.length); for(var stuff : stuffs) { Objects.requireNonNull(stuff); if(stuff instanceof Name) { names.add((Name)stuff); } else { String str = stuff.toString(); if(str.indexOf('.') == -1) { names.add(new Name(str)); } else { for(String name : str.split("\\.")) { names.add(new Name(name)); } } } } this.names = names.toArray(new Name[names.size()]); this.stringValue = String.join(".", names); } public QualifiedName(Collection<Name> names) { this(names.toArray(new Name[names.size()])); } @Override public QualifiedName clone() { return this; } public static final Collector<? extends CharSequence, ArrayList<Name>, QualifiedName> TO_QUALIFIED_NAME = Collector.of(ArrayList<Name>::new, QualifiedName::addToList, (list1, list2) -> { list1.addAll(list2); return list1; }, list -> new QualifiedName(list.toArray(new Name[list.size()]))); private static ArrayList<Name> addToList(ArrayList<Name> list, Object obj) { if(obj instanceof Name) { list.add((Name)obj); } else if(obj instanceof QualifiedName) { for(var name : (QualifiedName)obj) { list.add(name); } } else if(obj instanceof Name[]) { for(var name : (Name[])obj) { list.add(name); } } else if(obj instanceof QualifiedName[]) { for(var qualname : (QualifiedName[])obj) { for(var name : qualname) { list.add(name); } } } else if(obj instanceof CharSequence) { var str = obj.toString(); if(str.indexOf('.') == -1) { list.add(new Name(str)); } else { for(var substr : str.split("\\.")) { list.add(new Name(substr)); } } } else if(obj instanceof CharSequence[]) { for(var cseq : (CharSequence[])obj) { addToList(list, cseq); } } else if(obj instanceof Iterable) { for(var elem : (Iterable<?>)obj) { addToList(list, elem); } } else if(obj instanceof Object[]) { for(var elem : (Object[])obj) { addToList(list, elem); } } else { throw new IllegalArgumentException("Don't know how to convert " + obj.getClass().getSimpleName() + " to Name"); } return list; } @SuppressWarnings("unchecked") public static <T extends CharSequence> Collector<? super T, ArrayList<Name>, QualifiedName> collector() { return (Collector<? super T,ArrayList<Name>,QualifiedName>)TO_QUALIFIED_NAME; } public QualifiedName append(Name other) { return new QualifiedName(this, other); } public QualifiedName append(Name... names) { return Stream.concat(Arrays.stream(this.names), Arrays.stream(names)).collect(QualifiedName.collector()); } public QualifiedName append(List<? extends CharSequence> names) { return Stream.concat(Arrays.stream(this.names), names.stream()).collect(QualifiedName.collector()); } public QualifiedName append(QualifiedName other) { return Stream.concat(Stream.of(this), other.stream()).collect(QualifiedName.collector()); } public QualifiedName append(QualifiedName... names) { return Stream.concat(Stream.of(this), Arrays.stream(names)).collect(QualifiedName.collector()); } public QualifiedName append(CharSequence... names) { return Stream.concat(Stream.of(this), Arrays.stream(names)).collect(QualifiedName.collector()); } public Stream<Name> stream() { return Arrays.stream(names); } public Stream<Name> parallelStream() { return stream().parallel(); } public boolean contains(String name) { return stringValue.contains(name); } public boolean contains(Name name) { return Arrays.stream(names).anyMatch(name::equals); } public int nameCount() { return names.length; } public int charIndexOf(String substr) { return stringValue.indexOf(substr); } public int nameIndexOf(@NonNull Name subname) { for(int i = 0; i < names.length; i++) { if(names[i].equals(subname)) { return i; } } return -1; } public Name getName(int index) { return names[index]; } public Name firstName() { return names[0]; } public Name lastName() { return names[names.length-1]; } public QualifiedName subName(int start) { Objects.checkIndex(start, names.length); Name[] newnames = new Name[names.length - start]; System.arraycopy(names, start, newnames, 0, newnames.length); return new QualifiedName(newnames); } public QualifiedName subName(int start, int end) { Objects.checkFromToIndex(start, end, names.length); if(start == end) { throw new IndexOutOfBoundsException("start == end"); } Name[] newnames = new Name[end - start]; System.arraycopy(names, start, newnames, 0, newnames.length); return new QualifiedName(newnames); } public boolean isQualified() { return names.length > 1; } /** * @throws UnsupportedOperationException If this object is not * {@linkplain #isQualified() qualified}. */ public Name toName() { if(isQualified()) { return names[0]; } else { throw new UnsupportedOperationException(); } } @Override public Iterator<Name> iterator() { return Arrays.stream(names).iterator(); } public Name[] toArray() { return names.clone(); } @Override public String toString() { return stringValue; } @Override public String toCode() { return stringValue; } @Override public int length() { return stringValue.length(); } @Override public char charAt(int index) { return stringValue.charAt(index); } @Override public CharSequence subSequence(int start, int end) { return stringValue.substring(start, end); } public boolean startsWith(String str) { return stringValue.startsWith(str); } public boolean endsWith(String str) { return stringValue.endsWith(str); } public boolean startsWith(Name name) { return names[0].equals(name); } public boolean endsWith(Name name) { return names[names.length-1].equals(name); } public boolean startsWith(QualifiedName name) { if(nameCount() < name.nameCount()) { return false; } for(int i = 0; i < name.nameCount(); i++) { if(!getName(i).equals(name.getName(i))) { return false; } } return true; } public boolean endsWith(QualifiedName name) { if(nameCount() < name.nameCount()) { return false; } for(int i = name.nameCount(), j = nameCount(); i >= 0; i--, j--) { if(!getName(j).equals(name.getName(i))) { return false; } } return true; } @Override public boolean equals(Object obj) { if(this == obj) { return true; } else if(obj instanceof QualifiedName) { var name = (QualifiedName)obj; return Arrays.equals(names, name.names) && stringValue.equals(name.stringValue); } else { return obj instanceof CharSequence && stringValue.contentEquals((CharSequence)obj); } } public boolean equals(QualifiedName name) { return Arrays.equals(names, name.names); } public boolean equals(CharSequence cseq) { return stringValue.contentEquals(cseq); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { visitor.visitQualifiedName(this, parent, cast(replacer)); } }
8,996
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
RequiresDirective.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/RequiresDirective.java
package jtree.nodes; import static jtree.util.Utils.*; import java.util.List; import java.util.function.Consumer; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NonNull; @EqualsAndHashCode @Getter @Setter public class RequiresDirective extends Directive implements Modified { protected @NonNull List<Modifier> modifiers; public RequiresDirective(QualifiedName moduleName) { this(moduleName, emptyList()); } public RequiresDirective(QualifiedName moduleName, List<Modifier> modifiers) { super(moduleName); setModifiers(modifiers); } @Override public RequiresDirective clone() { return new RequiresDirective(getName(), clone(getModifiers())); } @Override public String toCode() { return "requires " + modifierString() + getName() + ";"; } @Override public void setModifiers(@NonNull List<Modifier> modifiers) { this.modifiers = newList(modifiers); } @Override public final void setModifiers(Modifier... modifiers) { setModifiers(List.of(modifiers)); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { if(visitor.visitRequiresDirective(this, parent, cast(replacer))) { getName().accept(visitor, this, this::setName); visitList(visitor, getModifiers()); } } }
1,319
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Expression.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Expression.java
package jtree.nodes; public interface Expression extends Initializer { @Override Expression clone(); Precedence precedence(); default Expression wrap(Expression expr) { if(expr.precedence().isGreaterThan(this.precedence())) { return new ParensExpr(expr); } else { return expr; } } default Expression unwrap(Expression expr) { if(expr instanceof ParensExpr) { var expr2 = ((ParensExpr)expr).getExpression(); if(expr2.precedence().isLessThanOrEqualTo(this.precedence())) { return expr2; } } else if(expr.precedence().isGreaterThan(this.precedence())) { return new ParensExpr(expr); } return expr; } }
649
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Modifier.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/nodes/Modifier.java
package jtree.nodes; import java.util.Arrays; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; import lombok.Getter; import lombok.NonNull; import lombok.experimental.Accessors; public class Modifier extends Node { public static enum Modifiers implements CharSequence { PUBLIC, PRIVATE, PROTECTED, STATIC, FINAL, TRANSIENT, VOLATILE, STRICTFP, NATIVE, SYNCHRONIZED, DEFAULT, ABSTRACT, TRANSITIVE; @Getter @Accessors(fluent = true) private final String toString = name().toLowerCase(); @Override public int length() { return toString.length(); } @Override public char charAt(int index) { return toString.charAt(index); } @Override public CharSequence subSequence(int start, int end) { return toString.subSequence(start, end); } private static final Map<String, Modifiers> NAME_TO_MODIFIER = Arrays.stream(values()).collect(Collectors.toMap(Modifiers::toString, m -> m)); public static Modifiers fromString(String str) { var result = NAME_TO_MODIFIER.get(str); if(result == null) { throw new IllegalArgumentException("'" + str + "' is not a valid Modifier"); } return result; } } protected final String modifier; public Modifier(Modifiers modifier) { this(modifier.toString()); } protected Modifier(@NonNull String value) { if(value.isBlank() || Character.isWhitespace(value.codePointAt(0)) || Character.isWhitespace(value.codePointAt(value.codePointCount(0, value.length()) - 1))) { throw new IllegalArgumentException("'" + value + "' is not a valid modifier"); } this.modifier = value; } @Override public Modifier clone() { return this; } @Override public String toCode() { return modifier; } @Override public String toString() { return modifier; } @Override public int hashCode() { return modifier.hashCode(); } @Override public boolean equals(Object obj) { return this == obj || obj instanceof Modifier && modifier.equals(((Modifier)obj).modifier) || obj instanceof CharSequence && modifier.contentEquals((CharSequence)obj); } public boolean equals(CharSequence cseq) { return modifier.contentEquals(cseq); } @Override public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) { visitor.visitModifier(this, parent, cast(replacer)); } }
2,388
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ContextStack.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/util/ContextStack.java
package jtree.util; import java.util.Stack; import java.util.function.Supplier; public final class ContextStack<T> implements ContextManager { private Stack<T> stack = new Stack<>(); public ContextStack() {} public ContextStack(T initialElement) { stack.push(initialElement); } public boolean isEmpty() { return stack.isEmpty(); } public int size() { return stack.size(); } public T get(int index) { return stack.get(index); } public T current() { return stack.peek(); } public T currentOrElse(T defaultValue) { if(stack.isEmpty()) { return defaultValue; } else { return stack.peek(); } } public T currentOrElseGet(Supplier<? extends T> defaultValueSupplier) { if(stack.isEmpty()) { return defaultValueSupplier.get(); } else { return stack.peek(); } } public ContextStack<T> enter(T element) { stack.push(element); return this; } @Override public void exit() { stack.pop(); } @Override public String toString() { return stack.toString(); } @Override public boolean equals(Object obj) { return obj instanceof ContextStack && stack.equals(((ContextStack<?>)obj).stack) || stack.equals(obj); } }
1,191
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Utils.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/util/Utils.java
package jtree.util; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.function.Function; import jtree.nodes.INode; import lombok.NonNull; import lombok.experimental.UtilityClass; @UtilityClass public class Utils { public <T> Iterable<T> iter(Iterator<T> iter) { return () -> iter; } public <T> List<T> emptyList() { return Collections.emptyList(); } public <T> ArrayList<T> newList() { return new ArrayList<>(); } @SafeVarargs public <T> ArrayList<T> newList(@NonNull T... elements) { var result = new ArrayList<T>(elements.length); for(T t : elements) { result.add(Objects.requireNonNull(t)); } return result; } public <T> ArrayList<T> newList(List<? extends T> list) { var result = new ArrayList<T>(list.size()); for(T t : list) { result.add(Objects.requireNonNull(t)); } return result; } public String joinNodes(String sep, INode... nodes) { return joinNodes(sep, Arrays.asList(nodes)); } public String joinNodes(String sep, Iterable<? extends INode> nodes) { return join(sep, nodes, INode::toCode); } public String join(String sep, Object... objects) { return join(sep, Arrays.asList(objects)); } public String join(String sep, Iterable<?> objects) { return join(sep, objects, Object::toString); } public <T> String join(String sep, T[] objects, Function<? super T, ?> mapper) { return join(sep, Arrays.asList(objects), mapper); } public <T> String join(String sep, Iterable<? extends T> objects, Function<? super T, ?> mapper) { var sb = new StringBuilder(); boolean first = true; for(var obj : objects) { if(first) { first = false; } else { sb.append(sep); } sb.append(mapper.apply(obj)); } return sb.toString(); } }
1,866
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
ContextManager.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/util/ContextManager.java
package jtree.util; public interface ContextManager extends AutoCloseable { void exit(); @Override default void close() { exit(); } }
142
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
LookAheadListIterator.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/util/LookAheadListIterator.java
package jtree.util; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Stack; import java.util.function.Consumer; import lombok.Setter; public class LookAheadListIterator<T> implements ListIterator<T>, Iterable<T> { private List<T> items; private Stack<Integer> marks = new Stack<>(); private int index; private Consumer<? super T> setter; public LookAheadListIterator(Iterable<? extends T> items) { this(items, null); } public LookAheadListIterator(Iterable<? extends T> items, Consumer<? super T> setter) { this.items = new ArrayList<>(); for(T t : items) { this.items.add(t); } if(this.items.isEmpty()) { throw new IllegalArgumentException("No items given"); } this.setter = setter; } @Override public T next() { if(index == items.size()) { return items.get(items.size()-1); } else { return items.get(index++); } } @Override public T previous() { if(index == 0) { return items.get(0); } else { return items.get(--index); } } public T look(int look) { int i = index + look; if(i < 0) { i = 0; } else if(i >= items.size()) { i = items.size()-1; } return items.get(i); } public class ResettableMarkContext implements AutoCloseable { @Setter private boolean reset = false; private boolean closed = false; public void reset() { reset = true; } public boolean willReset() { return reset; } public void reset(boolean reset) { this.reset = reset; close(); } @Override public void close() { if(closed) { throw new IllegalStateException("ResettableMarkContext has already been closed"); } closed = true; if(reset) { index = marks.pop(); if(setter != null) { setter.accept(look(-1)); } } else { marks.pop(); } } } public ResettableMarkContext enter() { marks.push(index); return new ResettableMarkContext(); } @Override public Iterator<T> iterator() { return new Iterator<>() { int pos = index; @Override public boolean hasNext() { return pos < items.size(); } @Override public T next() { if(pos >= items.size()) { throw new IllegalArgumentException(); } else { return items.get(pos++); } } }; } @Override public boolean hasNext() { return index < items.size(); } @Override public boolean hasPrevious() { return index > 0; } @Override public int nextIndex() { return index+1; } @Override public int previousIndex() { return index-1; } @Override public void remove() { throw new UnsupportedOperationException(); } @Override public void set(T e) { throw new UnsupportedOperationException(); } @Override public void add(T e) { throw new UnsupportedOperationException(); } }
2,830
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
Either.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/src/jtree/util/Either.java
package jtree.util; import java.util.NoSuchElementException; import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import lombok.NonNull; @SuppressWarnings("unchecked") public final class Either<F,S> { public static <F,S> Either<F,S> first(@NonNull F first) { return new Either<>(true, first); } public static <F,S> Either<F,S> second(@NonNull S second) { return new Either<>(false, second); } private final boolean isFirst; private final Object value; private Either(boolean isFirst, Object value) { if(this.isFirst = isFirst) { this.value = value; } else { this.value = value; } } public boolean isFirst() { return isFirst; } public boolean isSecond() { return !isFirst; } public F first() { if(isFirst) { return (F)value; } else { throw new NoSuchElementException(); } } public F firstOrElse(F other) { return isFirst? (F)value : other; } public F firstOrElseGet(Supplier<? extends F> supplier) { return isFirst? (F)value : supplier.get(); } public F firstOrElseThrow() { if(isFirst) { return (F)value; } else { throw new NoSuchElementException(); } } public <X extends Throwable> F firstOrElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if(isFirst) { return (F)value; } else { throw exceptionSupplier.get(); } } public S second() { if(isFirst) { throw new NoSuchElementException(); } else { return (S)value; } } public S secondOrElse(S other) { return isFirst? other : (S)value; } public S secondOrElseGet(Supplier<? extends S> supplier) { return isFirst? supplier.get() : (S)value; } public S secondOrElseThrow() { if(isFirst) { throw new NoSuchElementException(); } else { return (S)value; } } public <X extends Throwable> S secondOrElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if(isFirst) { throw exceptionSupplier.get(); } else { return (S)value; } } public Object getValue() { return value; } public void ifFirst(Consumer<? super F> action) { if(isFirst) { action.accept((F)value); } } public void ifSecond(Consumer<? super S> action) { if(!isFirst) { action.accept((S)value); } } public void accept(Consumer<? super F> action, Consumer<? super S> otherAction) { if(isFirst) { action.accept((F)value); } else { otherAction.accept((S)value); } } public <F2,S2> Either<F2,S2> flatMap(Function<? super F, ? extends Either<? extends F2, ? extends S2>> firstMapper, Function<? super S, ? extends Either<? extends F2, ? extends S2>> secondMapper) { return isFirst? (Either<F2,S2>)firstMapper.apply((F)value) : (Either<F2,S2>)secondMapper.apply((S)value); } public <F2,S2> Either<F2,S2> flatMap(BiFunction<? super Boolean, ? super Object, ? extends Either<? extends F2, ? extends S2>> mapper) { return (Either<F2,S2>)mapper.apply(isFirst, value); } public <F2,S2> Either<F2,S2> map(BiFunction<? super Boolean, ? super Object, ?> mapper) { Object result = mapper.apply(isFirst, value); return isFirst? Either.first((F2)result) : Either.second((S2)result); } public <F2,S2> Either<F2,S2> map(Function<? super F, ? extends F2> firstMapper, Function<? super S, ? extends S2> secondMapper) { return isFirst? Either.first(firstMapper.apply((F)value)) : Either.second(secondMapper.apply((S)value)); } public <T> T unravel(Function<? super F, ? extends T> firstMapper, Function<? super S, ? extends T> secondMapper) { return isFirst? firstMapper.apply((F)value) : secondMapper.apply((S)value); } public <T> T unravel(BiFunction<? super Boolean, ? super Object, ? extends T> func) { return func.apply(isFirst, value); } @Override public int hashCode() { return Objects.hash(isFirst, value); } @Override public boolean equals(Object obj) { if(this == obj) { return true; } if(obj instanceof Either) { var either = (Either<?,?>)obj; return isFirst == either.isFirst && Objects.equals(value, either.value); } return false; } @Override public String toString() { return String.format("Either.%s(%s)", isFirst? "first" : "second", value); } }
4,727
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TestLookAheadListIterator.java
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/JavaParser/tests/jtree/tests/TestLookAheadListIterator.java
package jtree.tests; import static org.junit.jupiter.api.Assertions.*; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import jtree.util.LookAheadListIterator; import lombok.RequiredArgsConstructor; class TestLookAheadListIterator { @Test void test1() { var iter = new LookAheadListIterator<>(List.of(1,2,3,4,5,6)); assertEquals(1, iter.next()); assertEquals(2, iter.next()); assertEquals(3, iter.look(0)); assertEquals(2, iter.look(-1)); assertEquals(3, iter.next()); assertEquals(6, iter.look(2)); assertEquals(4, iter.next()); assertEquals(3, iter.look(-2)); assertEquals(6, iter.look(1)); assertEquals(5, iter.next()); } @Test void test2() { @RequiredArgsConstructor class Element { private final String id; @Override public String toString() { return id; } } Element obj1 = new Element("obj1"), obj2 = new Element("obj2"), obj3 = new Element("obj3"), obj4 = new Element("obj4"), obj5 = new Element("obj5"), obj6 = new Element("obj6"); var iter = new LookAheadListIterator<>( List.of(obj1, obj2, obj3, obj4, obj5, obj6) .stream() .map(obj -> { System.out.println("get " + obj); return obj; }) .collect(Collectors.toList()) ); try(var state = iter.enter()) { assertEquals(obj1, iter.next()); assertEquals(obj2, iter.next()); assertEquals(obj3, iter.next()); assertEquals(obj4, iter.next()); state.reset(); } assertEquals(obj1, iter.next()); assertEquals(obj2, iter.look(0)); assertEquals(obj1, iter.previous()); assertEquals(obj1, iter.look(0)); assertEquals(obj1, iter.next()); assertEquals(obj2, iter.next()); assertEquals(obj3, iter.next()); try(var state = iter.enter()) { assertEquals(obj4, iter.next()); assertEquals(obj5, iter.next()); state.reset(); } assertEquals(obj4, iter.next()); assertEquals(obj4, iter.previous()); assertEquals(obj3, iter.previous()); assertEquals(obj2, iter.previous()); assertEquals(obj1, iter.previous()); assertEquals(obj1, iter.next()); } }
2,161
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z
TestModule.javapp
/FileExtraction/Java_unseen/raptor494_JavaPlusPlus/Java++Parser/TestModule.javapp
import com.test.Foo; open module com.test { requires transitive com.test.Thing; uses Foo; opens com.test.Bar to org.test; provides com.test.Service with com.test.ServiceImpl; }
182
Java
.java
raptor494/JavaPlusPlus
10
0
0
2019-07-12T21:47:58Z
2019-08-13T18:38:44Z