IETS3 / iets3.opensource

Open Source Parts of IETS3
Apache License 2.0
44 stars 22 forks source link

core.expr: implement hex numbers #1074

Closed alexanderpann closed 2 weeks ago

alexanderpann commented 1 month ago

This is a more editor-heavy reimplementation of https://github.com/IETS3/iets3.opensource/pull/630 that is hopefully is not a breaking change anymore. There is only a small issue that when you create a hex value in the max field in the range specs the cursor jumps to the min field afterwards. I couldn't fix this issue but it is only a small inconvenience. See previous PR for a screenshot. The approach can be adapted for any string properties that are used for storing numbers.

Changes:

alexanderpann commented 3 weeks ago

How will this feature work with migrations?

When you set node.value you lose the hex value. I introduced a new method to also set the hex value. Example: node.updateHexValueOrProperty(property/NumberLiteral : value/, "100")

Using Hex-values is not propagated

Fixed.

Can we make auto-completion also work when someone enters only the string

I implemented it so that 0x0 is automatically inserted but that also feels awkward. Should we generate a new hex value with invalid value "" instead? If the user enters 0x the editor cell is red and he has to enter a value.

What direction do we want to enforce by default?

According to the internet, the evaluation from right to left as implemented here seems to be the standard. You can try it with different tools e.g. enter "0x0f in decimal" on Google.

Is there a possibility to automatically remove the hex-value?

The easiest way to remove it, is to write node.value = node.value

Can we per default switch this feature off

Done.

alexanderpann commented 2 weeks ago

@HeikoBecker Thanks for noticing. I fixed both issues.

arimer commented 2 weeks ago

@alexanderpann I think your merge went sideways. It looks like parts of the fixes introduced in commit a93b766a were removed/overriden. Could you please double check?

It is no longer possible to create hex value representations for min range of NumberRangeSpec and max range of CollectionSizeSpec. Also NumberLiterals are not supporting hex notation either.