<commit_before><commit_msg>Job: #158 Add initial ant<commit_after>---

Copyright 2013 Mentor Graphics Corp.  All Rights Reserved.

---

# Missing return values in realized elements cause parse errors
### xtUML Project Analysis Note

1. Abstract
-----------
This note analyzes one approach to addressing an issue where parse errors are
created for empty OAL bodies that require a return value and have none.

2. Document References
----------------------
[1] Issues 158, https://github.com/xtuml/doc/issues/158  
[2] CQ Issue: dts0101025153

3. Background
-------------
When realized elements were introduced we did not consider what the parser does
with elements that require a return value.  Currently when doing a parse all,
all elements that require a return value and do not have one will have an error
created.  Users would like to suppress these errors as they do not intend to
write OAL in the action body.  Additionally, execution and code generation for
these elements is valid even without the return statement in OAL.

4. Requirements
---------------
4.1 An option should be available to prevent parse errors when an element
requires a return value and is realized.

5. Analysis
-----------
5.1 Add preference to disable parse errors for missing return values in empty
    bodies

A preference shall be added, which when enabled allows parse errors for missing
return values when an OAL body is empty.  This preference shall include a child
preference that when enabled will allow for errors when dealing with realized
elements.  The parser shall ignore this preference when dealing with Elements
that have action language and shall create errors in the same way as it does
today.

The defaults for these two preferences shall be:

non-realized elements : enabled
realized elements : disabled
  
5.2 Provide default OAL for bodies requiring a return value

For those elements that require a return value the tool shall include default
OAL.  This OAL shall be in the following form:

Operations/Functions
--------------------

return <default_value>;

Derived Based Attributes
------------------------

self.attributeName = <default_value>;

The tool currently creates the new operations/functions with a default return
type of void.  In the case of void the tool shall not add any default OAL.  When
the user chooses to change the type of the operation or function the tool shall
insert the default OAL, unless OAL already exists in the element.  This will
prevent any parse error from showing unless the user knowingly changed the OAL
or type after OAL existed.

For Derived Based Attributes the tool shall insert default OAL at the point the
user configures the attribute as derived.

5.3 Support automatically adding default return OAL

A new action shall be added to the tool.  This action shall scan the selected
element and all of its children for elements requiring a return value that have
an empty action body.  For all of those found it shall insert the default OAL.

6. Work Required
----------------

7. Acceptance Test
------------------

End
---


{'fraction_non_alphanumeric': 0.07432005060088552, 'fraction_numerical': 0.01265022137887413, 'mean_word_length': 2.9097651421508033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1691962', 'n_tokens_mistral': 819, 'n_tokens_neox': 749, 'n_words': 456}