ui5-tooling icon indicating copy to clipboard operation
ui5-tooling copied to clipboard

No code suggestions/auto-completion for `ui5.yaml` based on JSON schema

Open pubmikeb opened this issue 4 years ago • 9 comments

For SAP UI5 Tooling ui5.yaml there is a JSON schema https://sap.github.io/ui5-tooling/schema/ui5.yaml.json, which is supposed to assist when working with ui5.yaml.

The problem is that this schema doesn't provide a code suggestions/auto-completion aka IntelliSense. More precisely, it does it but only for the two items: specVersion and kind:

13_162203

And when I chose specVersion, it suggests me a version number: 2.5, 2.4, etc. But when I chose one of the proposed values, it turns out that it's specVersion: 2.5 instead of required specVersion: "2.5", so the specVersion is proposed as a number rather than a string.

For the rest of the items there is no suggestions at all.

Context

  • UI5 Module Version (output of ui5 --version when using the CLI): "@ui5/cli": "^2.12.1"
  • Node.js Version: 16.9.1
  • npm Version: 7.23.0
  • OS/Platform: Winndows 10 x64 21H1

pubmikeb avatar Sep 13 '21 14:09 pubmikeb

Once you declared a specification version greater than 2 (e.g. specVersion: "2.5"), additional suggestions should come up. Can you confirm that?

It's indeed an issue that the autocompletion does not put the version number into quotes. I'm not sure whether this is an issue with the schema or the way we validate it though.

RandomByte avatar Sep 20 '21 09:09 RandomByte

Can you confirm that?

No! That's the point, no suggestions appear:

20_222203

It's indeed an issue that the auto-completion does not put the version number into quotes. I'm not sure whether this is an issue with the schema or the way we validate it though.

It's a schema problem, there is a need to add "type": "string" to the specVersion definition:

"specVersion": {
  "enum": [
    "2.5",
    "2.4",
    "2.3",
    "2.2",
    "2.1",
    "2.0",
    "1.1",
    "1.0",
    "0.1"
  ],
  "type": "string",
  "errorMessage": "Unsupported \"specVersion\"\nYour UI5 CLI installation might be outdated.\nSupported specification versions: \"2.5\", \"2.4\", \"2.3\", \"2.2\", \"2.1\", \"2.0\", \"1.1\", \"1.0\", \"0.1\"\nFor details see: https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions"
}

pubmikeb avatar Sep 20 '21 20:09 pubmikeb

Can you confirm that?

No! That's the point, no suggestions appear:

20_222203

This I cannot reproduce. Once a spec-version >2 is set, suggestions work with the LSP-yaml plugin for Sublime Text: Screenshot 2021-09-22 at 14 05 32

May I ask which IDE (and schema-plugin, if any) you are using?

It's a schema problem, there is a need to add "type": "string" to the specVersion definition:

Thanks! We will look into it 👍

RandomByte avatar Sep 22 '21 12:09 RandomByte

May I ask which IDE (and schema-plugin, if any) you are using?

IntelliJ IDEA 2021.2.2

Schema file: https://sap.github.io/ui5-tooling/schema/ui5.yaml.json

What do you mean under «schema-plugin»?

pubmikeb avatar Sep 22 '21 18:09 pubmikeb

@matz3 could you look into the missing "type": "string" declaration mentioned in https://github.com/SAP/ui5-tooling/issues/560#issuecomment-923271887 ?

I asked @svbender to check whether he can reproduce the missing suggestions in WebStorm

RandomByte avatar Sep 28 '21 08:09 RandomByte

Even when adding "type": "string", the auto-suggestion (via https://github.com/redhat-developer/yaml-language-server) uses a number. So this seems to be a bug in the yaml-language-server.

@pubmikeb can you confirm that adding "type": "string" solves this problem in your IDE?

matz3 avatar Sep 28 '21 10:09 matz3

Can you confirm that adding "type": "string" solves this problem in your IDE?

I've tested the case on two file types:

  1. On JSON-file, there everything is OK:

28_224142

  1. On YAML-file, there "type": "string" doesn't ensure a string-type for the proposed value.

P.S. What is the added-value to use YAML over JSON as a config file for UI5 Tooling?

pubmikeb avatar Sep 28 '21 20:09 pubmikeb

I have tested the schema with WebStorm and can reproduce the issues.

  1. If you start with an empty ui5.yaml the IDE proposes to add the missing requirements specVersion and type, if I accept it, they are added with 1 indentation (2 spaces) which results in further confusion because there is no auto-completion for both and on top level the auto-completion suggests another specVersion entry. You need to remove the spaces.

  2. Auto-completion suggestions for kind are working but not for type. The good thing is that in the "Problems" tab/window of the IDE all possible enum values are shown correctly. For example: Schema validation: Value should be one of: "application", "library", "theme-library", "module"

  3. The specVersion string handling is not working as expected. Auto-completion is showing all available versions but they are not added with quotes.

    • Adding "type":"string" to specVersion in the schema has no effect beside that the IDE shows the problem Schema validation: Incompatible types. Required: string. Actual: number.. The quotes are not added automatically.
    • Adding single quotes in the schema works, but had the effect that the validator is not able to recognize the value even if it is in the enum list: Schema validation: Value should be one of: "2.5", "'2.4'", "2.3", "2.2", "2.1", "2.0", "1.1", "1.0", "0.1"

I think this issues are related to the IDE and the used parser.

WebStorm/IntelliJ is not using a separate plugin for that, it is a built-in feature. The schema is used automatically from https://www.schemastore.org/json/ , but you can overwrite the usage in the configuration: https://www.jetbrains.com/help/ruby/yaml.html#remote_json (It should be the same configuration for all IntelliJ based IDEs.)

svbender avatar Sep 29 '21 09:09 svbender

I've opened a ticket at WebStorm: https://youtrack.jetbrains.com/issue/WEB-52885

pubmikeb avatar Sep 29 '21 16:09 pubmikeb

Closing, as it's a third-party issue.

matz3 avatar Feb 21 '23 10:02 matz3