public ArgumentListTreeImpl newArguments(ExpressionTree expression, Optional<List<Tuple<InternalSyntaxToken, ExpressionTree>>> rests) { ImmutableList.Builder<ExpressionTree> expressions = ImmutableList.builder(); expressions.add(expression); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); if (rests.isPresent()) { for (Tuple<InternalSyntaxToken, ExpressionTree> rest : rests.get()) { separators.add(rest.first()); expressions.add(rest.second()); } } return new ArgumentListTreeImpl(expressions.build(), separators.build()); }
public ArgumentListTreeImpl newNormalAnnotation(AssignmentExpressionTreeImpl elementValuePair, Optional<List<Tuple<InternalSyntaxToken, AssignmentExpressionTreeImpl>>> rests) { ImmutableList.Builder<ExpressionTree> expressions = ImmutableList.builder(); expressions.add(elementValuePair); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); if (rests.isPresent()) { for (Tuple<InternalSyntaxToken, AssignmentExpressionTreeImpl> rest : rests.get()) { separators.add(rest.first()); expressions.add(rest.second()); } } return new ArgumentListTreeImpl(expressions.build(), separators.build()); }
public BoundListTreeImpl newBounds(TypeTree classType, Optional<List<Tuple<InternalSyntaxToken, Tree>>> rests) { ImmutableList.Builder<Tree> classTypes = ImmutableList.builder(); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); classTypes.add(classType); if (rests.isPresent()) { for (Tuple<InternalSyntaxToken, Tree> rest : rests.get()) { separators.add(rest.first()); classTypes.add(rest.second()); } } return new BoundListTreeImpl(classTypes.build(), separators.build()); }
@CheckForNull private static ArrayTypeTreeImpl newArrayTypeTree(Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> dims) { ArrayTypeTreeImpl result = null; if (dims.isPresent()) { for (Tuple<InternalSyntaxToken, InternalSyntaxToken> dim : dims.get()) { InternalSyntaxToken openBracketToken = dim.first(); InternalSyntaxToken closeBracketToken = dim.second(); result = new ArrayTypeTreeImpl(result, ImmutableList.<AnnotationTreeImpl>of(), openBracketToken, closeBracketToken); } } return result; }
public ArgumentListTreeImpl newNormalAnnotation(AssignmentExpressionTreeImpl elementValuePair, Optional<List<Tuple<InternalSyntaxToken, AssignmentExpressionTreeImpl>>> rests) { ImmutableList.Builder<ExpressionTree> expressions = ImmutableList.builder(); expressions.add(elementValuePair); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); if (rests.isPresent()) { for (Tuple<InternalSyntaxToken, AssignmentExpressionTreeImpl> rest : rests.get()) { separators.add(rest.first()); expressions.add(rest.second()); } } return new ArgumentListTreeImpl(expressions.build(), separators.build()); }
public MethodTreeImpl newAnnotationTypeMethod(InternalSyntaxToken openParenToken, InternalSyntaxToken closeParenToken, Optional<Tuple<InternalSyntaxToken, ExpressionTree>> defaultValue) { FormalParametersListTreeImpl parameters = new FormalParametersListTreeImpl(openParenToken, closeParenToken); InternalSyntaxToken defaultToken = null; ExpressionTree defaultExpression = null; if (defaultValue.isPresent()) { defaultToken = defaultValue.get().first(); defaultExpression = defaultValue.get().second(); } return new MethodTreeImpl(parameters, defaultToken, defaultExpression); }
public StatementExpressionListTreeImpl newStatementExpressions(ExpressionTree expression, Optional<List<Tuple<InternalSyntaxToken, ExpressionTree>>> rests) { ImmutableList.Builder<StatementTree> statements = ImmutableList.builder(); statements.add(new ExpressionStatementTreeImpl(expression, null)); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); if (rests.isPresent()) { for (Tuple<InternalSyntaxToken, ExpressionTree> rest : rests.get()) { separators.add(rest.first()); statements.add(new ExpressionStatementTreeImpl(rest.second(), null)); } } return new StatementExpressionListTreeImpl(statements.build(), separators.build()); }
public ImportTreeImpl newImportDeclaration(InternalSyntaxToken importToken, Optional<InternalSyntaxToken> staticToken, ExpressionTree qualifiedIdentifier, Optional<Tuple<InternalSyntaxToken, InternalSyntaxToken>> dotStar, InternalSyntaxToken semicolonToken) { ExpressionTree target = qualifiedIdentifier; if (dotStar.isPresent()) { IdentifierTreeImpl identifier = new IdentifierTreeImpl(dotStar.get().second()); InternalSyntaxToken dotToken = dotStar.get().first(); target = new MemberSelectExpressionTreeImpl(qualifiedIdentifier, dotToken, identifier); } InternalSyntaxToken staticKeyword = staticToken.orNull(); return new ImportTreeImpl(importToken, staticKeyword, target, semicolonToken); }
public ModuleDirectiveTree newOpensModuleDirective(InternalSyntaxToken opensKeyword, ExpressionTree packageName, Optional<Tuple<InternalSyntaxToken, ListTreeImpl<ModuleNameTree>>> moduleNames, InternalSyntaxToken semicolonToken) { InternalSyntaxToken toKeyword = null; ListTreeImpl<ModuleNameTree> otherModuleNames = ModuleNameListTreeImpl.emptyList(); if (moduleNames.isPresent()) { Tuple<InternalSyntaxToken, ListTreeImpl<ModuleNameTree>> toModuleNames = moduleNames.get(); toKeyword = toModuleNames.first(); otherModuleNames = toModuleNames.second(); } return new OpensDirectiveTreeImpl(opensKeyword, packageName, toKeyword, otherModuleNames, semicolonToken); }
@CheckForNull private static ArrayTypeTreeImpl newArrayTypeTree(Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> dims) { ArrayTypeTreeImpl result = null; if (dims.isPresent()) { for (Tuple<InternalSyntaxToken, InternalSyntaxToken> dim : dims.get()) { InternalSyntaxToken openBracketToken = dim.first(); InternalSyntaxToken closeBracketToken = dim.second(); result = new ArrayTypeTreeImpl(result, ImmutableList.<AnnotationTreeImpl>of(), openBracketToken, closeBracketToken); } } return result; }
public NewArrayTreeImpl newElementValueArrayInitializer(List<Tuple<ExpressionTree, Optional<InternalSyntaxToken>>> rests) { ImmutableList.Builder<ExpressionTree> expressions = ImmutableList.builder(); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); for (Tuple<ExpressionTree, Optional<InternalSyntaxToken>> tuple : rests) { expressions.add(tuple.first()); if (tuple.second().isPresent()) { separators.add(tuple.second().get()); } } return new NewArrayTreeImpl(ImmutableList.<ArrayDimensionTree>of(), new InitializerListTreeImpl(expressions.build(), separators.build())); }
public ModuleDirectiveTree newExportsModuleDirective(InternalSyntaxToken exportsKeyword, ExpressionTree packageName, Optional<Tuple<InternalSyntaxToken, ListTreeImpl<ModuleNameTree>>> moduleNames, InternalSyntaxToken semicolonToken) { InternalSyntaxToken toKeyword = null; ListTreeImpl<ModuleNameTree> otherModuleNames = ModuleNameListTreeImpl.emptyList(); if (moduleNames.isPresent()) { Tuple<InternalSyntaxToken, ListTreeImpl<ModuleNameTree>> toModuleNames = moduleNames.get(); toKeyword = toModuleNames.first(); otherModuleNames = toModuleNames.second(); } return new ExportsDirectiveTreeImpl(exportsKeyword, packageName, toKeyword, otherModuleNames, semicolonToken); }
public QualifiedIdentifierListTreeImpl newQualifiedIdentifierList(TypeTree qualifiedIdentifier, Optional<List<Tuple<InternalSyntaxToken, TypeTree>>> rests) { ImmutableList.Builder<TypeTree> qualifiedIdentifiers = ImmutableList.builder(); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); qualifiedIdentifiers.add(qualifiedIdentifier); if (rests.isPresent()) { for (Tuple<InternalSyntaxToken, TypeTree> rest : rests.get()) { separators.add(rest.first()); qualifiedIdentifiers.add(rest.second()); } } return new QualifiedIdentifierListTreeImpl(qualifiedIdentifiers.build(), separators.build()); }
public FormalParametersListTreeImpl prependNewFormalParameter(VariableTreeImpl variable, Optional<Tuple<InternalSyntaxToken, FormalParametersListTreeImpl>> rest) { if (rest.isPresent()) { InternalSyntaxToken comma = rest.get().first(); FormalParametersListTreeImpl partial = rest.get().second(); partial.add(0, variable); // store the comma as endToken for the variable variable.setEndToken(comma); return partial; } else { return new FormalParametersListTreeImpl(variable); } }
public ModuleNameTree newModuleName(InternalSyntaxToken firstIdentifier, Optional<List<Tuple<InternalSyntaxToken, InternalSyntaxToken>>> rest) { List<IdentifierTree> identifiers = new ArrayList<>(); List<SyntaxToken> separators = new ArrayList<>(); identifiers.add(new IdentifierTreeImpl(firstIdentifier)); if (rest.isPresent()) { for (Tuple<InternalSyntaxToken, InternalSyntaxToken> modulePart : rest.get()) { separators.add(modulePart.first()); identifiers.add(new IdentifierTreeImpl(modulePart.second())); } } return new ModuleNameTreeImpl(Collections.unmodifiableList(identifiers), Collections.unmodifiableList(separators)); }
public ModuleNameListTreeImpl newModuleNameListTreeImpl(ModuleNameTree firstModuleName, Optional<List<Tuple<InternalSyntaxToken, ModuleNameTree>>> rest) { List<ModuleNameTree> moduleNames = new ArrayList<>(); List<SyntaxToken> separators = new ArrayList<>(); moduleNames.add(firstModuleName); if (rest.isPresent()) { for(Tuple<InternalSyntaxToken, ModuleNameTree> tuple : rest.get()) { separators.add(tuple.first()); moduleNames.add(tuple.second()); } } return new ModuleNameListTreeImpl(Collections.unmodifiableList(moduleNames), Collections.unmodifiableList(separators)); }
private static ArrayTypeTreeImpl newArrayTypeTreeWithAnnotations(TypeTree type, Tuple<Optional<List<AnnotationTreeImpl>>, Tuple<InternalSyntaxToken, InternalSyntaxToken>> dim) { List<AnnotationTreeImpl> annotations = dim.first().or(ImmutableList.<AnnotationTreeImpl>of()); InternalSyntaxToken openBracketToken = dim.second().first(); InternalSyntaxToken closeBracketToken = dim.second().second(); return new ArrayTypeTreeImpl(type, annotations, openBracketToken, closeBracketToken); }
public TypeCastExpressionTreeImpl newClassCastExpression(TypeTree type, Optional<Tuple<InternalSyntaxToken, BoundListTreeImpl>> classTypes, InternalSyntaxToken closeParenToken, ExpressionTree expression) { BoundListTreeImpl bounds = BoundListTreeImpl.emptyList(); InternalSyntaxToken andToken = null; if (classTypes.isPresent()) { andToken = classTypes.get().first(); bounds = classTypes.get().second(); } return new TypeCastExpressionTreeImpl(type, andToken, bounds, closeParenToken, expression); }
public ResourceListTreeImpl newResources(List<Tuple<Tree, Optional<InternalSyntaxToken>>> rests) { ImmutableList.Builder<Tree> resources = ImmutableList.builder(); ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder(); for (Tuple<Tree, Optional<InternalSyntaxToken>> rest : rests) { if (rest.second().isPresent()) { separators.add(rest.second().get()); } resources.add(rest.first()); } return new ResourceListTreeImpl(resources.build(), separators.build()); }
public MethodTreeImpl newAnnotationTypeMethod(InternalSyntaxToken openParenToken, InternalSyntaxToken closeParenToken, Optional<Tuple<InternalSyntaxToken, ExpressionTree>> defaultValue) { FormalParametersListTreeImpl parameters = new FormalParametersListTreeImpl(openParenToken, closeParenToken); InternalSyntaxToken defaultToken = null; ExpressionTree defaultExpression = null; if (defaultValue.isPresent()) { defaultToken = defaultValue.get().first(); defaultExpression = defaultValue.get().second(); } return new MethodTreeImpl(parameters, defaultToken, defaultExpression); }