SAP / ui5-language-assistant

VSCode Extension and Editor Tooling for SAPUI5
Apache License 2.0
54 stars 25 forks source link

VSCODE / BAS Feature requests that would really help #82

Open erlethor opened 4 years ago

erlethor commented 4 years ago

Hi Colleagues,

Working for years with UI5 XML Views in the Fiori Elements library I would like to share my ideas about what would really be helpful in a UI5 XMLView assistant.

Navigation / go to definition (most helpful)

  1. In general: Any of the targets (js code, fragments) may be in the local repository (app as well as library repo), in a different cloned repository on the local machine, or is only in the "remote" ui5 distribution. It would be very helpful that the navigation would always try to find a local version and if not available locally go to the sapui5 documentation instead.

  2. Fragments. Ctrl/Cmd Click on a fragmentName reference should open the fragment in the editor. <core:Fragment fragmentName="sap.fe.templates.ObjectPage.view.fragments.HeaderImage" type="XML" />

  3. template:require / core:require should open the corresponding file if locally available or the sapui5 documentation if not.

    template:require="{
    macroLibrary: 'sap/fe/macros/macroLibrary',
    CORE: 'sap/fe/core/AnnotationHelper',
    MODEL: 'sap/ui/model/odata/v4/AnnotationHelper',
    ID: 'sap/fe/core/helpers/StableIdHelper'
    }"
    core:require="{FilterBarRuntime: 'sap/fe/macros/FilterBarRuntime'}"
  4. Navigate to controller (if it function starts with .) or static function defined by template:require / core:require. E.g. idPrefix="{= ID.generate([${this>id}, 'FilterFieldValueHelp']) }" should allow navigation to the function definition of generate() in sap/fe/core/helpers/StableIdHelper.js as defined in the template:require above. This should work no matter if it is about formatter, expression binding or event handler.

Type ahead / suggest (awesome)

It would be very helpful if auto suggest would work when typing all of the navigation examples.

1.<core:Fragment fragmentName=" would give a list of locally available fragments

  1. template:require: ' would give a list of classes defined locally or in ui5. Ideally path segment wise (first suggest of sap/, then sap/{second segement} and so on
  2. For event handlers, formatters and expression binding: Starting with the . would suggest functions from the controller. If it starts with a word defined in template:require or core:require it would suggest functions from that javascript file.

Syntax validation

A minimal syntax check for the following notations would help

  1. UI5 Binding for properties, aggregations or context binding, e.g. {path: 'entitySet>$Type', formatter: 'FIELD.getBindingForDraftAdminBlockInline'}
  2. UI5 Expression Binding visible="{= !${IsActiveEntity} || ${HasDraftEntity}}"

In the example 1. above, in case FIELD is not defined in either template:require or core:require` it should be marked as an error.

Parenthesis / Brackets / Curly Braces highlighting for

  1. UI5 Binding
  2. UI5 Expression Bindings

Thanks, Thorsten

bd82 commented 4 years ago

Thanks for the feedback @erlethor 👍

Navigation / go to definition (most helpful)

This seems very useful, it is also fairly complex as we currently do not yet any representation of the user's workspace in the extension, also some of this representation would require parsing JavaScript files while we (currently) only "understand" UI5 api.json files.

I am not saying this cannot be done, just noting the technical gaps.

Type ahead / suggest (awesome)

Similar to above the suggestions here seem to require expending the model we are working on, basically what we know of the user's workspace (custom libraries / JS files / other...).

Syntax validation Parenthesis / Brackets / Curly Braces highlighting for

The first step to adding any feature on for the "binding expressions" would be to parse these expressions.

For XML we build our own parser which has advanced features to support editor scenarios, e.g error recovery:

Questions;

erlethor commented 4 years ago

Thank you @bd82

The UI5 documentation is the only reference I know about bindings:

About the contribution. Although it would be very interesting I am afraid I won't find the time to actively contribute here.

mschleeweiss commented 3 years ago

BindingParser: https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/base/BindingParser.js ExpressionParser: https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/base/ExpressionParser.js

Can this somehow be ported to the language assistant? With some guidance I might try this myself @bd82

bd82 commented 2 years ago

Hello @mschleeweiss

It will likely be require more than a porting of said parser. I am not familiar with the specific ExpressionParser in UI5.

However, in general a parser meant to enable language service capabilities if often more complex than one that is only used to "compile" (transform) some input. The additional capabilities needed often include:

Basically if you want to implement advance capabilities such as content assist, tooltips, advanced highlights you often need to work on more low level (CST) and possibly incomplete data structures. In a compiler scenario it is much more simple, as you can stop on the first error, but in an editor scenario the features should (mostly) work even while the user is typing and the input in incomplete and invalid.

I don't know which of these capabilities the existing ExpressionParser has, but I suspect not all of them. For reference, to implement the XML related capabilities in the manifest.json we first had to implement a "smart" parser for XML capable of being using in a language server and related utilities.

MN-public commented 1 year ago

As this issue contains multiple feature requests, we should have smaller ones for each individual enhancement and link them to this one.

  1. minimal LSP features for PropertyBindingInfo: https://github.com/SAP/ui5-language-assistant/issues/563 and https://github.com/SAP/ui5-language-assistant/issues/614
MN-public commented 11 months ago
  1. LSP features for aggregation bindings https://github.com/SAP/ui5-language-assistant/issues/663
MN-public commented 5 months ago
  1. Navigation to controller files https://github.com/SAP/ui5-language-assistant/issues/702