Skip to content

Add capabilities to listings

Created by: creckord

In MPC we have the use-case that listing owners would like to express that their listings provide tooling for certain "well-known" features in the IDE, and users want to discover this tooling dynamically when they hit use-cases for those features.

Examples for this include:

  • When opening a file, prompt to install editor support for the file's type, e.g. JavaScript or Yaml (based on filename, file extension, or detected content type).
  • When importing a project, prompt to install tooling for the project type, e.g. Maven or Gradle plugins.
  • When detecting dependencies in the project stack, prompt to install special tooling for those, e.g. Spring tools if Spring dependencies are detected

In the old API, we solved this with a hack using specially named tags, e.g. fileExtension_js for JavaScript editing support and nature_org.eclipse.m2e.core.maven2Nature for Maven project support. This caused us a lot of grief: projects would have to add tons of tags that aren't really all that relevant to the end-user in the UI; we wanted to limit the number of tags returned (and possible to add) per listing, but this made it hard; it was hard to get the weight of tags in search results correct; ...

I think we should do a better job of expressing those features in a structured way. And I think a capability model much like the IDE itself uses would be a good approach:

    Capability:
      type: object
      description: Classifies a listing as providing support for a specific task in the IDE, such as an editor for a file type, support for a language, etc.
      properties:
        namespace:
          type: string
          description: Capability namespace, e.g. 'editor.fileExtension' or 'project.nature'
        value:
          type: string
          description: Capability-specific definition, e.g. a file extension or a nature id 

    Listing:
      type: object
      properties:
        # ...
        capabilities:
          type: array
          items: 
            $ref: "#/components/schemas/Capability"
          description: Array of capabilities that the listing provides.

An example would look like this:

{
   "id": "123abc",
   "title": "My Pom Editor",
   "body": "Editor for Maven POM files - supports all kinds of POM files, whether they are named pom.xml, *.pom, or just contain the expected Maven POM content type. It also adds project import support for maven projects"
   "capabilities": [{
      "namespace": "editor.file.name",
      "value": "pom.xml"
   }, {
      "namespace": "editor.file.name",
      "value": "*.pom"
   }, {
      "namespace": "editor.xml.ns",
      "value": "http://maven.apache.org/POM/4.0.0"
   }, {
      "namespace": "import.project.nature",
      "value": "org.eclipse.m2e.core.maven2Nature"
   }, {
      "namespace": "import.project.descriptor",
      "value": "pom.xml"
   }]
}

I'm not quite sure what the best endpoint would be to search for listings that provide a certain capability. But we will probably have to support either multiple values per namespace, or some sort of wildcard search, or both.

For example, for a lookup based on a file name, the IDE might have to lookup either the exact filename (Dockerfile), or an extension match (*.xml) or maybe even a prefix match (something.*).

Depending on query performance considerations, it might or might not also be desireable to look up different capabilities at once to limit search time, e.g. for the nature of a project that is currently imported, and all file types in the project. (Although it would probably be cleaner to do this in separate queries if they're fast enough.)