@@ -6,7 +6,7 @@ ReflectionObject.className = "ReflectionObject";
66const OneOf = require ( "./oneof" ) ;
77var util = require ( "./util" ) ;
88
9- var Root , Namespace ; // cyclic
9+ var Root ; // cyclic
1010
1111/* eslint-disable no-warning-comments */
1212// TODO: Replace with embedded proto.
@@ -196,6 +196,7 @@ ReflectionObject.prototype._resolveFeaturesRecursive = function _resolveFeatures
196196ReflectionObject . prototype . _resolveFeatures = function _resolveFeatures ( edition ) {
197197 var defaults = { } ;
198198
199+ /* istanbul ignore if */
199200 if ( ! edition ) {
200201 throw new Error ( "Unknown edition for " + this . fullName ) ;
201202 }
@@ -205,6 +206,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
205206
206207 if ( this . _edition ) {
207208 // For a namespace marked with a specific edition, reset defaults.
209+ /* istanbul ignore else */
208210 if ( edition === "proto2" ) {
209211 defaults = Object . assign ( { } , proto2Defaults ) ;
210212 } else if ( edition === "proto3" ) {
@@ -220,6 +222,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
220222
221223 // fields in Oneofs aren't actually children of them, so we have to
222224 // special-case it
225+ /* istanbul ignore else */
223226 if ( this . partOf instanceof OneOf ) {
224227 var lexicalParentFeaturesCopy = Object . assign ( { } , this . partOf . _features ) ;
225228 this . _features = Object . assign ( lexicalParentFeaturesCopy , protoFeatures || { } ) ;
@@ -229,7 +232,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
229232 var parentFeaturesCopy = Object . assign ( { } , this . parent . _features ) ;
230233 this . _features = Object . assign ( parentFeaturesCopy , protoFeatures || { } ) ;
231234 } else {
232- this . _features = Object . assign ( { } , protoFeatures ) ;
235+ throw new Error ( "Unable to find a parent for " + this . fullName ) ;
233236 }
234237 if ( this . extensionField ) {
235238 // Sister fields should have the same features as their extensions.
@@ -268,13 +271,7 @@ ReflectionObject.prototype.getOption = function getOption(name) {
268271ReflectionObject . prototype . setOption = function setOption ( name , value , ifNotSet ) {
269272 if ( ! this . options )
270273 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 ) ) {
278275 util . setProperty ( this . options , name , value , ifNotSet ) ;
279276 } else if ( ! ifNotSet || this . options [ name ] === undefined ) {
280277 if ( this . getOption ( name ) !== value ) this . resolved = false ;
@@ -295,7 +292,6 @@ ReflectionObject.prototype.setParsedOption = function setParsedOption(name, valu
295292 if ( ! this . parsedOptions ) {
296293 this . parsedOptions = [ ] ;
297294 }
298- var isFeature = / ^ f e a t u r e s $ / . test ( name ) ;
299295 var parsedOptions = this . parsedOptions ;
300296 if ( propName ) {
301297 // If setting a sub property of an option then try to merge it
@@ -360,10 +356,9 @@ ReflectionObject.prototype._editionToJSON = function _editionToJSON() {
360356 return undefined ;
361357 }
362358 return this . _edition ;
363- }
359+ } ;
364360
365361// Sets up cyclic dependencies (called in index-light)
366- ReflectionObject . _configure = function ( Root_ , Namespace_ ) {
362+ ReflectionObject . _configure = function ( Root_ ) {
367363 Root = Root_ ;
368- Namespace = Namespace_ ;
369364} ;
0 commit comments