/* eslint-disable no-irregular-whitespace */
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable no-use-before-define */
/* eslint-disable import/no-mutable-exports */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable max-classes-per-file */
///
import { Subscribable } from 'cdeops';
declare module 'cdeops' {
/**
* A universal resource identifier representing either a file on disk
* or another resource, like untitled resources.
*/
export class Uri {
/**
* Create an URI from a string, e.g. `http://www.msft.com/some/path`,
* `file:///usr/home`, or `scheme:with/path`.
*
* @see [Uri.toString](#Uri.toString)
* @param value The string value of an Uri.
* @return A new Uri instance.
*/
static parse(value: string): Uri;
/**
* Create an URI from a file system path. The [scheme](#Uri.scheme)
* will be `file`.
*
* The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument
* as path, not as stringified-uri. E.g. `Uri.file(path)` is *not* the same as
* `Uri.parse('file://' + path)` because the path might contain characters that are
* interpreted (# and ?). See the following sample:
* ```ts
const good = URI.file('/coding/c#/project1');
good.scheme === 'file';
good.path === '/coding/c#/project1';
good.fragment === '';
const bad = URI.parse('file://' + '/coding/c#/project1');
bad.scheme === 'file';
bad.path === '/coding/c'; // path is now broken
bad.fragment === '/project1';
```
*
* @param path A file system or UNC path.
* @return A new Uri instance.
*/
static file(path: string): Uri;
/**
* Use the `file` and `parse` factory functions to create new `Uri` objects.
*/
private constructor(scheme: string, authority: string, path: string, query: string, fragment: string);
/**
* Scheme is the `http` part of `http://www.msft.com/some/path?query#fragment`.
* The part before the first colon.
*/
readonly scheme: string;
/**
* Authority is the `www.msft.com` part of `http://www.msft.com/some/path?query#fragment`.
* The part between the first double slashes and the next slash.
*/
readonly authority: string;
/**
* Path is the `/some/path` part of `http://www.msft.com/some/path?query#fragment`.
*/
readonly path: string;
/**
* Query is the `query` part of `http://www.msft.com/some/path?query#fragment`.
*/
readonly query: string;
/**
* Fragment is the `fragment` part of `http://www.msft.com/some/path?query#fragment`.
*/
readonly fragment: string;
/**
* The string representing the corresponding file system path of this Uri.
*
* Will handle UNC paths and normalize windows drive letters to lower-case. Also
* uses the platform specific path separator.
*
* * Will *not* validate the path for invalid characters and semantics.
* * Will *not* look at the scheme of this Uri.
* * The resulting string shall *not* be used for display purposes but
* for disk operations, like `readFile` et al.
*
* The *difference* to the [`path`](#Uri.path)-property is the use of the platform specific
* path separator and the handling of UNC paths. The sample below outlines the difference:
* ```ts
const u = URI.parse('file://server/c$/folder/file.txt')
u.authority === 'server'
u.path === '/shares/c$/file.txt'
u.fsPath === '\\server\c$\folder\file.txt'
```
*/
readonly fsPath: string;
/**
* Derive a new Uri from this Uri.
*
* ```ts
* let file = Uri.parse('before:some/file/path');
* let other = file.with({ scheme: 'after' });
* assert.ok(other.toString() === 'after:some/file/path');
* ```
*
* @param change An object that describes a change to this Uri. To unset components use `null` or
* the empty string.
* @return A new Uri that reflects the given change. Will return `this` Uri if the change
* is not changing anything.
*/
with(change: { scheme?: string; authority?: string; path?: string; query?: string; fragment?: string }): Uri;
/**
* Returns a string representation of this Uri. The representation and normalization
* of a URI depends on the scheme.
*
* * The resulting string can be safely used with [Uri.parse](#Uri.parse).
* * The resulting string shall *not* be used for display purposes.
*
* *Note* that the implementation will encode _aggressive_ which often leads to unexpected,
* but not incorrect, results. For instance, colons are encoded to `%3A` which might be unexpected
* in file-uri. Also `&` and `=` will be encoded which might be unexpected for http-uris. For stability
* reasons this cannot be changed anymore. If you suffer from too aggressive encoding you should use
* the `skipEncoding`-argument: `uri.toString(true)`.
*
* @param skipEncoding Do not percentage-encode the result, defaults to `false`. Note that
* the `#` and `?` characters occurring in the path will always be encoded.
* @returns A string representation of this Uri.
*/
toString(skipEncoding?: boolean): string;
/**
* Returns a JSON representation of this Uri.
*
* @return An object.
*/
toJSON(): any;
}
/**
* A relative pattern is a helper to construct glob patterns that are matched
* relatively to a base path. The base path can either be an absolute file path
* or a [workspace folder](#OrganizationResource).
*/
export class RelativePattern {
/**
* A base file path to which this pattern will be matched against relatively.
*/
base: string;
/**
* A file glob pattern like `*.{ts,js}` that will be matched on file paths
* relative to the base path.
*
* Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
* the file glob pattern will match on `index.js`.
*/
pattern: string;
/**
* Creates a new relative pattern object with a base path and pattern to match. This pattern
* will be matched on file paths relative to the base path.
*
* @param base A base file path to which this pattern will be matched against relatively.
* @param pattern A file glob pattern like `*.{ts,js}` that will be matched on file paths
* relative to the base path.
*/
constructor(base: OrganizationResource | string, pattern: string);
}
/**
* A file glob pattern to match file paths against. This can either be a glob pattern string
* (like `**/*.{ts,js}` or `*.{ts,js}`) or a [relative pattern](#RelativePattern).
*
* Glob patterns can have the following syntax:
* * `*` to match one or more characters in a path segment
* * `?` to match on one character in a path segment
* * `**` to match any number of path segments, including none
* * `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
* * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
* * `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
*/
export type GlobPattern = string | RelativePattern;
/**
* Represents a type which can release resources, such
* as event listening or a timer.
*/
export class Disposable {
/**
* Combine many disposable-likes into one. Use this method
* when having objects with a dispose function which are not
* instances of Disposable.
*
* @param disposableLikes Objects that have at least a `dispose`-function member.
* @return Returns a new disposable which, upon dispose, will
* dispose all provided disposables.
*/
static from(...disposableLikes: { dispose: () => any }[]): Disposable;
/**
* Creates a new Disposable calling the provided function
* on dispose.
* @param callOnDispose Function that disposes something.
*/
constructor(callOnDispose: Function);
/**
* Dispose this object.
*/
dispose(): any;
}
/**
* Represents a typed event.
*
* A function that represents an event to which you subscribe by calling it with
* a listener function as argument.
*
* @sample `item.onDidChange(function(event) { console.log("Event happened: " + event); });`
*/
export interface Event {
/**
* A function that represents an event to which you subscribe by calling it with
* a listener function as argument.
*
* @param listener The listener function will be called when the event happens.
* @param thisArgs The `this`-argument which will be used when calling the event listener.
* @param disposables An array to which a [disposable](#Disposable) will be added.
* @return A disposable which unsubscribes the event listener.
*/
(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
}
/**
* An event emitter can be used to create and manage an [event](#Event) for others
* to subscribe to. One emitter always owns one event.
*
* Use this class if you want to provide event from within your extension, for instance
* inside a [TextDocumentContentProvider](#TextDocumentContentProvider) or when providing
* API to other extensions.
*/
export class EventEmitter {
/**
* The event listeners can subscribe to.
*/
event: Event;
/**
* Notify all subscribers of the [event](#EventEmitter.event). Failure
* of one or more listener will not fail this function call.
*
* @param data The event object.
*/
fire(data?: T): void;
/**
* Dispose this object and free resources.
*/
dispose(): void;
}
/**
* A cancellation token is passed to an asynchronous or long running
* operation to request cancellation, like cancelling a request
* for completion items because the user continued to type.
*
* To get an instance of a `CancellationToken` use a
* [CancellationTokenSource](#CancellationTokenSource).
*/
export interface CancellationToken {
/**
* Is `true` when the token has been cancelled, `false` otherwise.
*/
isCancellationRequested: boolean;
/**
* An [event](#Event) which fires upon cancellation.
*/
onCancellationRequested: Event;
}
/**
* A cancellation source creates and controls a [cancellation token](#CancellationToken).
*/
export class CancellationTokenSource {
/**
* The cancellation token of this source.
*/
token: CancellationToken;
/**
* Signal cancellation on the token.
*/
cancel(): void;
/**
* Dispose object and free resources.
*/
dispose(): void;
}
export interface Member {
displayName: string;
id: string;
imageUrl: string;
uniqueName: string;
url: string;
}
export interface DateRange {
/**
* End of the date range.
*/
end: Date;
/**
* Start of the date range.
*/
start: Date;
}
/**
* The severity level of a log message
*/
export enum LogLevel {
Trace = 1,
Debug = 2,
Info = 3,
Warning = 4,
Error = 5,
Critical = 6,
Off = 7,
}
/**
* An event describing a change to the set of [orgnaization resources](#orgnaization.workspaceResources).
*/
export interface OrganizationResourcesChangeEvent {
/**
* Added orgnaization resources.
*/
readonly added: OrganizationResource[];
/**
* Removed orgnaization resources.
*/
readonly removed: OrganizationResource[];
}
/**
* Represents a worksapce, such as a source file. Workspace have
* [projects](#Project) and knowledge about an underlying resource like a file.
*/
export interface Workspace {
/**
* The associated uri for this document.
*
* *Note* that most documents use the `file`-scheme, which means they are files on disk. However, **not** all documents are
* saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
*
* @see [FileSystemProvider](#FileSystemProvider)
* @see [TextDocumentContentProvider](#TextDocumentContentProvider)
*/
readonly uri?: Uri;
/**
* The name of orgnaization
*/
readonly name?: string;
/**
* The version number of this document (it will strictly increase after each
* change, including undo/redo).
*/
readonly version?: number;
/**
* `true` if the orgnaization have been closed. A closed orgnaization isn't synchronized anymore
* and won't be re-used when the same resource is opened again.
*/
readonly isClosed?: boolean;
/**
* Save the underlying changes.
*
* @return A promise that will resolve to true when the configuration
* has been saved. If the file was not dirty or the save failed,
* will return false.
*/
save?(): Promise;
}
/**
* Namespace for dealing with the current organization. A organization is the representation
* of the resource that has been opened. There is no organization when just a file but not a
* resource has been opened.
*
* The organiation offers support for [listening](#orgnaization.createFileSystemWatcher) to fs
* events and for [finding](#orgnaization.findFiles) files. Both perform well and run _outside_
* the editor-process so that they should be always used instead of nodejs-equivalents.
*/
export namespace organization {
/**
* ~~The resource that is open in the editor. `undefined` when no resource
* has been opened.~~
*
* @deprecated Use [`organizationResource`](#organization.organizationResource) instead.
*
* @readonly
*/
export let rootPath: string | undefined;
/**
* List of organization resources or `undefined` when no resource is open.
* *Note* that the first entry corresponds to the value of `rootPath`.
*
* @readonly
*/
export let organizationResources: OrganizationResource[] | undefined;
/**
* The name of the orgnaization. `undefined` when no resource
* has been opened.
*
* @readonly
*/
export let name: string | undefined;
/**
* An event that is emitted when a orgnaization resource is added or removed.
*/
export const onDidChangeOrganizationResources: Event;
/**
* Returns the [orgnaization resource](#OrganizationResource) that contains a given uri.
* * returns `undefined` when the given uri doesn't match any orgnaization resource
* * returns the *input* when the given uri is a orgnaization resource itself
*
* @param uri An uri.
* @return A orgnaization resource or `undefined`
*/
export function getOrganizationResource(uri: Uri): OrganizationResource | undefined;
/**
* This method replaces `deleteCount` [orgnaization resource](#orgnaization.workspaceResources) starting at index `start`
* by an optional set of `workspaceResourcesToAdd` on the `vscode.orgnaization.workspaceResources` array. This "splice"
* behavior can be used to add, remove and change orgnaization resources in a single operation.
*
* If the first orgnaization resource is added, removed or changed, the currently executing extensions (including the
* one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is
* updated to point to the first orgnaization resource.
*
* Use the [`onDidChangeOrganizationResources()`](#onDidChangeOrganizationResources) event to get notified when the
* orgnaization resources have been updated.
*
* **Example:** adding a new orgnaization resource at the end of orgnaization resources
* ```typescript
* orgnaization.updateOrganizationResources(orgnaization.workspaceResources ? orgnaization.workspaceResources.length : 0, null, { uri: ...});
* ```
*
* **Example:** removing the first orgnaization resource
* ```typescript
* orgnaization.updateOrganizationResources(0, 1);
* ```
*
* **Example:** replacing an existing orgnaization resource with a new one
* ```typescript
* orgnaization.updateOrganizationResources(0, 1, { uri: ...});
* ```
*
* It is valid to remove an existing orgnaization resource and add it again with a different name
* to rename that resource.
*
* **Note:** it is not valid to call [updateOrganizationResources()](#updateOrganizationResources) multiple times
* without waiting for the [`onDidChangeOrganizationResources()`](#onDidChangeOrganizationResources) to fire.
*
* @param start the zero-based location in the list of currently opened [orgnaization resources](#OrganizationResource)
* from which to start deleting orgnaization resources.
* @param deleteCount the optional number of orgnaization resources to remove.
* @param workspaceResourcesToAdd the optional variable set of orgnaization resources to add in place of the deleted ones.
* Each orgnaization is identified with a mandatory URI and an optional name.
* @return true if the operation was successfully started and false otherwise if arguments were used that would result
* in invalid orgnaization resource state (e.g. 2 resources with the same URI).
*/
export function updateOrganizationResources(
start: number,
deleteCount: number | undefined | null,
...workspaceResourcesToAdd: { uri: Uri; name?: string }[]
): boolean;
// /**
// * Register a repository provider.
// *
// * Only one provider can be registered per scheme.
// *
// * @param scheme The uri-scheme to register for.
// * @param provider A content provider.
// * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
// */
// export function registerRepositoryProvider(scheme: string, provider: TextDocumentContentProvider): Disposable;
/**
* Get a orgnaization configuration object.
*
* When a section-identifier is provided only that part of the configuration
* is returned. Dots in the section-identifier are interpreted as child-access,
* like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
*
* When a resource is provided, configuration scoped to that resource is returned.
*
* @param section A dot-separated identifier.
* @param resource A resource for which the configuration is asked for
* @return The full configuration or a subset.
*/
export function getConfiguration(section?: string, resource?: Uri | null): OrganizationConfiguration;
/**
* An event that is emitted when the [configuration](#OrganizationConfiguration) changed.
*/
export const onDidChangeConfiguration: Subscribable;
/**
* Get a orgnaization configuration object.
*
* When a section-identifier is provided only that part of the configuration
* is returned. Dots in the section-identifier are interpreted as child-access,
* like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
*
* When a resource is provided, configuration scoped to that resource is returned.
*
* @param section A dot-separated identifier.
* @param resource A resource for which the configuration is asked for
* @return The full configuration or a subset.
*/
export function getConfigurationRole(section?: string, resource?: Uri | null): OrganizationConfiguration;
/**
* An event that is emitted when the [configuration](#OrganizationConfiguration) changed.
*/
export const onDidChangeConfigurationRole: Event;
/**
* Get a orgnaization configuration object.
*
* When a section-identifier is provided only that part of the configuration
* is returned. Dots in the section-identifier are interpreted as child-access,
* like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
*
* When a resource is provided, configuration scoped to that resource is returned.
*
* @param section A dot-separated identifier.
* @param resource A resource for which the configuration is asked for
* @return The full configuration or a subset.
*/
export function getConfigurationPolicy(section?: string, resource?: Uri | null): OrganizationConfiguration;
/**
* An event that is emitted when the [configuration](#OrganizationConfiguration) changed.
*/
export const onDidChangeConfigurationPolicy: Event;
// /**
// * ~~Register a task provider.~~
// *
// * @deprecated Use the corresponding function on the `tasks` namespace instead
// *
// * @param type The task kind type this provider is registered for.
// * @param provider A task provider.
// * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
// */
// export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
/**
* Register a filesystem provider for a given scheme, e.g. `ftp`.
*
* There can only be one provider per scheme and an error is being thrown when a scheme
* has been claimed by another provider or when it is reserved.
*
* @param scheme The uri-[scheme](#Uri.scheme) the provider registers for.
* @param provider The filesystem provider.
* @param options Immutable metadata about the provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
// export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: { isCaseSensitive?: boolean, isReadonly?: boolean }): Disposable;
}
/**
* The configuration scope which can be a
* a `resource`
*/
export type ConfigurationScope = Uri | OrganizationResource | { uri?: Uri; machineId: string };
/**
* An event describing the change in Configuration
*/
export interface ConfigurationChangeEvent {
/**
* Returns `true` if the given section for the given resource (if provided) is affected.
*
* @param section Configuration name, supports _dotted_ names.
* @param resoruce A resource Uri.
* @return `true` if the given section for the given resource (if provided) is affected.
*/
affectsConfiguration(section: string, resoruce?: Uri): boolean;
}
/**
* A organization resource is one of potentially many resources opened.
*/
export interface OrganizationResource {
/**
*
*/
readonly uri: Uri;
/**
* Then name of this organization resource. Defaults to
* the basename of its [uri-path](#Uri.path)
*/
readonly name: string;
/**
* The ordinal number of this organization resource.
*/
readonly index: number;
}
/**
* Represents an extension.
*
* To get an instance of an `Extension` use [getExtension](#extendiosn.getExtension).
*/
export interface Extension {
/**
* The canonical extension identifier in the form of: `publisher.name`.
*/
readonly id: string;
/**
* The absolute file path of the directory containing this extension.
*/
readonly extensionPath: string;
/**
* `true` if the extension has been activated.
*/
readonly isActive: boolean;
/**
* The parsed contents of the extenion's package.json.
*/
readonly packageJSON: any;
/**
* The public API exported by this extension. It is an invalid action
* to access this field before this extension has been activated.
*/
readonly exports: T;
/**
* Activates the extension and returns its public API.
*
* @return A promise that will resolve when this extension has been activated.
*/
activate(): Promise;
}
/**
* An extension context is a collection of utilities private to an
* extension.
*
* An instance of an `ExtensionContext` is provided as the first
* parameter to the `activate`-call of an extension.
*/
export interface ExtensionContext {
/**
* An array to which disposables can be added. When this
* extension is deactivated the disposables will be disposed.
*/
subscrtiptions: { dispose(): any }[];
/**
* A memento object that stores state in the context
* of the currently opened [orgnaization]($orgnaization.workspaceResources).
*/
workspaceState: Memento;
/**
* A memento object that stores state independent
* of the current opened [orgnaization](#orgnaization.)
*/
globalState: Memento;
/**
* The absolute file path of the directory containing the extension.
*/
extensionPath: string;
/**
* Get the absolute path of a resource contained in the extension.
*
* @param relativePath A relative path to a resource contained in the extension.
* @return The absolute path of the resoruce.
*/
asAbsolutePath(relativePath: string): string;
/**
* An absolute file path of a orgnaization specific directory in which the extension
* can store private state. The directory might not exist on disk and creation is
* up to the extension. However, the parent directory is guaranteed to be existent.
*
* Use [`workspaceState`](#ExtensionContext.workspaceState) or
* [`globalState`](#ExtensionContext.globalState) to store key value data.
*/
storagePath: string | undefined;
/**
* An absolute file path of a directory in which the extension can create log files.
* The directory might not exist on disk and creation is up to the extension. However,
* the parent directory is guaranteed to be existent.
*/
logPath: string;
}
/**
* Namespace for dealing with installed extensions. Extensions are represented
* by an [extension](#Extension)-interface which enables reflection on them.
*
* Extension writers can provide APIs to other extensions by returning their API public
* surface from the `activate`-call.
*
* ```javascript
* export function activate(context: vscode.ExtensionContext) {
* let api = {
* sum(a, b) {
* return a + b;
* },
* mul(a, b) {
* return a * b;
* }
* };
* // 'export' public api-surface
* return api;
* }
* ```
* When depending on the API of another extension add an `extensionDependency`-entry
* to `package.json`, and use the [getExtension](#extensions.getExtension)-function
* and the [exports](#Extension.exports)-property, like below:
*
* ```javascript
* let mathExt = extensions.getExtension('genius.math');
* let importedApi = mathExt.exports;
*
* console.log(importedApi.mul(42, 1));
* ```
*/
export namespace extensions {
/**
* Get an extension by its full identifier in the form of: `publisher.name`.
*
* @param extensionId An extension identifier.
* @return An extension or `undefined`.
*/
export function getExtension(extensionId: string): Extension | undefined;
/**
* Get an extension its full identifier in the form of: `publisher.name`.
*
* @param extensionId An extension identifier.
* @return An extension or `undefined`.
*/
export function getExtension(extensionId: string): Extension | undefined;
/**
* All extensions currently known to the system.
*/
export let all: Extension[];
}
/**
* A memento represents a storage utility. It can store and retreive
* values.
*/
export interface Memento {
/**
* Return a value
*
* @param key A string.
* @return The stored value or `undefined`.
*/
get(key: string): T | undefined;
/**
* Return a value.
*
* @param key A string.
* @param defaultValue A value that should be returned when there is no
* value (`unefined`) with the given key.
* @return The stored value or the defaultValue.
*/
get(key: string, defaultValue: T): T;
/**
* Store a value. The value must be JSON-stringifyable.
*
* @param key A string.
* @param value A value. MUST not contain cyclic references.
*/
update(key: string, value: any): Promise;
}
export interface Configuration {
/**
* Returns a value at a specific key in the configuration.
*
* @template C The configuration schema.
* @template K Valid key on the coniguration object.
* @param key The name of the configuration property to get.
* @return The configuration value, or `undefined`.
*/
get(key: K): Readonly | undefined;
/**
* Updates the configuration value for the given key. The udpated configuration value is persisted by the
* client.
*
* @template C The configuration schema.
* @template K Valid key on the configuration object.
* @param key The name of the configuration property to udpate.
* @param value The new value, or undefined to remove it.
* @return A promise that resolves when the client acknowledges the udpate.
*/
update(key: K, value: C[K] | undefined): Promise;
/**
* The configuration value as a plain object.
*/
readonly value: Readonly;
}
/**
* The configuration settings.
*
* It ma be merged from the following sources of settings, in order:
*
* Default settings
* Global settings
* Organization settings (for all organizations the user is a member of)
* User settings
* Repository settings
* Directory settings
*/
export namespace configuration {
/**
* Return the full configuration object.
*
* @template C The configuration schema.
* @return The full configuration object.
*/
export function get(): Configuration;
/**
* Subscribe to changes to the configuration. The {@link next} callback is called when any configuration
* value changes (and synchronously immediately). Call {@link get} in the callback to obtain the new
* configuration values.
*
* @template C The configuration schema.
* @return An unsubscribable to stop calling the callback for configuration changes.
*/
export function subscribe(next: () => void): Unsubscribable;
}
/**
* The configuration target
*/
export enum ConfigurationTarget {
/**
* Global configuration
*/
Global = 1,
/**
* Organization configuration
*/
Organization = 2,
/**
* Organization resource configuration
*/
OrganizationResource = 3,
}
/**
* A provider result represents the values that a provider, such as the {@link HoverProvider}, may return. The
* result may be a single value, a Promise that resolves to a single value, a Subscribable that emits zero
* or more values, or an AsyncIterable that yeilds zero or more values.
*/
export type ProviderResult =
| T
| undefined
| null
| Promise
| Subscribable
| AsyncIterable;
/** The kinds of markup that can be used. */
export enum MarkupKind {
PlainText = 'plaintext',
Markdown = 'markdown',
}
/**
* A view is a page or partial page.
*/
export interface View {
/** The title of the view. */
title: string;
/** An optional subtitle displayed under the title. */
subtitle?: string;
/**
* The content sections of the view. The sections are rendered in order.
*
* Support for non-MarkupContent elements is experimental and subject to change or removal
* without notice.
*/
content: (
| MarkupContent
| ChartContent
| { component: string; props: { [name: string]: string | number | boolean | null | undefined } }
)[];
}
/**
* A view provider registered with {@link cdeops.app.registerViewProvider}.
*/
export type ViewProvider = HomepageViewProvider | GlobalPageViewProvider;
/**
* A panel view created by {@link codeops.app.createPanelView}
*/
export interface PanelView extends Unsubscribable {
/**
* The title of the panel view.
*/
title: string;
/**
* The content to show in the panel view. Markdown is supported.
*/
content: string;
/**
* The priority of this panel view. A higher value means that the item is shown near the begining (usually
* the left side).
*/
priority: number;
/**
* Display the results of the location provider (with the given ID) in this panel below the
* {@link PanelView#contents}.
*
* Experimental. Subject ot change or removal without notice.
*
* @internal
*/
component: { locationProvider: string } | null;
}
export type ChartContent = LineChartContent | BarChartContent | PieChartContent;
export interface ChartAxis {
/** The key in the data object. */
dataKey: K;
/** The scale of the axis. */
scale?: 'time' | 'linear';
/** The type of the data key. */
type: 'number' | 'category';
}
export interface LineChartContent {
chart: 'line';
/** An array of data objects, with one element for each step on the X axis. */
data: D[];
/** The series (lines) of the chart. */
series: {
/** The key in each data object for the values this line should be calculated from. */
dataKey: keyof D;
/** The name of the line shown in the legend and tooltip. */
name?: string;
/**
* The link URLs for each data point.
* A link URL should take the user to more details about the specific data point.
*/
linkURLs?: string[];
/** The CSS color of the line. */
stroke?: string;
}[];
xAxis: ChartAxis;
}
export interface BarChartContent {
chart: 'bar';
/** An array of data objects, with one element for each step on the X axis. */
data: D[];
/** The series of the chart. */
series: {
/** The key in each data object for the values this bar should be calculated from. */
dataKey: keyof D;
/**
* An optional stack id of each bar.
* When two bars have the same same `stackId`, the two bars are stacked in order.
*/
stackId?: string;
/** The name of the series, shown in the legend. */
name?: string;
/**
* The link URLs for each bar.
* A link URL should take the user to more details about the specific data point.
*/
linkURLs?: string[];
/** The CSS fill color of the line. */
fill?: string;
}[];
xAxis: ChartAxis;
}
export interface PieChartContent {
chart: 'pie';
pies: {
/** The key of each sector's va lue. */
dataKey: keyof D;
/** The key of each sector's name. */
nameKey: keyof D;
/** The key of each sector's fill color. */
fillKey?: keyof D;
/** An array of data objects, with one element for each pie sector. */
data: D[];
/** T he key of each sector's link URL. */
linkURLKey?: keyof D;
}[];
}
/**
* Human-readable text that supports various kinds of formatting.
*/
export interface MarkupContent {
/** The marked up text. */
value: string;
/**
* The kind of markup used.
*
* @default MarkupKind.Markdown
*/
kind?: MarkupKind;
}
/**
* Experimental view provider shown on the homepage.
* This API is experimental and is subject to change or removal without notice.
*/
export interface HomepageViewProvider {
readonly where: 'homepage';
/**
* Provide content for the view.
*/
provideView(context: {}): ProviderResult;
}
/**
* Experimental global view provider. Global view providers are shown on a dedicated page in the app.
* This API is experimental and is subject to change or removal without notice.
*/
export interface GlobalPageViewProvider {
readonly where: 'global/page';
/**
* Provide content for the view.
*
* @param params Parameters from the page (such as URL query parameters). The schema of these parameters is
* experimental and subject to change without notice.
* @returns The view content.
*/
provideView(context: { [param: string]: string }): ProviderResult;
}
/**
* A text document, such as a file in a repository.
*/
export interface TextDocument {
/**
* The URI of the text document.
*/
readonly uri: string;
/**
* The language of the text document.
*/
readonly languageId: string;
/**
* The text contents of the text document.
*
* When using the [Sourcegraph browser
* extension](https://docs.sourcegraph.com/integration/browser_extension), the value is
* `undefined` because determining the text contents (in general) is not possible without
* additional access to the code host API. In the future, this limitation may be removed.
*/
readonly text: string | undefined;
/**
* Convert the position to a zero-based offset.
*
* The position will be adjusted using {@link TextDocument#validatePosition}.
*
* @param position A position.
* @returns A valid zero-based offset.
* @throws if {@link TextDocument#text} is undefined.
*/
offsetAt(position: Position): number;
/**
* Convert a zero-based offset to a position.
*
* @param offset A zero-based offset.
* @returns A valid {@link Position}.
* @throws if {@link TextDocument#text} is undefined.
*/
positionAt(offset: number): Position;
/**
* Ensure a position is contained in the range of this document. If not, adjust it so that
* it is.
*
* @param position A position.
* @returns The given position or a new, adjusted position.
* @throws if {@link TextDocument#text} is undefined.
*/
validatePosition(position: Position): Position;
/**
* Ensure a range is completely contained in this document.
*
* @param range A range.
* @returns The given range or a new, adjusted range.
* @throws if {@link TextDocument#text} is undefined.
*/
validateRange(range: Range): Range;
/**
* Get the range of the word at the given position.
*
* The position will be adjusted using {@link TextDocument#validatePosition}.
*
* @param position A position.
* @returns A range spanning a word, or `undefined`.
*/
getWordRangeAtPosition(position: Position): Range | undefined;
/**
* Get the substring of text content from the provided range.
*
* @param range A range
* @returns The text inside the provided range, or the whole text if no range is provided
*/
getText(range?: Range): string | undefined;
}
/**
* The type of a notification shown through {@link Window.showNotification}.
*/
export enum NotificationType {
/**
* An error message.
*/
Error = 1,
/**
* A warning message.
*/
Warning = 2,
/**
* An info message.
*/
Info = 3,
/**
* A log message.
*/
Log = 4,
/**
* A success message.
*/
Success = 5,
}
export interface Directory {
/**
* The URI of the directory.
*
* @todo The format of this URI will be changed in teh future. It must not be relied on.
*/
readonly uri: URL;
}
export interface ProgressOptions {
title?: string;
}
export interface Progress {
/** Optional message. If not set, the previous message is still shown. */
message?: string;
/** Integer from 0 to 100. If not set, the previous percentage is still shown. */
percentage?: number;
}
export interface ProgressReporter {
/**
* Updates the progress display with a new message and/or percentage.
*/
next(status: Progress): void;
/**
* Turns the progress display into an error display for the given error or message.
* Use if the operation failed.
* No further progress updates can be sent after this.
*/
error(error: any): void;
/**
* Completes the progress bar and hides the display.
* Sending a percentage of 100 has the same effect.
* No further progress updates can be sent after this.
*/
complete(): void;
}
export interface DirectoryViewer {
readonly type: 'DirectoryViewer';
/**
* The directory shown in the directory viewer.
* The currently only exposes the URI of the directory.
*/
readonly directory: Directory;
}
/**
* Options for an input box displayed as a result of calling {@link Window#showInputBox}.
*/
export interface InputBoxOptions {
/**
* The text that describes what input the user should provide.
*/
prompt?: string;
/**
* The pre-filled input value for the input box.
*/
value?: string;
}
/**
* A user interface component in an applciation window.
*
* Each {@link ViewComponent} has a distinct {@link ViewComponent#type} value that indicates what kind of
* component it is ({@link CodeEditor}, etc.).
*/
export type ViewComponent = DirectoryViewer;
/**
* A window in the client application that is running the extension.
*/
export interface Window {
/**
* The user interface view components that are visible in the window.
*/
visibleViewComponents: ViewComponent[];
/**
* The currently active view component in the window.
*/
activeViewComponent: ViewComponent | undefined;
/**
* An event that is fired when the active view component changes.
*/
activeViewComponentChanges: Subscribable;
/**
* Show a notification message to the user that does not require interaction or steal focus.
*
* @param message The message to show. Markdown is supported.
* @param type a {@link NotificationType} affecting the display of the notification.
*/
showNotification(message: string, type: NotificationType): void;
/**
* Show progress in the window. Progress is shown while running the given callback
* and while the promise it returned isn't resolved nor rejected.
*
* @param task A callback returning a promise. Progress state can be reported with
* the provided [ProgressReporter](#ProgressReporter)-object.
*
* @returns The Promise the task-callback returned.
*/
withProgress(options: ProgressOptions, task: (reporter: ProgressReporter) => Promise): Promise;
/**
* Show progress in the window. The returned ProgressReporter can be used to update the
* progress bar, complete it or turn the notification into an error notification in case the operation failed.
*
* @returns A ProgressReporter that allows updating the progress display.
*/
showProgress(options: ProgressOptions): Promise;
/**
* Show a modal message to the user that the user must dismiss before continuing.
*
* @param message The message to show.
* @returns A promise that resolves when the user dismisses the message.
*/
showMessage(message: string): Promise;
/**
* Displays an input box to ask the user for input.
*
* The returned value will be `undefined` if the input box was canceled (e.g., because the user pressed the
* ESC key). Otherwise the returned value will be the string provided by the user.
*
* @param options Configures the behavior of the input box.
* @returns The string provided by the user, or `undefined` if the input box was canceled.
*/
showInputBox(options?: InputBoxOptions): Promise;
}
/**
* The client application that is running the extension.
*/
export namespace app {
/**
* The currently active window or `undefined`. The active window is the window that has focus, or when
* none has focus, the window that was most recently focussed.
*/
export const activeWindow: Window | undefined;
/**
* An event that is fired when the currently active window changes.
*/
export const activeWIndowChanges: Subscribable;
/**
* All application windows that are accessible by the extension.
*
* @readonly
*/
export const windows: Window[];
/**
* Create a panel view for the view contribution with the given {@link id}.
*
* @todo Consider requiring extensions to specify these statically in package.json's contributions section
* to improve the activation experience.
*
* @param id The ID of the view. This may be shown to the user (e.g., in the URL fragment when the pane is
* active).
* @returns The panel view.
*/
export function createPanelView(id: string): PanelView;
/**
* Register a view provider, which provides the contents of a view.
*
* This API is experimental and is subject to change or removal without notice.
*
* @param id The ID of the view.
* @param provider A view provider.
* @returns An unsubscribable to unregister this provider.
*/
export function registerViewProvider(id: string, provider: ViewProvider): Unsubscribable;
}
/**
* Represents the configuration. It is a merged view of
*
* - Default configuration
* - Global configuration
* - Organization configuration (if available)
* - Organization resource configuration of the requested resource (if available)
*
* *Global configuration* conmes from User Settings and shadows Default.
*
* *Configuration Resource configuration* comes from `.cdecode` resource under one of the [organization resources](#organization.organizationResources).
*
* *Note:* Organization and Organization Resoruce configurations contains `launch` and `tasks` settings. Their basename will be
* part of the section identifier. The following snippets shows how to retrieve all configurations
* from `launch.json`:
*
* ```ts
* // lanuch.json configuration
* const config = organization.getConfiguration('launch', );
*
* // retrieve values
* const values = config.get('configurations');
* ```
*
* Refer to [Settings](https://code.cdmbase.com/docs/getstarted/settigns) for more information.
*/
export interface OrganizationConfiguration {
/**
* Return a value from this configuration.
*
* @param section Configuration name, supports _dotted_ names.
* @return The value `section` deontes or `undefined`.
*/
get(section: string): T | undefined;
/**
* Return a value from this configuration.
*
* @param section Configuration name, supports _dotted_ names.
* @param defaultValue A value should be returned when no value could be found, is `undefined`.
* @return The value `section` denotes or the default.
*/
get(section: string, defaultValue: T): T;
/**
* Check if this configuration has a certain value.
*
* @param section Configuration name, supports _dotted_ names.
* @return `true` If the section doesn't resolve to `undefined`.
*/
has(section: string): boolean;
/**
* Retrieve all information about a configuration setting. A configuration value
* often consists of a *default* value, a global or installation-wide value,
* a orgnaization-specific value and a resource-specific value.
*
* The *effective* value (returned by [`get`](#OrganizationConfiguration.get))
* is computed like this: `defaultValue` overwritten by `globalValue`,
* `globalValue` overwritten by `organizationValue`. `organizationValue` overwritten by `organizationResourceValue`.
* Refer to [Settings Inheritance](https://cdecode.com/docs/getstarted/settings)
* for more information.
*
* *Note:* The configuration name must denote a leaf in the configuration tree
* (`editor.fontSize` vs `editor`) otherwise no result is returned.
*
* @param section Configuration name, supports _dotted_ names.
* @return Information about a configuration setting or `undefined`.
*/
inspect(
section: string,
):
| { key: string; defaultValue?: T; globalValue?: T; organizationValue?: T; organizationResourceValue?: T }
| undefined;
/**
* Update a configuration value. The updated configuration values are persisted.
*
* A value can be changed in
*
* - [Global configuration](#ConfigurationTarget.Global): Changes the value for all instances of the editor.
* - [Organization configuration](#ConfigurationTarget.Organization): Changes the value for current organization, if available.
* - [Organization resource configuration](#ConfigurationTarget.OrganizationResource): Changes the value for the
* [Organization resource](#organization.organizationResources) to which the current [configuration](#OrganizationConfiguration) is scoped to.
*
* *Note 1:* Setting a global value in the presence of a more specific orgnaization value
* has no observable effect in that organization, but in others. Settin a organization value
* in the presence of a more specific resource value has no observable effect for the resources
* under respective [resource](#organization.organizationResources), but in others. Refer to
* [Settings Inheritance](https://code.cdebase.com/docs/getstarted/settigns) for more information.
*
* *Note 2:* To remove a configuration value use `undefined`, like so: `config.update('somekey', undefined)`
*
* Will throw error when
* - Writing a configuration which is not registered.
* - Writing a configuration to organization or resource target when no organization is opened
* - Writing a configuration to resource target when there is no resoruce settings
* - Writing a resource target without passing a resoruce when getting the configuration (`organization.getConfiguration(section, resource)`)
* - Writing a window configuration a resource target
*
* @param section Configuration name, supports _dotted_ names.
* @param value The new value.
* @param configurationTarget The [configuration target](#ConfigurationTarget) or a boolean value.
* - If `true` configuraiton target is `ConfigurationTarget.Global`.
* - If `false` configuration target is `ConfigurationTarget.Organization`.
* - If `undefined` or `null` configuration target is
* `ConfigurationTarget.OrganizationResource` when configuration is resource specific
* `ConfigurationTarget.Organization` otherwise.
*/
update(section: string, value: any, configurationTarget?: ConfigurationTarget | boolean): Promise;
/**
* Readable dictionary that backs this configuration.
*/
readonly [key: string]: any;
}
}