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

Cannot use provided schemas #461

Closed
apupier opened this issue Jul 2, 2020 · 41 comments · Fixed by #488 or #490
Closed

Cannot use provided schemas #461

apupier opened this issue Jul 2, 2020 · 41 comments · Fixed by #488 or #490

Comments

@apupier
Copy link
Contributor

apupier commented Jul 2, 2020

when trying to use a specific schemas provided in preferences, when openign the file and asking for completion, there is this error:

eclipse.buildId=4.15.0.I20200305-0155
java.version=1.8.0_252
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.committers.product
Command-line arguments:  -data /home/apupier/ws/camel-ls -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.committers.product

This is a continuation of log file /home/apupier/ws/camel-ls/.metadata/.bak_5.log
Created Time: 2020-07-02 16:50:27.000

org.eclipse.lsp4e
Error
Thu Jul 02 16:56:59 CEST 2020
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request textDocument/completion failed with message: entry.getSchemas(...) is not a function or its return value is not iterable

java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request textDocument/completion failed with message: entry.getSchemas(...) is not a function or its return value is not iterable
	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
	at org.eclipse.lsp4e.operations.completion.LSContentAssistProcessor.computeCompletionProposals(LSContentAssistProcessor.java:105)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$10(AsyncCompletionProposalPopup.java:351)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$9(AsyncCompletionProposalPopup.java:350)
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
	at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request textDocument/completion failed with message: entry.getSchemas(...) is not a function or its return value is not iterable
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4e.LanguageServerWrapper.lambda$1(LanguageServerWrapper.java:243)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

tried with an URL and with a local file:

@mickaelistria
Copy link
Contributor

@vrubezhny Can you please have a look?

@mickaelistria
Copy link
Contributor

@apupier Can you please tell us the fully qualified version of org.eclipse.wildwebdeveloper.xml on your installation?

@apupier
Copy link
Contributor Author

apupier commented Jul 2, 2020

Can you please tell us the fully qualified version of org.eclipse.wildwebdeveloper.xml on your installation?

Wild Web Developer 0.10.0.202006021616 org.eclipse.wildwebdeveloper.feature.feature.group Eclipse Wild Web Developer project

@mickaelistria
Copy link
Contributor

Where do you find the preferences to add a JSON Schema?

@apupier
Copy link
Contributor Author

apupier commented Jul 9, 2020

Screenshot from 2020-07-09 16-32-08

@vrubezhny
Copy link
Contributor

@apupier I cannot reproduce the issue...
What I'm doing:

  • I saved the schema into my-schema.json file in my workspace project
  • In YAML Schemas preference page I created an association between the saved schema and *.camelk.yaml pattern
  • Created my-schema.camelk.yaml file, typed in - and pressed in order to invoke Content Assist stuff.

As result, the content assist is shown with no any exceptions:
Screenshot from 2020-07-09 17-28-04

Despite that fact that no exceptions produced, the suggested proposals, imho, don't follow the schema.
Please, look at steps to reproduce - am I acting correctly while trying to reproduce the issue?
Any corrections/suggestions/more clues?

@jeffmaury
Copy link
Contributor

I'm having the same issue with the POC I'm working on for jbosstools-quarkus.

@vrubezhny
Copy link
Contributor

vrubezhny commented Jul 9, 2020

I think, the reason I don't see in content assist proposals anything similar to what the schema defines is that YAML LS doesn't accept the schema with the following error:

{
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32601,
    "message": "Unsupported request method: custom/schema/content"
  }
}
{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "custom/schema/content",
  "params": "schemaservice:/home/jeremy/projects/runtime-wwd/HelloWorldTS/my-schema.json"
}

