async provideCompletionItems()

in src/extension.js [244:280]


    async provideCompletionItems(document, position, token, context) {
      const line = document.lineAt(position).text.trim();
      const parts = line.split(' ');

      if (!line.endsWith('--')) {
        return [];
      }

      if (parts.length >= 3) {
        const [, product, api] = parts;
        const parameters = await metadata.getParameters(product, api, getLocale());
        parameters.sort((a, b) => {
          if (a.schema.required === b.schema.required) {
            return a.name.localeCompare(b.name);
          }

          return a.schema.required ? -1 : 1;
        });

        return parameters.map((d) => {
          const label = {
            label: d.schema.required ? `${d.name}` : `${d.name}?`,
            description: d.schema.description
          };

          const item = new vscode.CompletionItem(label);
          item.kind = vscode.CompletionItemKind.Field;
          item.insertText = `${d.name} `;

          if (d.schema.deprecated) {
            item.tags = [ vscode.CompletionItemTag.Deprecated ];
          }

          return item;
        });
      }
    }