File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Source/Tools/ServiceGenerator Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -682,6 +682,32 @@ - (BOOL)preflightChecks:(SGGeneratorMessageHandler)messageHandler {
682682 messageHandler (kSGGeneratorHandlerMessageWarning , warning);
683683 }
684684
685+ // Check for class name collisions.
686+ NSMutableArray *worker = [self .api.sg_topLevelObjectSchemas mutableCopy ];
687+ for (GTLRDiscovery_JsonSchema *schema in self.api .sg_topLevelObjectSchemas ) {
688+ NSArray *kids = schema.sg_childObjectSchemas ;
689+ if (kids.count ) {
690+ [worker addObjectsFromArray: kids];
691+ }
692+ }
693+ NSMutableDictionary *nameToSchema = [[NSMutableDictionary alloc ] init ];
694+ for (GTLRDiscovery_JsonSchema *schema in worker) {
695+ NSString *objcClassName = schema.sg_objcClassName ;
696+ GTLRDiscovery_JsonSchema *previousSchema = [nameToSchema objectForKey: objcClassName];
697+ if (previousSchema) {
698+ // Report the previous first as it likely is higher in the chain
699+ // (especially if it was top level).
700+ NSString *errStr =
701+ [NSString stringWithFormat: @" Collision over the class name '%@ ' (schemas '%@ ' and '%@ ')" ,
702+ objcClassName,
703+ previousSchema.sg_fullSchemaName, schema.sg_fullSchemaName];
704+ messageHandler (kSGGeneratorHandlerMessageError , errStr);
705+ allGood = NO ;
706+ } else {
707+ [nameToSchema setObject: schema forKey: objcClassName];
708+ }
709+ }
710+
685711 return allGood;
686712}
687713
You can’t perform that action at this time.
0 commit comments