{
  "jsonrpc": "2.0",
  "method": "textDocument/publishDiagnostics",
  "params": {
    "uri": "file:///home/jeremy/projects/runtime-wwd/HelloWorldTS/my-schema.camelk.yaml",
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 0,
            "character": 0
          },
          "end": {
            "line": 0,
            "character": 1
          }
        },
        "severity": 1,
        "code": 768,
        "message": "Problems loading reference \u0027schemaservice:/home/jeremy/projects/runtime-wwd/HelloWorldTS/my-schema.json\u0027: Unable to load schema from \u0027schemaservice:/home/jeremy/projects/runtime-wwd/HelloWorldTS/my-schema.json\u0027: Unsupported request method: custom/schema/content."
      }
    ]
  }
}

@mickaelistria
Copy link
Contributor

Could be that a recent LS updates changes the operation.
We probably need some automated test to cover that feature if it's unstable on LS side.

@vrubezhny
Copy link
Contributor

vrubezhny commented Jul 9, 2020

@apupier There is one obvious error in your YAML Schemas preference page image: the path to schema must be project relative, not absolute, see: https://github.com/redhat-developer/yaml-language-server#associating-a-schema-to-a-glob-pattern-via-yamlschemas
So, if your schema is placed into the root of your project it probably must be specified as yaml-schema.json or ./yaml-schema.json in YAML Schemas preference page.
Could you please change your schema path to be project relative and try again with your example? At least, when I did so, the LS returned error I described above has gone. However the content assist doesn't seem to started to work though.
The exception is still not reproducible for me.

@jeffmaury What do you mean by "the same issue": the ResponseErrorException or not working properly content assistant?

@apupier
Copy link
Contributor Author

apupier commented Jul 10, 2020

There is one obvious error in your YAML Schemas preference page image: the path to schema must be project relative, not absolute, see: https://github.com/redhat-developer/yaml-language-server#associating-a-schema-to-a-glob-pattern-via-yamlschemas
So, if your schema is placed into the root of your project it probably must be specified as yaml-schema.json or ./yaml-schema.json in YAML Schemas preference page.

using VS Code, I was able to specify an absolute path.

Could you please change your schema path to be project relative and try again with your example?

I still have the same error with both yaml-schema.json or ./yaml-schema.json

@apupier
Copy link
Contributor Author

apupier commented Jul 10, 2020

please note that now the Camel K schema is part of json schema store so when testign might need to use different glob pattern SchemaStore/schemastore#1138

@jeffmaury
Copy link
Contributor

@vrubezhny I don't agree the schema should be specified using a URL, the file pattern is relative to the project.
And yes, I have the same error with getSchemas not being resolved when computing the completion items

@mickaelistria
Copy link
Contributor

I don't think the schema URL or not does matter, and attention should be focused on the Unsupported request method: custom/schema/content message. Where does this come from? I don't think it's something we call explicitly in the code; so is it coming directly from the LS (making the LS buggy here as it's not supposed to send unsupported operations randomly?).

@jeffmaury
Copy link
Contributor

This is the famous extension point from the LS we discussed in #318

@mickaelistria
Copy link
Contributor

But isn't this only with Quarkus tools? As far as I understand, plain Wild Web Developer doesn't have such issue then?

@jeffmaury
Copy link
Contributor

No the extension is from the LS and WWD does not implement this request thus the message.
Quarkus Tools wanted WWD to implement this custom request through an extension point that would be implemented by Quarkus Tools but my POC is using the solution you proposed (through didChangeConfiguration) but does not suffer from WWD not implemeting this custom message

@mickaelistria
Copy link
Contributor

So the message comes from the server to the client? Without a capability check? It then seems like a bug in the LS to me.

@vrubezhny
Copy link
Contributor

@jeffmaury

using VS Code, I was able to specify an absolute path.

