Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
89214105
Commit
89214105
authored
Oct 13, 2014
by
Maxime Perrotin
Browse files
Magic autocompletion for text, State and Input
parent
95d69280
Changes
6
Hide whitespace changes
Inline
Side-by-side
TextInteraction.py
View file @
89214105
...
...
@@ -248,7 +248,7 @@ class EditableText(QGraphicsTextItem, object):
def
context_completion_list
(
self
):
''' Advanced context-dependent autocompletion
for SEQUENCE fields
'''
''' Advanced context-dependent autocompletion '''
# Select text from the begining of a line to the cursor position
# Then keep the last word including separators ('!' and '.')
# This word (e.g. variable!field!subfield) is then used to update
...
...
ogAST.py
View file @
89214105
...
...
@@ -927,6 +927,7 @@ class AST(object):
self
.
dataview
=
None
self
.
asn1Modules
=
None
# ASN.1-defined constants (constants in Ada but variables in C)
# dictionnary: {ConstantName: type } - copied from dataview.py
self
.
asn1_constants
=
None
# List of System
...
...
ogParser.py
View file @
89214105
...
...
@@ -3976,11 +3976,13 @@ def parseSingleElement(elem='', string=''):
t
,
semantic_errors
,
warnings
=
backend_ptr
(
root
=
root
,
parent
=
None
,
context
=
context
)
except
AttributeError
as
err
:
print
str
(
err
)
print
(
traceback
.
format_exc
())
#
print str(err)
#
print (traceback.format_exc())
# Syntax checker has no visibility on variables and types
# so we have to discard exceptions sent by e.g. find_variable
pass
except
NotImplementedError
as
err
:
syntax_errors
.
append
(
'Syntax error in expression - Fix it.'
)
return
(
t
,
syntax_errors
,
semantic_errors
,
warnings
,
context
.
terminators
)
...
...
sdlSymbols.py
View file @
89214105
...
...
@@ -57,17 +57,31 @@ SDL_REDBOLD = ['\\b{word}\\b'.format(word=word) for word in (
'TASK'
,
'PROCESS'
,
'LABEL'
,
'JOIN'
,
'CONNECTION'
,
'CONNECT'
)]
def
variables_autocompletion
(
symbol
):
''' Intelligent autocompletion for variables - including struct fields '''
res
=
()
def
variables_autocompletion
(
symbol
,
type_filter
=
None
):
''' Intelligent autocompletion for variables - including struct fields
Optional: only variables of a type listed in type_filter are kept
'''
res
=
set
()
if
not
symbol
.
text
:
return
res
parts
=
symbol
.
text
.
context
.
split
(
'!'
)
if
len
(
parts
)
==
0
:
return
res
elif
len
(
parts
)
==
1
:
# Return the list of variables
res
=
set
(
CONTEXT
.
variables
.
keys
()
+
AST
.
asn1_constants
.
keys
())
# Return the list of variables, possibly filterd by type
if
not
type_filter
:
res
=
set
(
CONTEXT
.
variables
.
keys
()
+
CONTEXT
.
global_variables
.
keys
()
+
AST
.
asn1_constants
.
keys
())
else
:
constants
=
{
name
:
(
cty
.
type
,
None
)
for
name
,
cty
in
AST
.
asn1_constants
.
viewitems
()}
type_filter_names
=
[
ogParser
.
type_name
(
ty
)
for
ty
in
type_filter
]
for
name
,
(
asn1type
,
_
)
in
chain
(
CONTEXT
.
variables
.
viewitems
(),
CONTEXT
.
global_variables
.
viewitems
(),
constants
.
viewitems
()):
if
ogParser
.
type_name
(
asn1type
)
in
type_filter_names
:
res
.
add
(
name
)
else
:
var
=
parts
[
0
].
lower
()
try
:
...
...
@@ -156,9 +170,15 @@ class Input(HorizontalSymbol):
def
completion_list
(
self
):
''' Set auto-completion list '''
if
'('
in
unicode
(
self
):
return
variables_autocompletion
(
self
)
# Input parameter: return the list of variables of this type
input_name
=
unicode
(
self
).
split
(
'('
)[
0
].
strip
().
lower
()
asn1_filter
=
[
sig
[
'type'
]
for
sig
in
CONTEXT
.
input_signals
if
sig
[
'name'
]
==
input_name
]
return
variables_autocompletion
(
self
,
asn1_filter
)
else
:
return
(
sig
[
'name'
]
for
sig
in
CONTEXT
.
input_signals
)
# Return the list of input signals and timers
return
(
set
(
sig
[
'name'
]
for
sig
in
CONTEXT
.
input_signals
).
union
(
CONTEXT
.
global_timers
+
CONTEXT
.
timers
))
class
Connect
(
Input
):
...
...
@@ -592,7 +612,6 @@ class ProcedureCall(VerticalSymbol):
blackbold
=
[
'
\\
bWRITELN
\\
b'
,
'
\\
bWRITE
\\
b'
,
'
\\
bSET_TIMER
\\
b'
,
'
\\
bRESET_TIMER
\\
b'
]
redbold
=
SDL_REDBOLD
#completion_list = {'set_timer', 'reset_timer', 'write', 'writeln'}
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Output
(
defName
=
''
)
...
...
@@ -660,7 +679,13 @@ class TextSymbol(HorizontalSymbol):
@
property
def
completion_list
(
self
):
''' Set auto-completion list '''
return
AST
.
dataview
.
viewkeys
()
res
=
set
(
CONTEXT
.
global_timers
+
CONTEXT
.
timers
)
try
:
res
=
res
.
union
(
AST
.
dataview
.
keys
())
except
AttributeError
:
# No Dataview
pass
return
res
def
set_shape
(
self
,
width
,
height
):
''' Define the polygon of the text symbol '''
...
...
tests/regression/test-debug/orchestrator.pr
View file @
89214105
...
...
@@ -6,9 +6,7 @@ COMMENT 'Hello';
dcl seq tastE_Peek_id_list;
dcl fixed FixedString := 'Hello';
dcl variable VariableString := 'Hello';
dcl seqboolean SeqBool := { true, false };
dcl seqbool2 SeqBoolFix := { true, false };
...
...
@@ -63,4 +61,4 @@ endfor;
/* CIF STATE (423, 163), (118, 50) */
STATE Wait_for_GUI;
ENDSTATE;
ENDPROCESS orchestrator;
\ No newline at end of file
ENDPROCESS orchestrator;
tests/regression/test6/dataview-uniq.asn
View file @
89214105
...
...
@@ -53,6 +53,8 @@ Autocompletion ::= SEQUENCE {
-- You can also declare variables (they will be visible in C, Ada and SDL)
myVar MySeqOf ::= { hello, world }
mySeq Autocompletion ::= { first-field TRUE, secondField { third TRUE, fourth FALSE } }
myConst INTEGER ::= 5
myStart T-Int32 ::= 32
END
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment