Region selection for primitives
Regions take the lowest possible node in the ast. For primitives this is often not desired behavior.
The code:
1 1.4 "Asdf" 2015-01-01 0:00:00 2015-12-31 23:59:59 no value
Has the following ast:
[ Int("1"){ (NablProp_ordering(), [Ordered()]) , (NablProp_multiplicity(), [One()]) , (Type(), [Int()]) } , Float("1.4"){ (NablProp_ordering(), [Ordered()]) , (NablProp_multiplicity(), [One()]) , (Type(), [Float()]) } , String("Asdf"){ (NablProp_ordering(), [Ordered()]) , (NablProp_multiplicity(), [One()]) , (Type(), [String()]) } , Datetime("2015-01-01 0:00:00"){ (NablProp_ordering(), [Ordered()]) , (NablProp_multiplicity(), [One()]) , (Type(), [Datetime()]) } , Datetime("2015-12-31 23:59:59"){ (NablProp_ordering(), [Ordered()]) , (NablProp_multiplicity(), [One()]) , (Type(), [Datetime()]) } , NoValue(){ (NablProp_ordering(), [Ordered()]) , (NablProp_multiplicity(), [ZeroOrOne()]) , (Type(), [NoValue()]) } ]
In SPT:
test type of Literal Int [[ [[1]] ]] run get-type to Int test type of Literal Float [[ [[1.4]] ]] run get-type to Float test type of literal String [[ [["Asdf"]] ]] run get-type to String test type of literal Datetime [[ [[2015-01-01 0:00:00]] ]] run get-type to Datetime test type of literal Datetime2[[ [[2015-12-31 23:59:59]] ]] run get-type to Datetime test type of literal No Value [[ [[no value]] ]] run get-type to NoValue
Will select:
"1" "1.4" String("Asdf") "2015-01-01 0:00:00" "2015-12-31 23:59:59" NoValue()
Note that
String
constructor is selected because"
and"
are part of theString()
concrete syntax, onlyAsdf
is lexical syntax.Currently there is no way to let the region selection favor
Int("1")
over"1"
. (And the behavior is different from old Spoofax.)I tried parenthesis:
test type of Literal Int [[ [[(1)]] ]] run get-type to Int
But parenthesis are not supported in region selection yet:
Could not resolve this selection.
N.B. Running
get-type
on"1"
,"1.4"
,"2015-01-01 0:00:00"
, and"2015-12-31 23:59:59"
throws a stacktrace:Unexpected error: rewriting failed get_multiplicity_0_0 get_property_0_1 get_index_property_0_1 nabl_uris_0_0 has_annos_0_0
N.B. (2) This is a different issue than https://yellowgrass.org/issue/SPTWithCore/7
Submitted by Daco Harkes on 12 January 2016 at 19:32
Issue Log
Note that the region selection in SPT does not support the ‘if fail then try parent’ logic which the hover builder does.
test type of Literal Int [[ [[1]] ]] run get-type-safe to Int
get-type-safe: a -> <get-type>a where not(is-string) //should obviously allow strings with annotations...
Results in:
Unexpected error: rewriting failed get_type_safe_0_0
This issue is fixed.
Log in to post comments