//===--- SyntaxCollectionData.h ---------------------------------*- C++ -*-===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2017 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 // //===----------------------------------------------------------------------===// #ifndef SWIFT_SYNTAX_SYNTAXCOLLECTIONDATA_H #define SWIFT_SYNTAX_SYNTAXCOLLECTIONDATA_H #include "swift/Syntax/SyntaxData.h" namespace swift { namespace syntax { template class SyntaxCollection; template class SyntaxCollectionData : public SyntaxData { friend class SyntaxCollection; std::vector> CachedElements; friend struct SyntaxFactory; friend class SyntaxData; friend class FunctionCallExprSyntaxBuilder; SyntaxCollectionData(RC Raw, const SyntaxData *Parent = nullptr, CursorIndex IndexInParent = 0) : SyntaxData(Raw, Parent, IndexInParent), CachedElements(Raw->Layout.size(), nullptr) { assert(Raw->Kind == CollectionKind); } static RC> make(RC Raw, const SyntaxData *Parent = nullptr, CursorIndex IndexInParent = 0) { return RC> { new SyntaxCollectionData { Raw, Parent, IndexInParent } }; } static RC> makeBlank() { auto Raw = RawSyntax::make(CollectionKind, {}, SourcePresence::Present); return make(Raw); } public: static bool classof(const SyntaxData *SD) { return SD->getKind() == CollectionKind; } }; } // end namespace syntax } // end namespace swift #endif