File tree 3 files changed +15
-1
lines changed
3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -732,6 +732,7 @@ export abstract class NamespaceBase extends ReflectionObject {
732
732
733
733
/** Nested objects of this namespace as an array for iteration. */
734
734
public readonly nestedArray : ReflectionObject [ ] ;
735
+ public readonly orderedNestedMessages : ReflectionObject [ ] ;
735
736
736
737
/**
737
738
* Converts this namespace to a namespace descriptor.
Original file line number Diff line number Diff line change @@ -108,6 +108,12 @@ function Namespace(name, options) {
108
108
* @private
109
109
*/
110
110
this . _nestedArray = null ;
111
+
112
+ /**
113
+ * Array of nested messages in the order they were parsed from the schema.
114
+ * @type {ReflectionObject[] }
115
+ */
116
+ this . orderedNestedMessages = null ;
111
117
}
112
118
113
119
function clearCache ( namespace ) {
@@ -239,6 +245,7 @@ Namespace.prototype.add = function add(object) {
239
245
throw Error ( "duplicate name '" + object . name + "' in " + this ) ;
240
246
}
241
247
}
248
+
242
249
this . nested [ object . name ] = object ;
243
250
object . onAdd ( this ) ;
244
251
return clearCache ( this ) ;
Original file line number Diff line number Diff line change @@ -306,12 +306,18 @@ Root.prototype._handleAdd = function _handleAdd(object) {
306
306
307
307
} else if ( ! ( object instanceof OneOf ) ) /* everything else is a namespace */ {
308
308
309
- if ( object instanceof Type ) // Try to handle any deferred extensions
309
+ if ( object instanceof Type ) { // Try to handle any deferred extensions
310
+ if ( ! object . parent . orderedNestedMessages ) {
311
+ object . parent . orderedNestedMessages = [ ] ;
312
+ }
313
+ object . parent . orderedNestedMessages . push ( object ) ;
314
+
310
315
for ( var i = 0 ; i < this . deferred . length ; )
311
316
if ( tryHandleExtension ( this , this . deferred [ i ] ) )
312
317
this . deferred . splice ( i , 1 ) ;
313
318
else
314
319
++ i ;
320
+ }
315
321
for ( var j = 0 ; j < /* initializes */ object . nestedArray . length ; ++ j ) // recurse into the namespace
316
322
this . _handleAdd ( object . _nestedArray [ j ] ) ;
317
323
if ( exposeRe . test ( object . name ) )
You can’t perform that action at this time.
0 commit comments