export function activate()

in tools/vscode_query_breakdown/src/extension.ts [24:83]


export function activate(context: vscode.ExtensionContext) {
  const execPath = path.join(
    __filename,
    '..',
    '..',
    'resources',
    'query_breakdown',
    'bin',
    'query_breakdown.jar'
  );
  // The command has been defined in the package.json file
  const disposable = vscode.commands.registerCommand(
    'vscode-query-breakdown.run',
    async () => {
      // Display a message box to the user
      vscode.window.showInformationMessage(
        'vscode_query_breakdown is running!'
      );

      // Display that progress is being made (the tool is running)
      vscode.window.withProgress(
        {
          location: vscode.ProgressLocation.Notification,
          title: 'Finding Unparsable Components',
          cancellable: true,
        },
        async (progress, token) => {
          const runner = new QueryBreakdownRunner(execPath);
          const currentEditor = vscode.window.activeTextEditor;
          if (currentEditor) {
            // get results from the backend
            json = await runner.execute(
              currentEditor.document.uri.fsPath,
              progress,
              token
            );
            if (!json) {
              vscode.window.showInformationMessage(
                'There was an error in fetching results from the backend'
              );
            } else if (json.length === 0) {
              vscode.window.showInformationMessage(
                'The entire query can be parsed without error'
              );
            } else {
              // highlights and creates hovers for queries
              decorate(currentEditor);
            }
          } else {
            vscode.window.showInformationMessage(
              'there is no editor open currently'
            );
          }
        }
      );
    }
  );

  context.subscriptions.push(disposable);
}