@@ -6,7 +6,7 @@ ReflectionObject.className = "ReflectionObject";
6
6
const OneOf = require ( "./oneof" ) ;
7
7
var util = require ( "./util" ) ;
8
8
9
- var Root , Namespace ; // cyclic
9
+ var Root ; // cyclic
10
10
11
11
/* eslint-disable no-warning-comments */
12
12
// TODO: Replace with embedded proto.
@@ -196,6 +196,7 @@ ReflectionObject.prototype._resolveFeaturesRecursive = function _resolveFeatures
196
196
ReflectionObject . prototype . _resolveFeatures = function _resolveFeatures ( edition ) {
197
197
var defaults = { } ;
198
198
199
+ /* istanbul ignore if */
199
200
if ( ! edition ) {
200
201
throw new Error ( "Unknown edition for " + this . fullName ) ;
201
202
}
@@ -205,6 +206,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
205
206
206
207
if ( this . _edition ) {
207
208
// For a namespace marked with a specific edition, reset defaults.
209
+ /* istanbul ignore else */
208
210
if ( edition === "proto2" ) {
209
211
defaults = Object . assign ( { } , proto2Defaults ) ;
210
212
} else if ( edition === "proto3" ) {
@@ -220,6 +222,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
220
222
221
223
// fields in Oneofs aren't actually children of them, so we have to
222
224
// special-case it
225
+ /* istanbul ignore else */
223
226
if ( this . partOf instanceof OneOf ) {
224
227
var lexicalParentFeaturesCopy = Object . assign ( { } , this . partOf . _features ) ;
225
228
this . _features = Object . assign ( lexicalParentFeaturesCopy , protoFeatures || { } ) ;
@@ -229,7 +232,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
229
232
var parentFeaturesCopy = Object . assign ( { } , this . parent . _features ) ;
230
233
this . _features = Object . assign ( parentFeaturesCopy , protoFeatures || { } ) ;
231
234
} else {
232
- this . _features = Object . assign ( { } , protoFeatures ) ;
235
+ throw new Error ( "Unable to find a parent for " + this . fullName ) ;
233
236
}
234
237
if ( this . extensionField ) {
235
238
// Sister fields should have the same features as their extensions.
@@ -268,13 +271,7 @@ ReflectionObject.prototype.getOption = function getOption(name) {
268
271
ReflectionObject . prototype . setOption = function setOption ( name , value , ifNotSet ) {
269
272
if ( ! this . options )
270
273
this . options = { } ;
271
- if ( name === "features" ) {
272
- if ( ifNotSet ) {
273
- this . options . features = Object . assign ( Object . assign ( { } , value ) , this . options . features || { } ) ;
274
- } else {
275
- this . options . features = Object . assign ( this . options . features || { } , value ) ;
276
- }
277
- } else if ( / ^ f e a t u r e s \. / . test ( name ) ) {
274
+ if ( / ^ f e a t u r e s \. / . test ( name ) ) {
278
275
util . setProperty ( this . options , name , value , ifNotSet ) ;
279
276
} else if ( ! ifNotSet || this . options [ name ] === undefined ) {
280
277
if ( this . getOption ( name ) !== value ) this . resolved = false ;
@@ -295,7 +292,6 @@ ReflectionObject.prototype.setParsedOption = function setParsedOption(name, valu
295
292
if ( ! this . parsedOptions ) {
296
293
this . parsedOptions = [ ] ;
297
294
}
298
- var isFeature = / ^ f e a t u r e s $ / . test ( name ) ;
299
295
var parsedOptions = this . parsedOptions ;
300
296
if ( propName ) {
301
297
// If setting a sub property of an option then try to merge it
@@ -360,10 +356,9 @@ ReflectionObject.prototype._editionToJSON = function _editionToJSON() {
360
356
return undefined ;
361
357
}
362
358
return this . _edition ;
363
- }
359
+ } ;
364
360
365
361
// Sets up cyclic dependencies (called in index-light)
366
- ReflectionObject . _configure = function ( Root_ , Namespace_ ) {
362
+ ReflectionObject . _configure = function ( Root_ ) {
367
363
Root = Root_ ;
368
- Namespace = Namespace_ ;
369
364
} ;
0 commit comments