question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

discussion: multi registry import IntelliSense

See original GitHub issue

We added support for IntelliSense autocomplete a week ago. It only has support for deno.land/x right now. I would like this feature to support more registries (like nest.land or jspm.dev). This is currently not practical to do because each registry requires a separate code path in the extension.

As a solution to this I propose a dynamic import IntelliSense that is not specific to any one registry. You should be able to dynamically add more registries without updates to the VS Code Deno extension.

How does this work for the user?

All registries that want to support this feature must host a /.well-known/deno-import-intellisense.json file on their domain (contents of this file are described below). The extension will request this file when it encounters a domain in an import statement for the first time. If the extension finds this file and recognizes the syntax, a popup is shown to the user:

Do you want to enable import IntelliSense for https://deno.land? Only do this if you trust https://deno.land.

Learn more

[No] [Yes]

If the user enables this, this domain will be added to an array of allowlisted domains in the deno.import_intellisense setting in VS Code user settings (override per project possible). If a domain is part of this allowlist, autocomplete for that domain will be enabled (how this works is described below).

How does this technically work?

When an import is found with a matching registry it is parsed according to the schema defined in /.well-known/deno-import-intellisense.json. Depending on where in the URL the cursor is, the correct auto complete should be triggered. The actual IntelliSense logic should be the same as the one we use now.

Schema of /.well-known/deno-import-intellisense.json

This is approximately what the schema could look like for https://deno.land:

{
  "version": 1,
  "registries": [
    {
      "schema": "/x/:module@:version/:path*",
      "variables": {
        "module": {
          "url": "https://api.deno.land/importintellisense/modules"
        },
        "version": {
          "url": "https://api.deno.land/importintellisense/modules/${module}"
        },
        "path": {
          "url": "https://api.deno.land/importintellisense/modules/${module}/versions/${version}"
        }
      }
    },
    {
      "schema": "/std@:version/:path*",
      "variables": {
        "version": {
          "url": "https://api.deno.land/importintellisense/modules/std"
        },
        "path": {
          "url": "https://api.deno.land/importintellisense/modules/std/versions/${{version}}"
        }
      }
    }
  ]
}

So what does this mean?

The file contains a list of registries under this domain, each with a url schema it containing variables. These variables have a specified URL endpoint that is used to request the information for auto complete. These urls can have replacement variables which will be populated with the extracted values from matched the URL schema. There are two types of replacement variables: ${} which inserts the literal value of the variable and ${{}} which inserts the URL encoded value of the variable. These URLs are expected to return an array of strings in JSON format when sent a HTTP GET request. They will cached (respecting the cache-control headers).

cc @kitsonk @t8 @CGQAQ @callionica @David-Else

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
lucacasonatocommented, Sep 18, 2020

Q1. It’s not explicitly called out in the description, but the design calls for a block list as well as an allow list, right? So users could manually add domains to the block list to prevent any web requests including the web request for the well-known file?

SGTM - so a deno.import_intellisense_ignore setting.

Q2. How many requests for the well-known file will a domain that doesn’t provide the file see? Can domains enable tracking by not providing the file?

I would say we try max once every few days? A user can prevent this by adding the domain to the deno.import_intellisense_ignore setting.

Q3. If a user or organisation plans to use a single registry, can they use this system to enable autocomplete for that registry while still preventing all web requests to other locations (including the requests for the well-known file)?

What about a "deno.import_intellisense_discovery": false setting to disable the requests for the well-known file? It would be true by default. Users can still manually add registries via the deno.import_intellisense setting.

2reactions
kitsonkcommented, Sep 16, 2020

I like this a lot better. It allows users to add registries without modifying the code of the extension, and as important too, it doesn’t pick a horse in the race.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to automatically use IntelliSense importing across ...
It seems to be easy to organize and remove unused imports, but is it possible to add an import across multiple files in...
Read more >
Import multiple repositories by uploading a manifest file | GitLab
From your GitLab dashboard select New project. Switch to the Import project tab. Select Manifest file. Provide GitLab with a manifest XML file....
Read more >
Intellisense (I think) malfunction? - Visual Basic - CodeProject
This happens when I refer to any object (combo box/label/the form itself) in code and want to change a property of that object....
Read more >
Python - Open VSX Registry
IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), ... your Python code with variable extraction, method extraction and import sorting ...
Read more >
Apache NiFi User Guide
NiFi allows multiple components, such as Processors, ... The file can be used as a backup or imported into a NiFi Registry using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found