/**
 * Copyright (c) 2016-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import * as Code from '../code' ; import * as Error from '../error' ; import * as FileWriter from '../file-writer' ; import * as ImmutableImportUtils from '../immutable-import-utils' ; import * as ImmutableInitializerUtils from '../immutable-initializer-utils' ; import * as Maybe from '../maybe' ; import * as ObjC from '../objc' ; import * as ObjCCommentUtils from '../objc-comment-utils' ; import * as ObjCNullabilityUtils from '../objc-nullability-utils' ; import * as ObjectSpec from '../object-spec' ; export function createPlugin ( ) { return { additionalFiles : function ( objectType ) : Code . File [ ] { return [ ] ; } , transformBaseFile : function ( objectType , baseFile ) : Code . File { return baseFile ; } , additionalTypes : function ( objectType ) : ObjectSpec . Type [ ] { return [ ] ; } , attributes : function ( objectType ) : ObjectSpec . Attribute [ ] { return [ ] ; } , classMethods : function ( objectType ) : ObjC . Method [ ] { return [ ] ; } , transformFileRequest : function ( request ) : FileWriter . Request { return request ; } , fileType : function ( objectType ) : Code . FileType | null { return null ; } , forwardDeclarations : function ( objectType ) : ObjC . ForwardDeclaration [ ] { return objectType . includes . indexOf ( 'UseForwardDeclarations' ) !== - 1 ? ImmutableImportUtils . forwardClassDeclarationsForObjectType ( objectType ) : [ ] ; } , functions : function ( objectType ) : ObjC . Function [ ] { return [ ] ; } , headerComments : function ( objectType ) : ObjC . Comment [ ] { return [ ] ; } , implementedProtocols : function ( objectType ) : ObjC . ImplementedProtocol [ ] { return [ ] ; } , imports : ImmutableImportUtils . importsForObjectType , instanceMethods : ( objectType ) => { const initializers = ImmutableInitializerUtils . initializerMethodsForObjectType ( objectType ) ; const getters = objectType . attributes . map ( ( attribute ) => ( { preprocessors : [ ] , belongsToProtocol : null , code : [ `return _${ attribute . name };` ] , comments : ObjCCommentUtils . commentsAsBlockFromStringArray ( attribute . comments ) , compilerAttributes : [ ] , keywords : [ { argument : null , name : attribute . name } , ] , returnType : { type : attribute . type , modifiers : ObjCNullabilityUtils . keywordArgumentModifiersForNullability ( attribute . nullability ) } } ) ) ; return initializers . concat ( getters ) ; } , instanceVariables : ( objectType ) => objectType . attributes . map ( ( attribute ) => ( { comments : [ ] , modifiers : [ ] , access : ObjC . InstanceVariableAccess . Private ( ) , name : attribute . name , returnType : attribute . type } ) ) , macros : function ( valueType ) : ObjC . Macro [ ] { return [ ] ; } , properties : function ( objectType ) : ObjC . Property [ ] { return [ ] ; } , requiredIncludesToRun : [ 'RMImmutableIvars' ] , staticConstants : function ( objectType ) : ObjC . Constant [ ] { return [ ] ; } , validationErrors : function ( objectType ) : Error . Error [ ] { return [ ] ; } , nullability : function ( objectType ) : ObjC . ClassNullability | null { return null ; } , subclassingRestricted : function ( objectType ) : boolean { return false ; } } ; }