@@ -205,8 +205,11 @@ def reserved_title(self) -> Optional[str]:
205
205
206
206
@property
207
207
def reserved_statement (self ) -> Optional [str ]:
208
+ element : GrammarElement = self .document .grammar .elements_by_type [
209
+ self .requirement_type
210
+ ]
208
211
return self ._get_cached_field (
209
- RequirementFieldName . STATEMENT , singleline_only = False
212
+ element . content_field [ 0 ] , singleline_only = False
210
213
)
211
214
212
215
@property
@@ -276,6 +279,12 @@ def get_requirement_style_mode(self) -> str:
276
279
assert self .ng_document_reference .get_document () is not None
277
280
return self .ng_document_reference .get_document ().config .get_requirement_style_mode ()
278
281
282
+ def get_content_field_name (self ) -> str :
283
+ element : GrammarElement = self .document .grammar .elements_by_type [
284
+ self .requirement_type
285
+ ]
286
+ return element .content_field [0 ]
287
+
279
288
def has_requirement_references (self , ref_type : str ) -> bool :
280
289
if len (self .relations ) == 0 :
281
290
return False
@@ -374,9 +383,7 @@ def enumerate_meta_fields(
374
383
self .requirement_type
375
384
]
376
385
grammar_field_titles = list (map (lambda f : f .title , element .fields ))
377
- statement_field_index = grammar_field_titles .index (
378
- RequirementFieldName .STATEMENT
379
- )
386
+ statement_field_index : int = element .content_field [1 ]
380
387
for field in self .enumerate_fields ():
381
388
if field .field_name in RESERVED_NON_META_FIELDS :
382
389
continue
@@ -412,6 +419,13 @@ def get_field_human_title(self, field_name: str) -> str:
412
419
field_human_title = element .fields_map [field_name ]
413
420
return field_human_title .get_field_human_name ()
414
421
422
+ def get_field_human_title_for_statement (self ) -> str :
423
+ element : GrammarElement = self .document .grammar .elements_by_type [
424
+ self .requirement_type
425
+ ]
426
+ field_human_title = element .fields_map [element .content_field [0 ]]
427
+ return field_human_title .get_field_human_name ()
428
+
415
429
def get_requirement_prefix (self ) -> str :
416
430
parent : Union [SDocSection , SDocDocument ] = assert_cast (
417
431
self .parent , (SDocSection , SDocDocument , SDocCompositeNode )
@@ -479,25 +493,11 @@ def set_field_value(
479
493
self .requirement_type
480
494
]
481
495
grammar_field_titles = list (map (lambda f : f .title , element .fields ))
482
- # FIXME: This will go away very soon when the RELATIONS become a
483
- # separate field in SDoc REQUIREMENT's grammar.
484
- grammar_field_titles .append ("REFS" )
485
496
field_index = grammar_field_titles .index (field_name )
486
497
487
- try :
488
- title_field_index = grammar_field_titles .index (
489
- RequirementFieldName .TITLE
490
- )
491
- except ValueError :
492
- # It is a rare edge case when a grammar is without a TITLE but if it
493
- # happens, use STATEMENT as a fallback.
494
- title_field_index = grammar_field_titles .index (
495
- RequirementFieldName .STATEMENT
496
- )
497
-
498
498
field_value = None
499
499
field_value_multiline = None
500
- if field_index <= title_field_index :
500
+ if field_index < element . content_field [ 1 ] :
501
501
field_value = value
502
502
else :
503
503
field_value_multiline = value
0 commit comments