//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SwiftSyntax

extension VariableDecl {
  /// Creates an optionally initialized property.
  public init(
    leadingTrivia: Trivia = [],
    _ letOrVarKeyword: TokenSyntax,
    name: ExpressibleAsIdentifierPattern,
    type: ExpressibleAsTypeAnnotation? = nil,
    initializer: ExpressibleAsInitializerClause? = nil
  ) {
    self.init(leadingTrivia: leadingTrivia, letOrVarKeyword: letOrVarKeyword) {
      PatternBinding(
        pattern: name,
        typeAnnotation: type,
        initializer: initializer
      )
    }
  }

  /// Creates a computed property with the given accessor.
  public init(
    leadingTrivia: Trivia = [],
    modifiers: ModifierList? = nil,
    name: ExpressibleAsIdentifierPattern,
    type: ExpressibleAsTypeAnnotation,
    @CodeBlockItemListBuilder accessor: () -> ExpressibleAsCodeBlockItemList
  ) {
    self.init(leadingTrivia: leadingTrivia, modifiers: modifiers, letOrVarKeyword: .var) {
      PatternBinding(
        pattern: name,
        typeAnnotation: type,
        accessor: CodeBlock(statements: accessor())
      )
    }
  }
}

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SwiftSyntax

extension VariableDecl {
  /// Creates an optionally initialized property.
  public init(
    leadingTrivia: Trivia = [],
    modifiers: ModifierList? = nil,
    _ letOrVarKeyword: TokenSyntax,
    name: ExpressibleAsIdentifierPattern,
    type: ExpressibleAsTypeAnnotation? = nil,
    initializer: ExpressibleAsInitializerClause? = nil
  ) {
    self.init(leadingTrivia: leadingTrivia, modifiers: modifiers, letOrVarKeyword: letOrVarKeyword) {
      PatternBinding(
        pattern: name,
        typeAnnotation: type,
        initializer: initializer
      )
    }
  }

  /// Creates a computed property with the given accessor.
  public init(
    leadingTrivia: Trivia = [],
    modifiers: ModifierList? = nil,
    name: ExpressibleAsIdentifierPattern,
    type: ExpressibleAsTypeAnnotation,
    @CodeBlockItemListBuilder accessor: () -> ExpressibleAsCodeBlockItemList
  ) {
    self.init(leadingTrivia: leadingTrivia, modifiers: modifiers, letOrVarKeyword: .var) {
      PatternBinding(
        pattern: name,
        typeAnnotation: type,
        accessor: CodeBlock(statements: accessor())
      )
    }
  }
}

Add modifiers parameter to VariableDecl convenience init
Add modifiers parameter to VariableDecl convenience init
