Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App/Gui: Refactor expression completer and unit expressions #3062

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from

Commits on Mar 17, 2022

  1. Spreadsheet: change alias handling

    No longer add dynamic property for alias, simply rely on
    get(Dynamic)PropertyByName() to check for aliases.
    
    Add new API PropertyContainer::getPropertyNamedList() so that
    ExpressionCompleter can discover properties with aliases.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    1cb40ca View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    242f372 View commit details
    Browse the repository at this point in the history
  3. App: support new sub object referencing syntax in expression

    The previous syntax for sub-object referencing is kind of awkward, but
    is unambiguious nevertherless.
    
    The new syntax allows referencing sub-object like,
    
        Part.Origin.X_Axis
    
    which may be ambiguious in case there is also a (existing or future
    added dynamic) property named 'Origin'. The expression parser will
    automatically convert this more natural syntax to the unambiguous one
    like,
    
        Part.<<Origin.X_Axis.>>
    
    The new syntax works for label reference as well,
    
        <<Part>>.<<Part001>>.<<Cube>>
    
    which will be converted to
        <<Part>>.<<$Part001.$Cube.>>
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    935b926 View commit details
    Browse the repository at this point in the history
  4. Gui: refactor ExpressionCompleter

    Make use of the more user friendly sub-object referecing syntax.
    
    Refectored ExpressionCompleterModel to support completing Python
    attributes, using CallTipsList::extractTips().
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    bb9ea11 View commit details
    Browse the repository at this point in the history
  5. App: change Property::getPaths() and getPyPathValue()

    Since ExpressionCompleter will now look into Python attributes, there
    is no need to expose duplicated information through getPaths(), except
    those that provides extra information (e.g. Rotation.Angle with extra
    unit information)
    
    getPyPathValue() is modified to return Python attributes after the
    given path.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    320f71b View commit details
    Browse the repository at this point in the history
  6. Gui: catch Py::Exception

    The Python exception is supposed to be captured by application code. If
    it is somehow leaked, it may cause system instability.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    d16d4cf View commit details
    Browse the repository at this point in the history
  7. Base/App: refactor expression unit parsing

    Before this patch, the definitions of unit are somewhat duplicated in
    several places, Base/QuantityParser.l, App/ExpressionParser.l,
    Base/Quantity.cpp, App/FreeCADInit.py, etc.
    
    This patch remove all duplications (that I can found), and put them all
    inside function Base::Quantity::unitInfo(). Here is how other code
    obtain the definition,
    
    Base/QuantityParser.l calls Quantity::fromUnitString() and resolved the
    unit at parsing time.
    
    App/ExpressionParser.l treats unit token as IDENTIFIER, and let the
    expression parser (ExpressionParser.y) to decide whether to resolve the
    unit at parsing time (by calling UnitExpression::create()), and create
    a VariableExpression and resolve the unit at runtime (if there is no
    property found with the same name).
    
    App/FreeCADUnit.py expose Python predefined units using
    App.Units.listPredefinedUnits/listUnitTypes(), which are implemented in
    UnitsApiPy.cpp.
    
    The benifit of moving unit token parsing out of expression lexical
    scanner is that we can safely introduce new unit keyword without any
    risking of breaking backward compatibility. Because the lexical scanner
    will not mistakenly treat any identifier in existing expression as unit
    because of name clash. In does introduce some side effect as the unit
    may or may not be resolved at parsing time. For example, an expression
    '1m/s' may be evaluated to different results depending on whether there
    is a property named 's'. To avoid this, the user can opt to bracket the
    unit expression, like '1(m/s)'.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    d91c1e3 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    bf6e41e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0782ef7 View commit details
    Browse the repository at this point in the history
  10. Gui: add some icons

    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    8efdf2d View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    f2ef38a View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    685e230 View commit details
    Browse the repository at this point in the history
  13. App: add ObjectIdentifier pseudo property _ref

    To return a (sub)object reference that is suitable for assignment to
    link type property
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    b4bed4c View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    4a6c85e View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    89c1a10 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    da7b591 View commit details
    Browse the repository at this point in the history
  17. App: fix unintialized variable bug in ObjectIdentifier

    This must be the cause of mysterious test failure on Travis!
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    5e0fc73 View commit details
    Browse the repository at this point in the history
  18. Spreadsheet: relax alias naming restriction

    Because there is now a way to resolve name clash with unit.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    67af184 View commit details
    Browse the repository at this point in the history
  19. App: fix ObjectIdentifier behavior when copying without dependency

    Object reference will be auto converted to external or internal
    reference depending on whether the referenced object is exported
    together or not.
    
    Related FreeCAD#2477
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    5cab396 View commit details
    Browse the repository at this point in the history
  20. App: fix ObjectIdentifier map indexing

    Support old syntax of map indexing for backward compatibility,
    
        Obj.PropertyMap.<<key>>
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    6321ffc View commit details
    Browse the repository at this point in the history
  21. Sketcher: fix PropertyConstraintList::canonicalPath()

    For named constraint with space.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    9750fed View commit details
    Browse the repository at this point in the history
  22. Gui: fix build warning

    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    3bba14a View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    10aa7ad View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    9580de4 View commit details
    Browse the repository at this point in the history
  25. Base: improve Quantity parser

    Add Quantity::concat() to handle quantity concatenation, which can
    either be plus or minus depending on the signedness of the left
    quantity.
    
    1m1mm is interpreted as 1m plus 1mm,
    
    -1m1mm means -1m minus 1mm.
    
    -1m-1mm means -1m minus -1mm, i.e. -1m plus 1mm.
    
    (0-1)m-1mm means -1m minus -1mm, i.e. -1m plus 1mm.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    7750f5e View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    fdd5c1f View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    b450f43 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    f832bfc View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    cf8b1e0 View commit details
    Browse the repository at this point in the history
  30. Gui: do not report error on incomplete expression

    That is, to supress 'unexpected end of input' ParserError.
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    1476c38 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    e808537 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    8555cd4 View commit details
    Browse the repository at this point in the history
  33. App: improve ObjectIdentifier resolve()

    Try to resolve as much information as possible
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    8b49772 View commit details
    Browse the repository at this point in the history
  34. Gui: improve ExpressionCompleter

    Support 'MatchContains' on sub-object/property/attribute
    Fix sub-object/element references
    realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    3fddd56 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    a7cba97 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    25cca0f View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    301feaf View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    9aa7f29 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    b05a06d View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    81333ac View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    e50864d View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    ed576de View commit details
    Browse the repository at this point in the history
  43. Fix various typos in PR

    luzpaz authored and realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    e52ee97 View commit details
    Browse the repository at this point in the history
  44. Fix additional typos

    luzpaz authored and realthunder committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    1f23e8e View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2022

  1. Configuration menu
    Copy the full SHA
    5d267d0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    567409a View commit details
    Browse the repository at this point in the history
  3. App/Sketcher: fix sketch constraint renaming

    In case either and new or old name contains space
    realthunder committed Mar 18, 2022
    Configuration menu
    Copy the full SHA
    4ad94ae View commit details
    Browse the repository at this point in the history
  4. Base: do not report exception in Base::PyException::ThrowException()

    Because user code may want to silence the exception
    realthunder committed Mar 18, 2022
    Configuration menu
    Copy the full SHA
    0c39584 View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2022

  1. Configuration menu
    Copy the full SHA
    d531d55 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ad9cf27 View commit details
    Browse the repository at this point in the history