async function initialize()

in packages/vscode-extension-web-ide/src/main.ts [55:137]


async function initialize(
  context: vscode.ExtensionContext,
  disposables: vscode.Disposable[],
  progress: vscode.Progress<{ increment: number; message: string }>,
  options: InitializeOptions,
) {
  // we want this to be fire-and-forget
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
  warnIfLanguageServerFlag();

  progress.report({ increment: -1, message: options.isReload ? MSG_LOADING : MSG_INITIALIZING });

  const startResponse = start({ ref: options.ref });
  const localStorage = new DefaultLocalStorage(context.globalState);

  const { files, ref, repoRoot, project, mergeRequest, userPermissions, forkInfo } =
    await startResponse;

  // If user can't push, show warning message
  if (!userPermissions.pushCode) {
    // We don't need to wait for this warning. Just fire and forget.
    // eslint-disable-next-line @typescript-eslint/no-floating-promises
    showCannotPushCodeWarning(forkInfo);
  }

  // If we are on the merge request branch, consider the merge request URL assoc with the branch
  const branchMergeRequestUrl = mergeRequest?.isMergeRequestBranch
    ? mergeRequest.mergeRequestUrl
    : '';

  const { fs, sourceControl, sourceControlFs } = await createSystems({
    contentProvider: new GitLabFileContentProvider(ref.sha),
    gitLsTree: files,
    repoRoot,
  });
  const fileList = new DefaultFileList({
    initBlobs: files.map(x => x.path),
    sourceControl,
  }).withCache(fs);

  await setupFileSystemProvider(disposables, fs, !userPermissions.pushCode);
  disposables.push(
    vscode.workspace.registerFileSearchProvider(
      FS_SCHEME,
      new GitLabFileSearchProvider(new DefaultFileSearcher(fileList), repoRoot),
    ),
  );

  registerCommands(disposables, startResponse, sourceControl);

  await initializeSourceControl(disposables, {
    sourceControl,
    sourceControlFs,
    localStorage,
    repoRoot,
    ref,
    project,
    branchMergeRequestUrl,
  });

  initBranchStatusBarItem(disposables, ref);

  updateWebIdeContext({
    ref: getRefName(ref),
    projectPath: project.path_with_namespace,
  });

  await refreshFileView();

  // what: Declare to the parent context that the Web IDE is "ready"
  await vscode.commands.executeCommand('setContext', WEB_IDE_READY_CONTEXT_ID, true);
  await ready();

  // what: We can load this extra context after we are "ready"
  if (mergeRequest?.isMergeRequestBranch) {
    await initMergeRequestContext(disposables, progress, {
      mergeRequest,
      files,
      repoRoot,
      isReload: options.isReload,
    });
  }
}