Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-esa committed Apr 26, 2024
2 parents dcef01d + 7907743 commit 4f01003
Show file tree
Hide file tree
Showing 9 changed files with 24,860 additions and 26,125 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ The background pattern was downloaded from www.subtlepatterns.com

Changelog
=========
**4.3.1 (04/2024)**
- Major parsing speedup

**4.3.0 (04/2024)**
- Introduce the requirements and review widgets
- Fix help search engine
Expand Down
55 changes: 55 additions & 0 deletions opengeode/Pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,42 @@ def hyperlink(symbol):
return f"/* CIF Keep Specific Geode HyperLink '{symbol.text.hyperlink}' */"


def req_server(symbol):
''' Gitlab server holding requirements '''
if genericSymbols.g_QtTaste:
url = genericSymbols.g_url
if type(url) != str:
url = url.toString()
return f"/* CIF Keep Specific Geode REQSERVER '{url}' */"
else:
return ''

def req_ids(symbol):
''' PR string for the optional requirement ids associated to a symbol '''
if symbol.req_model is None:
return []
# We have to check if some requirements are selected for the symbol
ticked = symbol.req_model.selectedRequirements()
ticked.extend(symbol.ast.req_ids)
selected=set(ticked)
result = []
for each in selected:
result.append(f"/* CIF Keep Specific Geode REQID '{each}' */")
return result


def rid_ids(symbol):
''' PR string for the optional requirement ids associated to a symbol '''
if symbol.rid_model is None:
return[]
# We have to check if some requirements are selected for the symbol
#selected = symbol.rid_model.selectedReviews()
result = []
#for each in selected:
# result.append(f"/* CIF Keep Specific Geode RID '{each}' */")
return result


def partition(symbol):
scene = symbol.scene()
if scene:
Expand All @@ -195,6 +231,8 @@ def common(name, symbol):
result.append(cif_coord(name, symbol))
if symbol.text.hyperlink:
result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
if isinstance(symbol, (sdlSymbols.State, sdlSymbols.Procedure)) and name != 'NEXTSTATE':
part = partition(symbol)
if part:
Expand Down Expand Up @@ -235,6 +273,8 @@ def _comment(symbol, **kwargs):
result.append(cif_coord('comment', symbol))
if symbol.text.hyperlink:
result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
result.append("comment '" + str(symbol.text).replace("'", "\\'") + "';")
return result