I'm sure that YAML LS, when it resolves a schema, searches for it by a path that is relative to sourceRoot, so, as WWD doesn't modify a schema path specified in YAML Schemas pref. page, LS is to fail on using an absolute paths. In case of VsCode - they probably modify paths (to be project related) before sending them to the server. Probably we should have such a path conversion in WWD. (One problem here - as YAML Schemas pref. page is global for all the projects, I don't know how will it work in case a schema and according YAML file to be edited are placed in different projects)

Could you please change your schema path to be project relative and try again with your example?

I still have the same error with both yaml-schema.json or ./yaml-schema.json

Could you please tell what YAML LS version it installed? Recently we have updated it to be 0.8.0, and I suppose that WWD 0.10.0 still uses 0.6.1 - this probably is a reason why I cannot reproduce the error with getSchemas

@jeffmaury
Copy link
Contributor

Yes I'm using 0.6.1 because it's the one WWD is shipping. The YAML LS doc clearly states that the schema specification is through an URL and relative applies to file pattern

@vrubezhny
Copy link
Contributor

vrubezhny commented Jul 10, 2020

Yes I'm using 0.6.1 because it's the one WWD is shipping. The YAML LS doc clearly states that the schema specification is through an URL and relative applies to file pattern

"yaml.schemas applies a schema to a file. In other words, the schema (placed on the left) is applied to the glob pattern on the right. Your schema can be local or online. Your schema path must be relative to the project root and not an absolute path to the schema."
YAML LS Sources proves that schema file must be project relative: https://github.com/redhat-developer/yaml-language-server/blob/master/src/languageservice/services/yamlSchemaService.ts#L111

Anyway, it looks we're looking at different versions and seeing the different issues...
@apupier @jeffmaury, could you please install WWD from the latest snapshots and see if it fixes 'getSchemas` LS Error and if the schemas start actually work on YAML Editor.
Regardless of absolute/relative file stuff, if a schema is specified as an URL - it should be loaded.

@jeffmaury
Copy link
Contributor

jeffmaury commented Jul 10, 2020

I tried with snapshots and code assist is now working correctly.
Here is the settings that I set:
image

@mickaelistria
Copy link
Contributor

Thanks for the feedback @jeffmaury !
In the meantime, we've been chatting about it with Victor and we believe that YAML-LS should support absolute path as well, since a yaml file isn't necesarily attached to a project; and since one could imagine having conflicting schemas for the same glob pattern when using multiple projects with same file layout/names. Absolute path would allow to remove all form of confusion for those cases. AFAIK, @vrubezhny is going to open an issue to YAML-LS.

@vrubezhny
Copy link
Contributor

@jeffmaury Glad to see the content assist is working correctly for you. Thanks for the feedback!
I've opened the issue against YAML-LS project in order to add support for absolute paths for schemas: redhat-developer/yaml-language-server#275

@JPinkney
Copy link

I'm a little bit confused on a few things. First for:

  "jsonrpc": "2.0",
  "id": 0,
  "method": "custom/schema/content",
  "params": "schemaservice:/home/jeremy/projects/runtime-wwd/HelloWorldTS/my-schema.json"
}

the only way that should appear is if a yaml/registerCustomSchemaRequest is sent on the client side. Was this done? because typically schemas are only prefixed like this when using that feature schemaservice:/home/jeremy/projects/runtime-wwd/HelloWorldTS/my-schema.json. Otherwise there's no reason to send the schemaservice prefix AFAIK. If it wasn't done then please file an issue on the yaml-language-server.

Also what are the workspace folders sent/workspaceRoot? We use those to turn the relative paths into absolute paths

@vrubezhny
Copy link
Contributor

vrubezhny commented Jul 13, 2020

The schemas are set here by invocation of org.eclipse.lsp4j.services.WorkspaceService.didChangeConfiguration(DidChangeConfigurationParams)

On yaml/registerCustomSchemaRequest and sent/workspaceRoot - I can't find out it to be sent right now neither in org.eclipse.wildwebdeveloper.yaml.YAMLLanguageServer, nor in YAML LS logs generated with trace=verbose`. So, probably it's not configured, however, when I specify a project related path for a schema, it gets loaded with no error messages, so I believe we have only problem using absolute paths.

