Exemplo n.º 1
0
DictionaryTypeSyntax
SyntaxFactory::makeDictionaryType(RC<TokenSyntax> LeftSquareBracket,
                                  TypeSyntax KeyType,
                                  RC<TokenSyntax> Colon,
                                  TypeSyntax ValueType,
                                  RC<TokenSyntax> RightSquareBracket) {
  auto Raw = RawSyntax::make(SyntaxKind::DictionaryType,
                             {
                               LeftSquareBracket,
                               KeyType.getRaw(),
                               Colon,
                               ValueType.getRaw(),
                               RightSquareBracket
                             },
                             SourcePresence::Present);
  auto Data = DictionaryTypeSyntaxData::make(Raw);
  return DictionaryTypeSyntax { Data, Data.get() };
}
Exemplo n.º 2
0
TypeAliasDeclSyntax SyntaxFactory::makeTypealiasDecl(
    RC<TokenSyntax> TypealiasToken, RC<TokenSyntax> Identifier,
    GenericParameterClauseSyntax GenericParams, RC<TokenSyntax> AssignmentToken,
    TypeSyntax Type) {
  auto Raw = RawSyntax::make(SyntaxKind::TypeAliasDecl,
                             {TypealiasToken, Identifier, GenericParams.getRaw(),
                              AssignmentToken, Type.getRaw()},
                             SourcePresence::Present);
  auto Data = TypeAliasDeclSyntaxData::make(Raw);
  return TypeAliasDeclSyntax { Data, Data.get() };
}
Exemplo n.º 3
0
ImplicitlyUnwrappedOptionalTypeSyntax SyntaxFactory::
makeImplicitlyUnwrappedOptionalType(TypeSyntax BaseType,
                                    const Trivia &TrailingTrivia) {
  auto Raw = RawSyntax::make(SyntaxKind::ImplicitlyUnwrappedOptionalType,
    {
      BaseType.getRaw(),
      SyntaxFactory::makeExclaimPostfixToken(TrailingTrivia),
    },
    SourcePresence::Present);
  auto Data = ImplicitlyUnwrappedOptionalTypeSyntaxData::make(Raw);
  return ImplicitlyUnwrappedOptionalTypeSyntax { Data, Data.get() };
}
Exemplo n.º 4
0
MetatypeTypeSyntax SyntaxFactory::makeMetatypeType(TypeSyntax BaseType,
                                                   RC<TokenSyntax> DotToken,
                                                   RC<TokenSyntax> TypeToken) {
  auto Raw = RawSyntax::make(SyntaxKind::MetatypeType,
                             {
                               BaseType.getRaw(),
                               DotToken,
                               TypeToken
                             },
                             SourcePresence::Present);
  auto Data = MetatypeTypeSyntaxData::make(Raw);
  return MetatypeTypeSyntax { Data, Data.get() };
}
Exemplo n.º 5
0
OptionalTypeSyntax
SyntaxFactory::makeOptionalType(TypeSyntax BaseType,
                                const Trivia &TrailingTrivia) {
  auto Raw = RawSyntax::make(SyntaxKind::OptionalType,
  {
    BaseType.getRaw(),
    SyntaxFactory::makeQuestionPostfixToken(TrailingTrivia),
  },
  SourcePresence::Present);

  auto Data = OptionalTypeSyntaxData::make(Raw);
  return OptionalTypeSyntax { Data, Data.get() };
}
Exemplo n.º 6
0
SameTypeRequirementSyntax SyntaxFactory::makeSameTypeRequirement(
    TypeIdentifierSyntax LeftTypeIdentifier, RC<TokenSyntax> EqualityToken,
    TypeSyntax RightType) {
  auto Raw = RawSyntax::make(SyntaxKind::SameTypeRequirement,
                             {
                               LeftTypeIdentifier.getRaw(),
                               EqualityToken,
                               RightType.getRaw()
                             },
                             SourcePresence::Present);
  auto Data = SameTypeRequirementSyntaxData::make(Raw);
  return SameTypeRequirementSyntax { Data, Data.get() };
}
Exemplo n.º 7
0
ArrayTypeSyntax
SyntaxFactory::makeArrayType(RC<TokenSyntax> LeftSquareBracket,
                             TypeSyntax ElementType,
                             RC<TokenSyntax> RightSquareBracket) {
  auto Raw = RawSyntax::make(SyntaxKind::ArrayType,
                             {
                               LeftSquareBracket,
                               ElementType.getRaw(),
                               RightSquareBracket
                             },
                             SourcePresence::Present);
  auto Data = ArrayTypeSyntaxData::make(Raw);
  return ArrayTypeSyntax { Data, Data.get() };
}
Exemplo n.º 8
0
FunctionTypeArgumentSyntax
SyntaxFactory::makeFunctionTypeArgument(TypeSyntax TypeArgument) {
  auto Raw = RawSyntax::make(SyntaxKind::FunctionTypeArgument,
    {
      TokenSyntax::missingToken(tok::identifier, ""),
      TokenSyntax::missingToken(tok::identifier, ""),
      RawSyntax::missing(SyntaxKind::TypeAttributes),
      TokenSyntax::missingToken(tok::kw_inout, "inout"),
      TokenSyntax::missingToken(tok::colon, ":"),
      TypeArgument.getRaw()
    }, SourcePresence::Present);
  auto Data = FunctionTypeArgumentSyntaxData::make(Raw);
  return { Data, Data.get() };
}
Exemplo n.º 9
0
FunctionTypeArgumentSyntax SyntaxFactory::
makeFunctionTypeArgument(RC<TokenSyntax> ExternalParameterName,
                         RC<TokenSyntax> LocalParameterName,
                         TypeAttributesSyntax TypeAttributes,
                         RC<TokenSyntax> InoutKeyword,
                         RC<TokenSyntax> ColonToken,
                         TypeSyntax ParameterTypeSyntax) {
  auto Raw = RawSyntax::make(SyntaxKind::FunctionTypeArgument,
                             {
                               ExternalParameterName,
                               LocalParameterName,
                               TypeAttributes.getRaw(),
                               InoutKeyword,
                               ColonToken,
                               ParameterTypeSyntax.getRaw()
                             }, SourcePresence::Present);
  auto Data = FunctionTypeArgumentSyntaxData::make(Raw);
  return { Data, Data.get() };
}
Exemplo n.º 10
0
FunctionTypeSyntax SyntaxFactory::makeFunctionType(
    TypeAttributesSyntax TypeAttributes, RC<TokenSyntax> LeftParen,
    TypeArgumentListSyntax ArgumentList, RC<TokenSyntax> RightParen,
    RC<TokenSyntax> ThrowsOrRethrows, RC<TokenSyntax> Arrow,
    TypeSyntax ReturnType) {
  auto Raw =
      RawSyntax::make(SyntaxKind::FunctionType,
                      {
                        TypeAttributes.getRaw(),
                        LeftParen,
                        ArgumentList.getRaw(),
                        RightParen,
                        ThrowsOrRethrows,
                        Arrow,
                        ReturnType.getRaw()
                      },
                      SourcePresence::Present);
  auto Data = FunctionTypeSyntaxData::make(Raw);
  return FunctionTypeSyntax { Data, Data.get() };
}
Exemplo n.º 11
0
FunctionSignatureSyntax
SyntaxFactory::makeFunctionSignature(RC<TokenSyntax> LeftParen,
                                     FunctionParameterListSyntax ParameterList,
                                     RC<TokenSyntax> RightParen,
                                     RC<TokenSyntax> ThrowsOrRethrows,
                                     RC<TokenSyntax> Arrow,
                                     TypeAttributesSyntax ReturnTypeAttributes,
                                     TypeSyntax ReturnTypeSyntax) {
  auto Raw = RawSyntax::make(SyntaxKind::FunctionSignature,
                             {
                               LeftParen,
                               ParameterList.getRaw(),
                               RightParen,
                               ThrowsOrRethrows,
                               Arrow,
                               ReturnTypeAttributes.getRaw(),
                               ReturnTypeSyntax.getRaw()
                             },
                             SourcePresence::Present);
  auto Data = FunctionSignatureSyntaxData::make(Raw);
  return { Data, Data.get() };
}
Exemplo n.º 12
0
TypeAliasDeclSyntax
TypeAliasDeclSyntax::withTypeSyntax(TypeSyntax NewType) const {
  return Data->replaceChild<TypeAliasDeclSyntax>(NewType.getRaw(),
                                                 Cursor::Type);
}