winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.04k stars 196 forks source link

vscode no suggestions on extern syntax #4002

Open staycoolcall911 opened 1 year ago

staycoolcall911 commented 1 year ago

I tried this:

Add an extern function. There's no way for me to figure out the syntax unless I copy it from an example or the language reference. My code:

bring cloud;

class GDPRService {
  api: cloud.Api;
  bucket: cloud.Bucket;

  extern
          // ^ cursor here

  init() {
    this.api = new cloud.Api();
    this.bucket =  new cloud.Bucket();
    this.api.post("/doc/{id}", inflight (req) => {
      let id = req.vars.get("id");
      let origin = Json.stringify(req.body);
      this.bucket.put("origin${id}.txt", origin);
    });
  }
}

This happened:

No completion for the extern syntax: image

I expected this:

To get a guiding docstring or syntax completion.

Is there a workaround?

No response

Component

IDE Extension

Wing Version

0.26.7

Node.js Version

18.15.0

Platform(s)

MacOS

Anything else?

No response

Community Notes

MarkMcCulloh commented 11 months ago

@eladb Originally wanted the syntax for extern to be extern("path") instead of extern "path".

I didn't like this because it felt strange to introduce a function-call-esque modifier that didn't match other modifiers. I still feel this way, but it's not like the current method is any less unique (in a bad way). Now that we've had it for a while, pragmatically I think it makes sense to change it to extern("path") instead.

It also makes this issue significantly easier to implement. This syntax change shouldn't be difficult and IMO can be implemented as part of this issue

Chriscbr commented 8 months ago

I'm not sure not having a completion is a bug per se (an LSP can't come up with every possible thing you can type at every position in your code), but otherwise I agree with what Mark said above.

As a related improvement, if you write

class A {
  extern foo(): str;
}

It will help if we provide a helpful syntax error, like "Missing file name after extern. Try extern "./file.js" " instead of "Unknown parser error"

github-actions[bot] commented 5 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 1 month ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!