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

VSCODE / BAS Feature requests that would really help #82

Open
erlethor opened this issue May 7, 2020 · 7 comments
Open

VSCODE / BAS Feature requests that would really help #82

erlethor opened this issue May 7, 2020 · 7 comments

Comments

@erlethor
Copy link

erlethor commented May 7, 2020

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'}"
  1. 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
2. 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
3. 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
Copy link
Member

bd82 commented May 17, 2020

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;

  • Are there specifications for the binding expressions syntax?
  • Is this something you would like to try and contribute? (I can guide you in this).

@erlethor
Copy link
Author

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
Copy link
Contributor

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
Copy link
Member

bd82 commented Oct 7, 2021

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
Copy link
Contributor

MN-public commented Feb 17, 2023

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: LSP for PropertyBindingInfo #563 and Display description for property names in PropertyBindingInfo on hover #614

@MN-public
Copy link
Contributor

  1. LSP features for aggregation bindings LSP features for aggregation bindings #663

@MN-public
Copy link
Contributor

  1. Navigation to controller files Enable navigation to controller files #702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants