"use strict";
const cancellation = require("../../../../base/common/cancellation.js");
const types = require("../../../../base/common/types.js");
const uri = require("../../../../base/common/uri.js");
const resolverService = require("../../../common/services/resolverService.js");
const outlineModel = require("./outlineModel.js");
const commands = require("../../../../platform/commands/common/commands.js");
var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
  function adopt(value) {
    return value instanceof P ? value : new P(function(resolve) {
      resolve(value);
    });
  }
  return new (P || (P = Promise))(function(resolve, reject) {
    function fulfilled(value) {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    }
    function rejected(value) {
      try {
        step(generator["throw"](value));
      } catch (e) {
        reject(e);
      }
    }
    function step(result) {
      result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
    }
    step((generator = generator.apply(thisArg, _arguments || [])).next());
  });
};
commands.CommandsRegistry.registerCommand("_executeDocumentSymbolProvider", function(accessor, ...args) {
  return __awaiter(this, void 0, void 0, function* () {
    const [resource] = args;
    types.assertType(uri.URI.isUri(resource));
    const outlineService = accessor.get(outlineModel.IOutlineModelService);
    const modelService = accessor.get(resolverService.ITextModelService);
    const reference = yield modelService.createModelReference(resource);
    try {
      return (yield outlineService.getOrCreate(reference.object.textEditorModel, cancellation.CancellationToken.None)).getTopLevelSymbols();
    } finally {
      reference.dispose();
    }
  });
});
