Commit aeb13bc2 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Detect duplicate procedures

parent 44c9ff3d
......@@ -142,6 +142,9 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
1.5.12 (09/2016)
- Detect duplicate declaration of procedures
1.5.11 (09/2016)
- Allow semicolon in the declaration of procedures after RETURNS keyword
......
......@@ -2026,8 +2026,15 @@ def composite_state(root, parent=None, context=None):
comp.entry_procedure = new_proc
elif new_proc.inputString.strip().lower() == 'exit':
comp.exit_procedure = new_proc
comp.content.inner_procedures.append(new_proc)
# check for duplicate declaration
if any(each.inputString.lower() == new_proc.inputString.lower()
for each in chain(comp.content.inner_procedures,
context.procedures)):
errors.append(['Duplicate procedure Declaration: {}'
.format(new_proc.inputString),
[new_proc.pos_x, new_proc.pos_y], []])
# Add procedure to the context, to make it visible at scope level
comp.content.inner_procedures.append(new_proc)
context.procedures.append(new_proc)
elif child.type in (lexer.COMPOSITE_STATE, lexer.STATE_AGGREGATION):
inner_composite.append(child)
......@@ -2202,9 +2209,17 @@ def procedure_post(proc, content, parent=None, context=None):
inner_proc.append((new_proc, content))
errors.extend(err)
warnings.extend(warn)
proc.content.inner_procedures.append(new_proc)
# check for duplicate declaration
err = any(each.inputString.lower() == new_proc.inputString.lower()
for each in chain(proc.content.inner_procedures,
context.procedures))
# Add procedure to the context, to make it visible at scope level
context.procedures.append(new_proc)
proc.content.inner_procedures.append(new_proc)
if err:
errors.append(['Duplicate declaration of procedure {}'
.format(new_proc.inputString),
[0, 0], []])
elif child.type == lexer.START:
# START transition (fills the mapping structure)
proc.content.start, err, warn = start(child, context=proc)
......@@ -2527,11 +2542,18 @@ def text_area_content(root, ta_ast, context):
errors.extend(err)
warnings.extend(warn)
try:
# Add procedure to the container (process or procedure)
context.content.inner_procedures.append(proc)
content = context.content.inner_procedures
except AttributeError:
# May not be any content in current context (eg System)
pass
content = []
# check for duplicates
if any(each.inputString.lower() == proc.inputString.lower()
for each in chain(content, context.procedures)):
errors.append('Duplicate Procedure Declaration: {}'
.format(proc.inputString))
# Add procedure to the container (process or procedure) if any
content.append(proc)
# Add to context to make it visible at scope level
context.procedures.append(proc)
# And add it to the TextArea AST for the text autocompletion
......@@ -2809,8 +2831,15 @@ def process_definition(root, parent=None, context=None):
inner_proc.append((proc, content))
errors.extend(err)
warnings.extend(warn)
process.content.inner_procedures.append(proc)
# check for duplicate declaration
if any(each.inputString.lower() == proc.inputString.lower()
for each in chain(process.content.inner_procedures,
process.procedures)):
errors.append(['Duplicate Procedure declaration: {}'
.format(proc.inputString),
[proc.pos_x, proc.pos_y], []])
# Add it at process level so that it is in the scope
process.content.inner_procedures.append(proc)
process.procedures.append(proc)
elif child.type == lexer.FLOATING_LABEL:
lab, err, warn = floating_label(
......
......@@ -138,7 +138,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.5.11'
__version__ = '1.5.12'
if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated)
......@@ -1300,15 +1300,17 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# TODO check if symbol can have more than
# one connection if there is already one, if start
# and end can be on the same symbol, etc.
self.mode = 'wait_next_connection_point'
click_point = event.scenePos()
point = self.border_point(symb, click_point)
self.edge_points = [point]
self.temp_lines.append(self.addLine(point.x(),
point.y(),
click_point.x(),
click_point.y()))
self.connection_start = symb
# DISABLE CONNECTIONS FOR NOW
pass
# self.mode = 'wait_next_connection_point'
# click_point = event.scenePos()
# point = self.border_point(symb, click_point)
# self.edge_points = [point]
# self.temp_lines.append(self.addLine(point.x(),
# point.y(),
# click_point.x(),
# click_point.y()))
# self.connection_start = symb
elif self.mode == 'wait_placement':
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment