A Language Server Protocol implementation for the Smithy IDL.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.
This project forked from smithy-lang/smithy-language-server
A Language Server Protocol implementation for the Smithy IDL
Home Page: https://awslabs.github.io/smithy/
License: Apache License 2.0
A Language Server Protocol implementation for the Smithy IDL.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.
I've spent a bit of time looking at various language servers and it seems that most support communication over the standard in/out.
It should be as simple as just providing System.in/System.out as InputStream and OutputStream to LSP launcher.
I propose we do this if the port argument is missing, to maintain backwards compatibility (tbh I don't know which method of communication is preferable/faster)
given the following smithy-build.json
file:
{
"mavenDependencies" : ["com.disneystreaming.smithy4s:smithy4s-protocol_2.13:latest.stable" ]
}
and a simple smithy definition file:
namespace smithy4s.hello
use smithy4s.api#simpleRestJson
@simpleRestJson
service HelloWorldService {
version: "1.0.0"
}
The VS code extension reports a problem coming from the smithy4s.smithy file (included in the downloaded jar). Note: this is possibly an error too. Clicking on the error will try to open a path that points to a jar.
The warning in question (may open another issue because I don't think it should be marked as an error):
Clicking on the issue attempt a jump to definition but can't open the file:
A solution would be to extract the file from the jar, after the click, but before the file opening, and open the extracted file instead. I think scalameta/metals does something similar.
It works, but we can see in the output the following exception:
[2022-02-22 14:40:17.444] [renderer6] [error] [Extension Host] stderr: Feb 22, 2022 2:40:17 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
"jsonrpc": "2.0",
"method": "textDocument/didClose",
"params": {
"textDocument": {
"uri": "smithyjar:/c%3A/Users/dfrancoeur/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/com/disneystreaming/smithy4s/smithy4s-protocol_2.13/0.12.2/smithy4s-protocol_2.13-0.12.2.jar%21/META-INF/smithy/smithy4s.smithy"
}
}
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
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)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
... 11 more
Caused by: java.lang.IllegalArgumentException: URI scheme is not "file"
at java.io.File.<init>(File.java:421)
at software.amazon.smithy.lsp.SmithyTextDocumentService.fileFromUri(SmithyTextDocumentService.java:333)
at software.amazon.smithy.lsp.SmithyTextDocumentService.fileUri(SmithyTextDocumentService.java:325)
at software.amazon.smithy.lsp.SmithyTextDocumentService.didClose(SmithyTextDocumentService.java:312)
... 16 more
The videos shows what happens:
Given smithy files like this:
# file 1
structure SomeStruc {
id: Session_Id
}
# file 2
@uuidFormat
string Session_Id
# file 3
/// Session data
structure Session {
account: Account,
identity: SessionIdentity
}
When hovering or clicking to definition on Session_Id
, it points to the file #3
Session structure instead
This would be a very welcome feature and (hopefully) a relatively quick win.
The point is to have go-to-symbol, e.g. here's something from a Scala file:
It looks connected to the "Outline View" in vscode, so hopefully implementing one resolves the other as well.
I believe it's this LSP endpoint: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
The document symbol request is sent from the client to the server. The returned result is either
SymbolInformation[] which is a flat list of all symbols found in a given text document. Then neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy.
DocumentSymbol[] which is a hierarchy of symbols found in a given text document.
given the following smithy definition
@trait(selector: "service")
structure compat {
@required
mode: CompatMode
}
@enum([
{ name: "BACKWARD", value: "BACKWARD" },
{ name: "FORWARD", value: "FORWARD" },
{ name: "NONE", value: "NONE" }
])
string CompatMode
Adding the trait to a service, and typing out {mode: "...NONE"}
you'll see tons of popup warning on the bottom right as you type the right value.
This might also affect completion. We should be able to autocomplete the string, but as of right now, it does not work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.