But even if we configure something like workspaceRoot and place some schema in a directory that is placed out of specified workspace - will the setting of workpaceRoot solve the problem?
Actually I don't believe that setting of workspaceRoot would help if YAML LS doesn't use Eclipse's Workspace API to calculate absolute paths.

@vrubezhny
Copy link
Contributor

@JPinkney Here is my YAML LS log for a opening and closing the YAML Editor when a schema is specified by an absolute path:
org.eclipse.wildwebdeveloper.yaml.log

@JPinkney
Copy link

Interesting, if I have time I'll set things up and debug but I can't guarentee any timeline

@JPinkney
Copy link

Is there any documentation on how to set everything up/contribute? I'm not really familiar with eclipse desktop ide projects

@vrubezhny
Copy link
Contributor

In general, you need:

  • openjdk-11 (with sources) installed ,
  • Eclipse SDK + eclipse-test-framework-4.16.zip
  • cd ~/projects/ (or whereever you save your projects)
    git clone https://github.com/eclipse/wildwebdeveloper.git
    (if needed) git clone git://git.eclipse.org/gitroot/lsp4e/lsp4e.git
  • some really simple test project with json schema (like described above)
  • Install Eclipse, install eclipse-test-framework into it (might help in building/running tests), import (in simple case) all wildwebdeveloper plugin projects, (if needed) you might import all jsp4e plugns.
  • Build WWD Target Platform (cd ~/projects/wildwebdeveloper/target-platform/; mvn clean install;) and set it as your Eclipse's target platform (open in Eclipse wildwebdeveloper/target-platform/target-platform.target file and check it's installed in Window - Preferences -> Plug-in Development -> Target Platform preference page.
  • Build WWD itself (cd ~/projects/wildwebdeveloper//; mvn clean install;)
  • Create Run/Debug 'Eclipse Application" configuration and start it.
  • Then, in started application, create or import some simple test project (with json schema and a yaml file) and configure in `Window -> Preferences -> YAML -> YAML Schemas' your schema and a global pattern.
  • That's it... You can open your yaml file in editor and see the server logs.
  • One more thing to configure: yaml server logs: Window -> Preferences -> Language Servers -> Logs, enable the required either Log to File or Log to Console or both. There will be a new project created in your workspace named after languageServers-log - you may find a link on the same preference page. Also, you can import it into you workspace and always have the logs handy.
    Quite simple :)

@mickaelistria
Copy link
Contributor

Thanks for those details @vrubezheny!
It would be great if you could add such hints directly into some CONTRIBUTING.md file.

@JPinkney
Copy link

I never get custom/schema/context at all in the logs but I can produce one issue.

Testing scenarios

I've set everything up, started the node process built from redhat-developer/yaml-language-server@3cdc18b and starting playing around with it. Absolute paths worked for me with one project in the workspace:

test/
    test.yaml

with:

schema: /home/joshpinkney/Documents/Work/Schemas/composer.json
glob pattern: test.yaml

Additionally, I was able to add composer.json to my workspace so that it was

test/
    composer.json
    test.yaml

and then I was able to do:

schema: composer.json
glob pattern: test.yaml

and everything worked successfully.

I think the issue is with:

[t=1594754457856] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":6666,"rootPath":"/home/joshpinkney/runtime-EclipseApplication/test/","rootUri":"file:///home/joshpinkney/runtime-EclipseApplication/test/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"],"failureHandling":"undo"},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true,"documentationFormat":["markdown","plaintext"]}},"hover":{"contentFormat":["markdown","plaintext"]},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{"valueSet":[18,17,5,14,9,10,22,24,8,1,12,11,20,6,2,3,21,16,19,25,4,7,15,23,26,13]},"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{},"definition":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{},"documentLink":{},"colorProvider":{},"rename":{}}},"clientName":"Eclipse Platform","trace":"off"}}

LSP4E seems to be passing in a rootUri and not workspaceFolders despite there being multiple roots in the project which probably leads into an issue on the language server-side. The YAML language server uses either rootURI or workspaceFolders as its root when building up relative pathing and only checks these at initialization. That means, that if you open a YAML file and
the language server gets initialized, the language server will be using that root to construct relative schemas, since only rootURI is set. Meaning that any other project in your eclipse workspace won't be able to use relative schemas (unless you set them relative to the original root).

I was able to verify this by doing:

test/
   composer.json
   test.yaml
test2/
   test2.yaml

opening up test2.yaml first and then setting:

schema: ../test/composer.json
glob pattern: test.yaml

The fix

I assume that LSP4E will send the correct workspaceFolder events after initialization so the solution is make the YAML language server react to workspaceFolder events.

The other things that came up

I still haven't been able to produce:
entry.getSchemas(...) is not a function or its return value is not iterable
or
custom/schema/content requests

I have a feeling though both of these have been fixed a lonngggg time ago and its caused by issues in an old version of the language server

@vrubezhny
Copy link
Contributor

@JPinkney I agree, The issue could be in not provided WorkspaceFolder's list... However, when I tried to send those:

{"jsonrpc":"2.0","method":"workspace/didChangeWorkspaceFolders","params":{"event":{"added":[{"uri":"file:/home/jeremy/projects/runtime-wwd/HelloWorldJSP"},{"uri":"file:/home/jeremy/projects/runtime-wwd/HelloWorldTS"}],"removed":[]}}}

...I didn't get any changes in behaviour - I still see the same error:

{"jsonrpc":"2.0","id":0,"error":{"code":-32601,"message":"Unsupported request method: custom/schema/content"}}

But even with no WorkspaceFolders set, just having rootUri and rootPath initialized (both) to point to my project folder (I don't know why lsp4e does so - I supposed these should point to a workspace root, not a project root, but...), like:

"rootPath":"/home/jeremy/projects/runtime-wwd/HelloWorldTS/",
"rootUri":"file:///home/jeremy/projects/runtime-wwd/HelloWorldTS/"

...yaml ls should be able to calculate the correct path to the schema:

"schemas":{"/home/jeremy/projects/runtime-wwd/HelloWorldTS/yaml-schema.json":"/my-schema.camelk.yaml"}

...but it still cannot find the schema.

Others:

entry.getSchemas(...) is not an issue anymore after the upgrade to 0.80.0 (and 0.90.0 as well).

@JPinkney
Copy link

Unfortunately, I'm still unable to reproduce.

I've tested a bunch of schema configuration settings and still cannot reproduce "Unsupported request method: custom/schema/content" and setting it with absolute paths worked on my side. I followed #461 (comment) exactly (I never even had eclipse installed on the machine I was testing on before so there wasn't anything previous installed here) and the only thing I did was update the version of yaml-language-serer to 0.9.0. Though I'm pretty sure with 0.8.0 I would have had the same results. These were the configurations I was using to test:

[t=1595285516341] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":29406,"rootPath":"/home/joshpinkney/runtime-EclipseApplication/test/","rootUri":"file:///home/joshpinkney/runtime-EclipseApplication/test/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"],"failureHandling":"undo"},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true,"documentationFormat":["markdown","plaintext"]}},"hover":{"contentFormat":["markdown","plaintext"]},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{"valueSet":[18,17,5,14,9,10,22,24,8,1,12,11,20,6,2,3,21,16,19,25,4,7,15,23,26,13]},"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{},"definition":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{},"documentLink":{},"colorProvider":{},"rename":{}}},"clientName":"Eclipse Platform","trace":"off"}}

Test 1:
[t=1595285516345] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"yaml":{"completion":true,"hover":true,"schemas":{"../test/composer.json":"test.yaml"},"validate":true}}}}

Test 2:
[t=1595285636583] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"yaml":{"completion":true,"hover":true,"schemas":{"composer.json":"test.yaml"},"validate":true}}}}

Test 3:
[t=1595285845705] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"yaml":{"completion":true,"hover":true,"schemas":{"/home/joshpinkney/Documents/Work/Schemas/t.json":"test.yaml"},"validate":true}}}}

Test 4:
[t=1595286175162] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"yaml":{"completion":true,"hover":true,"schemas":{"/home/joshpinkney/Documents/Work/Schemas/composer.json":"/test.yaml"},"validate":true}}}}

Workspace folder handling has been merged but won't be available until a future release so that stuff still won't be working. BTW what are the contents of "/home/jeremy/projects/runtime-wwd/HelloWorldTS/yaml-schema.json" ? Perhaps the schema is just invalid? Does it work when you set it in VSCode for example?

@vrubezhny
Copy link
Contributor

@JPinkney I can confirm. It looks like I had something cached somehow inside LS after update to 0.90.0. so, I don't see Unsupported request method: custom/schema/contenterror at the moment. (With YAML LS v.0.90.0).

The schema file I'm testing with is downloaded from https://gist.githubusercontent.com/lburgazzoli/5b860fdad50d372a27fc51306f1ae378/raw/addea32147720a41ff58aa82e1ec845dae6ab77c/camel-yaml-dsl.json

However there are still few problems with schemas:

  • It looks like getInitialOptions() doesn't allow to set any schemas. I believe it doesn't work for WorkspaceFolder-s as well.
  • "initialize" is received only once, so the rootPath and rootPath are set to point to the project of the first YAML-file. Which doesn't look correct. Imho, more correctly is to point rootPath and rootUri to workspace (and provide a list of WorkspaceFolder-s) - probably it's a problem of how WWD configures a LS. (@JPinkney could you please comment on this?)
  • Providing a list of WorkpaceFolder-s probably helps, but I don't see any difference (working with or without providing such a list). BTW, which folders are to be included - every folder of every workspace project or just the first level project folders (aka top-level projects)?

@JPinkney
Copy link

It looks like getInitialOptions() doesn't allow to set any schemas

WDYM? I'm not sure where getInitialOptions is from

Imho, more correctly is to point rootPath and rootUri to workspace (and provide a list of WorkspaceFolder-s) - probably it's a problem of how WWD configures a LS.

It seems to me like this is the way it should behave but I'm not sure if every language server has support for workspaceFolders yet so maybe its feasible yet

Providing a list of WorkpaceFolder-s probably helps, but I don't see any difference (working with or without providing such a list)

In a future release of the yaml-language-server all of the schemas will use either workspaceFolders (if available) or the rootUri to construct schema paths. Anytime workspaceFolders is added/removed the mapping of the schemas will re-generate automatically on the language server side

BTW, which folders are to be included - every folder of every workspace project or just the first level project folders (aka top-level projects)?

I think it would just include all of the projects that are listed at the root of your workspace

@vrubezhny
Copy link
Contributor

It looks like getInitialOptions() doesn't allow to set any schemas

WDYM? I'm not sure where getInitialOptions is from

It's used to provide initialization options on the start of a language server (org.eclipse.lsp4j.InitializeParams.setInitializationOptions(Object) The output that contains the options returned by getInitialOptions() can be seen amount the initialize request params sent to the LS, like:

[t=1595300664178] LSP4E to org.eclipse.wildwebdeveloper.yaml:
{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":1039611,"rootPath":"/home/jeremy/projects/runtime-wwd/HelloWorldTS/","rootUri":"file:///home/jeremy/projects/runtime-wwd/HelloWorldTS/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"],"failureHandling":"undo"},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true,"documentationFormat":["markdown","plaintext"]}},"hover":{"contentFormat":["markdown","plaintext"]},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{"valueSet":[18,17,5,14,9,10,22,24,8,1,12,11,20,6,2,3,21,16,19,25,4,7,15,23,26,13]},"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{},"definition":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{},"documentLink":{},"colorProvider":{},"rename":{}}},"clientName":"Eclipse Platform","trace":"off"}}

So, it's logical to set initial configuration for the schemas and WorkspaceFolder list at initialize. In this ^^^ output there is no schemas={} part because I removed the schemas and folders from the initialization as they accepted (at least don't generate any errors), but looks like not used by the LS if provided here (no content assist is working for schemas).

Imho, more correctly is to point rootPath and rootUri to workspace (and provide a list of WorkspaceFolder-s) - probably it's a problem of how WWD configures a LS.

It seems to me like this is the way it should behave but I'm not sure if every language server has support for workspaceFolders yet so maybe its feasible yet

OK. Thanks. I'll try to override and send rootPath and rootUri pointing to the workspace root instead (in conjunction with the setup of a set of Workspace Folders)

Providing a list of WorkpaceFolder-s probably helps, but I don't see any difference (working with or without providing such a list)

In a future release of the yaml-language-server all of the schemas will use either workspaceFolders (if available) or the rootUri to construct schema paths. Anytime workspaceFolders is added/removed the mapping of the schemas will re-generate automatically on the language server side

BTW, which folders are to be included - every folder of every workspace project or just the first level project folders (aka top-level projects)?

I think it would just include all of the projects that are listed at the root of your workspace

OK thanks I'll try sending the only root project folder list (as sending of every workspace, imho, folder might generate a big overload at initialization steps)

vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 21, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 21, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 21, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
@vrubezhny
Copy link
Contributor

Well, Currently I can't find a way to override/change the way LSP4E initializes rootUri/rootPath for YAML LS,
I filed a bug with a question: https://bugs.eclipse.org/bugs/show_bug.cgi?id=565390 to LSP4E.
@mickaelistria Could you please comment on this?

@JPinkney
Copy link

So, it's logical to set initial configuration for the schemas and WorkspaceFolder list at initialize. In this ^^^ output there is no schemas={} part because I removed the schemas and folders from the initialization as they accepted (at least don't generate any errors), but looks like not used by the LS if provided here (no content assist is working for schemas).

I think what VSCode does is after initialize happens then they send didChangeConfiguration to basically sync the editor settings with the language server. You might be able to try something like that

@mickaelistria
Copy link
Contributor

Eclipse LSP4E can be improved on that matter.
However, I think it's usually best if the LS doesn't rely on rootUri or workspaceFolders to work.

vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 22, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
@vrubezhny
Copy link
Contributor

So, it's logical to set initial configuration for the schemas and WorkspaceFolder list at initialize. In this ^^^ output there is no schemas={} part because I removed the schemas and folders from the initialization as they accepted (at least don't generate any errors), but looks like not used by the LS if provided here (no content assist is working for schemas).

I think what VSCode does is after initialize happens then they send didChangeConfiguration to basically sync the editor settings with the language server. You might be able to try something like that

That's what I finally did: I'm sending the initial schemas and set of folders when 'initialize" response is received, After that resource change listener sends the changes in WS folders, while Preference change listener reports the changes in schemas.
I just expected the initial schemas and folders are to be accepted right at server creation (before it responded with InitializeResult message. But probably it's not that important as it works with didChangeConfiguration/didChangeWorkspaceFolders after the initialization.

vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 22, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 22, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 22, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 23, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 23, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
mickaelistria pushed a commit that referenced this issue Jul 23, 2020
Fixes: #461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 23, 2020
Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit to vrubezhny/wildwebdeveloper that referenced this issue Jul 23, 2020
Fixed preferernce listener installation

Fixes: eclipse-wildwebdeveloper#461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
vrubezhny added a commit that referenced this issue Jul 23, 2020
Fixed preferernce listener installation

Fixes: #461

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants