Giter Site home page Giter Site logo

disneystreaming / smithy-language-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smithy-lang/smithy-language-server

12.0 3.0 3.0 549 KB

A Language Server Protocol implementation for the Smithy IDL

Home Page: https://awslabs.github.io/smithy/

License: Apache License 2.0

Java 94.79% Scala 1.30% Shell 0.19% Smithy 3.71%

smithy-language-server's Introduction

smithy-language-server's People

Contributors

amazon-auto avatar baccata avatar daddykotex avatar jordonphillips avatar keynmol avatar kstich avatar kubukoz avatar milesziemer avatar nikhilrayala12 avatar renfraser avatar smithy-automation avatar srchase avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

smithy-language-server's Issues

Support stdio/stdout method of communication

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)

Opening a smithy file included via a dependency fails

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):

warning

Clicking on the issue attempt a jump to definition but can't open the file:

error-after-click

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.

when navigating to a smithy file in a jar, an exception is generated

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

Invalid references reported

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

Provide document outline (symbol information)

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:

image

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.

Typing out enum value in a trait will trigger a pop up until you have the right value

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.

Screen Shot 2022-03-25 at 09 37 56

This might also affect completion. We should be able to autocomplete the string, but as of right now, it does not work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.