Expand Down Expand Up @@ -306,6 +346,8 @@ def _decisionanswer(symbol, recursive=True, **kwargs):
ans = f'({ans})'
if symbol.text.hyperlink:
result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
result.append(f'{ans}:')
if recursive:
result.extend(recursive_aligned(symbol))
Expand Down Expand Up @@ -347,6 +389,8 @@ def _procedurecall(symbol, **kwargs):
result.append(cif_coord('PROCEDURECALL', symbol))
if symbol.text.hyperlink:
result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
result.append('call {}{}'.format(str(symbol.text), ';'
if not symbol.comment else ''))
if symbol.comment:
Expand All @@ -361,6 +405,8 @@ def _procedurecall(symbol, **kwargs):
result.append(cif_coord('CREATE', symbol))
if symbol.text.hyperlink:
result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
result.append(f'create {str(symbol.text)}{";" if not symbol.comment else ""}')
if symbol.comment:
result.extend(generate(symbol.comment))
Expand All @@ -374,6 +420,8 @@ def _textsymbol(symbol, **kwargs):
#if symbol.text.hyperlink:
# no hyperlink for text symbols (see sdl92.g)
# result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
part = partition(symbol)
if part:
result.append(part)
Expand All @@ -392,6 +440,8 @@ def _label(symbol, recursive=True, **kwargs):
result.append(cif_coord('label', symbol))
if symbol.text.hyperlink:
result.append(hyperlink(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
if symbol.common_name == 'floating_label':
part = partition(symbol)
if part:
Expand Down Expand Up @@ -463,6 +513,9 @@ def _process(symbol, recursive=True, **kwargs):
#result = common(name, symbol)
result = Indent()
result.append(cif_coord('PROCESS', symbol))
result.append(req_server(symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
result.append("{} {}{}".format(name, str(symbol.text), ";" if
not symbol.comment else ""))
if symbol.comment:
Expand Down Expand Up @@ -498,6 +551,8 @@ def _start(symbol, recursive=True, **kwargs):
''' START symbol or branch if recursive is set '''
result = Indent()
result.append(cif_coord('START', symbol))
result.extend(req_ids(symbol))
result.extend(rid_ids(symbol))
result.append('START{via}{comment}'
.format(via=(' ' + str(symbol) + ' ')
if str(symbol).replace('START', '') else '',
Expand Down
8 changes: 7 additions & 1 deletion opengeode/genericSymbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

@Slot (QUrl, str)
def set_credentials(url, token):
''' Slot called whenever user changed the credentials in a Requirements
''' Slot called whenever user changed the credentials in a Requirement
or Review widget '''
global g_url, g_token
g_url = url
Expand Down Expand Up @@ -575,6 +575,12 @@ def contextMenuEvent(self, event):
if self.req_widget.token() != g_token:
self.req_widget.setToken(g_token)
self.req_widget.show()
# Set the list of selected requirements, both from the AST and
# from the user-selection
ticked = self.req_model.selectedRequirements()
ticked.extend(self.ast.req_ids)
selected = set(ticked)
self.req_model.setSelectedRequirements(list(selected))
elif action.text() == rid_action:
# update credentials if they were changed in another
# instance of the widget
Expand Down
42 changes: 42 additions & 0 deletions opengeode/ogAST.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ def __init__(self):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# hint for backends needing a temporary variable to hold the question
self.tmpVar = -1
# Errors associated to this element
Expand Down Expand Up @@ -397,6 +400,9 @@ def __init__(self):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# Errors associated to this element
self.errors, self.warnings = [], []
# the path allows to retrieve the location of the symbol
Expand All @@ -423,6 +429,9 @@ def __init__(self):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
self.elems = []
# Errors associated to this element
self.errors, self.warnings = [], []
Expand Down Expand Up @@ -453,6 +462,9 @@ def __init__(self):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# Errors associated to this element
self.errors, self.warnings = [], []
# the path allows to retrieve the location of the symbol
Expand Down Expand Up @@ -505,6 +517,9 @@ def __init__(self, defName=''):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# Errors associated to this element
self.errors, self.warnings = [], []
# the path allows to retrieve the location of the symbol
Expand Down Expand Up @@ -550,6 +565,9 @@ def __init__(self, defName=''):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# optional Label instance (to be placed just before the terminator)
self.label = None
# Return expression
Expand Down Expand Up @@ -615,6 +633,9 @@ def __init__(self):
self.charPositionInLine = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# No comment for labels - keep to None
self.comment = None
# List of terminators following this label
Expand Down Expand Up @@ -712,6 +733,9 @@ def __init__(self):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# list of terminators following the input symbol
self.terminators = []
# If this input is in fact a continuous signal, code generators will ignore it
Expand Down Expand Up @@ -784,6 +808,9 @@ def __init__(self):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# list of terminators following the start symbol
self.terminators = []
# Errors associated to this element
Expand Down Expand Up @@ -824,6 +851,9 @@ def __init__(self):
self.charPositionInLine = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# Errors associated to this element
self.errors, self.warnings = [], []
# the path allows to retrieve the location of the symbol
Expand Down Expand Up @@ -861,6 +891,9 @@ def __init__(self, defName=''):
self.comment = None
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# optional composite state content (type CompositeState)
self.composite = None
# via clause, used for entering nested state with an entry point
Expand Down Expand Up @@ -912,6 +945,9 @@ def __init__(self):
self.procedures = []
# optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# List of Observer states defined in this text area (error/success/ignore states)
# used for error reporting to get the right symbol coordinates
self.observer_states : List [str] = []
Expand Down Expand Up @@ -959,6 +995,9 @@ def __init__(self):
self.height = 35
# Optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# Local variables dictionary (see Process)
self.variables = {}
# MONITOR variables used in observers (same structure as DCL)
Expand Down Expand Up @@ -1064,6 +1103,9 @@ def __init__(self):
self.height = 75
# Optional hyperlink
self.hyperlink = None
# Optional set of requirements and RID ids for this item
self.req_ids = []
self.rid_ids = []
# Optional comment
self.comment = None

Expand Down
Loading

0 comments on commit 4f01003

Please sign in to comment.