@theia/core
- Version 1.53.2
- Published
- 11.2 MB
- 70 dependencies
- EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 license
Install
npm i @theia/core
yarn add @theia/core
pnpm add @theia/core
Overview
Theia is a cloud & desktop IDE framework implemented in TypeScript.
Index
Variables
- ACCOUNTS_MENU
- ACCOUNTS_SUBMENU
- BackendStopwatch
- BackendStopwatchOptions
- CommandContribution
- CommandService
- commandServicePath
- ConnectionHandler
- ContributionFilterRegistry
- ContributionProvider
- EOL
- Filter
- FilterContribution
- ILogger
- isOSX
- isWindows
- logger
- LoggerFactory
- LoggerName
- MAIN_MENU_BAR
- MANAGE_MENU
- MAX_SAFE_INTEGER
- MEMORY_TEXT
- MenuCommandAdapter
- MenuCommandAdapterRegistry
- MenuCommandExecutor
- MenuContribution
- messageServicePath
- OSBackendProvider
- OSBackendProviderPath
- ProgressClient
- QuickInputService
- quickInputServicePath
- QuickPickService
- quickPickServicePath
- ResourceProvider
- ResourceResolver
- rootLoggerName
- servicesPath
- stopwatchPath
- THEIA_VERSION
- UNTITLED_SCHEME
Functions
- bindContribution()
- bindContributionProvider()
- cancelled()
- checkCancelled()
- cloneAndChange()
- cmd()
- commonPrefixLength()
- compare()
- compareIgnoreCase()
- compareSubstring()
- compareSubstringIgnoreCase()
- createUntitledURI()
- deepClone()
- deepFreeze()
- disposableTimeout()
- endsWith()
- equalsIgnoreCase()
- escapeInvisibleChars()
- escapeRegExpCharacters()
- filterItems()
- findMatches()
- generateUuid()
- hashValue()
- isArray()
- isBoolean()
- isCancelled()
- isDefined()
- isEmpty()
- isEmptyObject()
- isError()
- isErrorLike()
- isFunction()
- isLowerAsciiLetter()
- isNumber()
- isObject()
- isString()
- isStringArray()
- isUndefined()
- isUndefinedOrNull()
- isUpperAsciiLetter()
- isUUID()
- notEmpty()
- nullToUndefined()
- regExpFlags()
- setRootLogger()
- split()
- startsWithIgnoreCase()
- unescapeInvisibleChars()
- unreachable()
- unsetRootLogger()
Classes
CommandRegistry
- addRecentCommand()
- clearCommandHistory()
- commandIds
- commands
- contributionProvider
- doFireDidChange()
- doRegisterCommand()
- executeCommand()
- fireDidChange
- fireWillExecuteCommand()
- getActiveHandler()
- getAllCommands()
- getAllHandlers()
- getCommand()
- getToggledHandler()
- getVisibleHandler()
- isEnabled()
- isToggled()
- isVisible()
- onCommandsChanged
- onCommandsChangedEmitter
- onDidExecuteCommand
- onDidExecuteCommandEmitter
- onStart()
- onWillExecuteCommand
- onWillExecuteCommandEmitter
- recent
- registerCommand()
- registerHandler()
- toUnregisterCommands
- unregisterCommand()
MenuModelRegistry
- allChildrenCompound()
- changeEventOnDispose()
- commands
- contributions
- findGroup()
- findSubMenu()
- fireChangeEvent()
- getMenu()
- getMenuNode()
- getPath()
- independentSubmenus
- isEmpty()
- isReady
- linkSubmenu()
- onDidChange
- onDidChangeEmitter
- onStart()
- registerIndependentSubmenu()
- registerMenuAction()
- registerMenuNode()
- registerSubmenu()
- removeSingleRootNode()
- root
- unregisterMenuAction()
- unregisterMenuNode()
RpcProtocol
- CANCELLATION_TOKEN_KEY
- cancellationTokenSources
- channel
- decoder
- disposeCancellationEventListener()
- encoder
- handleCancel()
- handleMessage()
- handleNotify()
- handleReply()
- handleReplyErr()
- handleRequest()
- mode
- nextMessageId
- onNotification
- onNotificationEmitter
- pendingRequestCancellationEventListeners
- pendingRequests
- requestHandler
- sendCancel()
- sendNotification()
- sendRequest()
- toDispose
URI
- allLocations
- authority
- displayName
- fragment
- fromComponents()
- fromFilePath()
- getDistinctParents()
- isEqual()
- isEqualOrParent()
- normalizePath()
- parent
- path
- query
- relative()
- resolve()
- resolveToAbsolute()
- scheme
- toComponents()
- toString()
- withAuthority()
- withFragment()
- withoutAuthority()
- withoutFragment()
- withoutPath()
- withoutQuery()
- withPath()
- withQuery()
- withScheme()
Interfaces
QuickPickOptions
- activeItem
- ariaLabel
- autoFocusOnList
- busy
- buttons
- canAcceptInBackground
- canSelectMany
- contextKey
- customButton
- customHover
- customLabel
- description
- enabled
- filterValue
- hideCheckAll
- hideInput
- ignoreFocusOut
- keepScrollPosition
- matchOnDescription
- matchOnDetail
- matchOnLabel
- onDidAccept
- onDidChangeActive
- onDidChangeSelection
- onDidChangeValue
- onDidCustom
- onDidHide
- onDidTriggerButton
- onDidTriggerItemButton
- placeholder
- runIfSingle
- sortByLabel
- step
- title
- totalSteps
- validationMessage
- value
- valueSelection
Enums
Type Aliases
- Bindable
- CMD
- ConnectionErrorHandlerOptions
- ContributionType
- Deferred
- DisposableGroup
- Filter
- JsonRpcConnectionEventEmitter
- JsonRpcProxy
- JsonRpcServer
- Log
- Loggable
- LoggerFactory
- MaybeArray
- MaybeNull
- MaybePromise
- MaybeUndefined
- MenuCommandArguments
- MenuNode
- MenuPath
- MessageProvider
- Mutable
- QuickPickInput
- QuickPickItemOrSeparator
- QuickPicks
- RecursivePartial
- RemoteMeasurement
- RequestHandler
- ResourceProvider
- RpcProtocolFactory
- RpcProxy
- RpcServer
- WaitUntilData
Namespaces
Variables
variable ACCOUNTS_MENU
const ACCOUNTS_MENU: MenuPath;
variable ACCOUNTS_SUBMENU
const ACCOUNTS_SUBMENU: string[];
variable BackendStopwatch
const BackendStopwatch: Symbol;
variable BackendStopwatchOptions
const BackendStopwatchOptions: Symbol;
variable CommandContribution
const CommandContribution: Symbol;
variable CommandService
const CommandService: Symbol;
variable commandServicePath
const commandServicePath: string;
variable ConnectionHandler
const ConnectionHandler: Symbol;
variable ContributionFilterRegistry
const ContributionFilterRegistry: Symbol;
variable ContributionProvider
const ContributionProvider: Symbol;
variable EOL
const EOL: string;
variable Filter
const Filter: Symbol;
variable FilterContribution
const FilterContribution: Symbol;
variable ILogger
const ILogger: Symbol;
variable isOSX
const isOSX: boolean;
variable isWindows
const isWindows: boolean;
variable logger
let logger: ILogger;
variable LoggerFactory
const LoggerFactory: Symbol;
variable LoggerName
const LoggerName: Symbol;
variable MAIN_MENU_BAR
const MAIN_MENU_BAR: MenuPath;
variable MANAGE_MENU
const MANAGE_MENU: MenuPath;
variable MAX_SAFE_INTEGER
const MAX_SAFE_INTEGER: number;
The maximum safe integer (
2^32-1
) is used as a placeholder for large numbers which are not allowed to be floats. For example as line/column arguments for monaco-ranges.
variable MEMORY_TEXT
const MEMORY_TEXT: string;
variable MenuCommandAdapter
const MenuCommandAdapter: Symbol;
variable MenuCommandAdapterRegistry
const MenuCommandAdapterRegistry: Symbol;
variable MenuCommandExecutor
const MenuCommandExecutor: Symbol;
variable MenuContribution
const MenuContribution: Symbol;
variable messageServicePath
const messageServicePath: string;
variable OSBackendProvider
const OSBackendProvider: Symbol;
variable OSBackendProviderPath
const OSBackendProviderPath: string;
variable ProgressClient
const ProgressClient: Symbol;
variable QuickInputService
const QuickInputService: Symbol;
variable quickInputServicePath
const quickInputServicePath: string;
variable QuickPickService
const QuickPickService: Symbol;
variable quickPickServicePath
const quickPickServicePath: string;
variable ResourceProvider
const ResourceProvider: Symbol;
variable ResourceResolver
const ResourceResolver: Symbol;
variable rootLoggerName
const rootLoggerName: string;
variable servicesPath
const servicesPath: string;
variable stopwatchPath
const stopwatchPath: string;
API path of the stopwatch service that exposes the back-end stopwatch to clients.
variable THEIA_VERSION
const THEIA_VERSION: string;
variable UNTITLED_SCHEME
const UNTITLED_SCHEME: string;
Functions
function bindContribution
bindContribution: ( bindable: Bindable, service: interfaces.ServiceIdentifier<any>, contributions: interfaces.ServiceIdentifier<any>[]) => void;
Helper function to bind a service to a list of contributions easily.
Parameter bindable
a Container or the bind function directly.
Parameter service
an already bound service to refer the contributions to.
Parameter contributions
array of contribution identifiers to bind the service to.
function bindContributionProvider
bindContributionProvider: (bindable: Bindable, id: symbol) => void;
function cancelled
cancelled: () => Error;
function checkCancelled
checkCancelled: (token?: CancellationToken) => void;
function cloneAndChange
cloneAndChange: (obj: any, changer: (orig: any) => any) => any;
function cmd
cmd: (command: string, ...args: string[]) => CMD;
function commonPrefixLength
commonPrefixLength: (a: string, b: string) => number;
Returns
the length of the common prefix of the two strings.
function compare
compare: (a: string, b: string) => number;
function compareIgnoreCase
compareIgnoreCase: (a: string, b: string) => number;
function compareSubstring
compareSubstring: ( a: string, b: string, aStart?: number, aEnd?: number, bStart?: number, bEnd?: number) => number;
function compareSubstringIgnoreCase
compareSubstringIgnoreCase: ( a: string, b: string, aStart?: number, aEnd?: number, bStart?: number, bEnd?: number) => number;
function createUntitledURI
createUntitledURI: (extension?: string, parent?: URI) => URI;
Deprecated
Since 1.27.0. Please use
UntitledResourceResolver.createUntitledURI
instead.
function deepClone
deepClone: <T>(obj: T) => T;
function deepFreeze
deepFreeze: <T>(obj: T) => T;
function disposableTimeout
disposableTimeout: ( handler: TimerHandler, timeout?: number, ...arguments: any[]) => Disposable;
function endsWith
endsWith: (haystack: string, needle: string) => boolean;
Determines if haystack ends with needle.
function equalsIgnoreCase
equalsIgnoreCase: (a: string, b: string) => boolean;
function escapeInvisibleChars
escapeInvisibleChars: (value: string) => string;
function escapeRegExpCharacters
escapeRegExpCharacters: (value: string) => string;
Escapes regular expression characters in a given string
function filterItems
filterItems: ( items: QuickPickItemOrSeparator[], filter: string) => QuickPickItemOrSeparator[];
Filter the list of quick pick items based on the provided filter. Items are filtered based on if: - their
label
satisfies the filter usingfuzzy
. - theirdescription
satisfies the filter usingfuzzy
. - theirdetail
satisfies the filter usingfuzzy
. Filtered items are also updated to display proper highlights based on how they were filtered.Parameter items
the list of quick pick items.
Parameter filter
the filter to search for.
Returns
the list of quick pick items that satisfy the filter.
function findMatches
findMatches: ( word: string, pattern: string) => Array<{ start: number; end: number }> | undefined;
Find match highlights when testing a word against a pattern.
Parameter word
the word to test.
Parameter pattern
the word to match against.
Returns
the list of highlights if present.
function generateUuid
generateUuid: () => string;
function hashValue
hashValue: (value: string) => string;
This function will hash the given value using SHA1. The result will be a uuid.
Parameter value
the string to hash
Returns
a uuid
function isArray
isArray: <T>( value: unknown, every?: (value: unknown) => unknown, thisArg?: unknown) => value is T[];
Parameter value
value to check.
Parameter every
optional predicate ran on every element of the array.
Parameter thisArg
value to substitute
this
with when invoking in the predicate.Returns
whether or not
value
is an array.
function isBoolean
isBoolean: (value: unknown) => value is boolean;
function isCancelled
isCancelled: (err: Error | undefined) => boolean;
function isDefined
isDefined: <T>(arg: T | null | undefined) => arg is T;
Returns
whether the provided parameter is defined.
function isEmpty
isEmpty: (arg: Object) => boolean;
true
if the argument is an empty object. Otherwise,false
.
function isEmptyObject
isEmptyObject: (obj: unknown) => obj is object;
Returns
whether the provided parameter is an empty JavaScript Object or not.
function isError
isError: (value: unknown) => value is Error;
function isErrorLike
isErrorLike: (value: unknown) => value is Error;
function isFunction
isFunction: <T extends (...args: unknown[]) => unknown>( value: unknown) => value is T;
function isLowerAsciiLetter
isLowerAsciiLetter: (code: number) => boolean;
function isNumber
isNumber: (value: unknown) => value is number;
function isObject
isObject: <T extends object>(value: unknown) => value is UnknownObject<T>;
function isString
isString: (value: unknown) => value is string;
function isStringArray
isStringArray: (value: unknown) => value is string[];
function isUndefined
isUndefined: (value: unknown) => value is undefined;
function isUndefinedOrNull
isUndefinedOrNull: (obj: unknown) => obj is null;
Returns
whether the provided parameter is undefined or null.
function isUpperAsciiLetter
isUpperAsciiLetter: (code: number) => boolean;
function isUUID
isUUID: (value: string) => boolean;
function notEmpty
notEmpty: <T>(arg: T | undefined | null) => arg is T;
function nullToUndefined
nullToUndefined: <T>(nullable: MaybeNull<T>) => MaybeUndefined<T>;
Creates a shallow copy with all ownkeys of the original object that are
null
madeundefined
function regExpFlags
regExpFlags: (regexp: RegExp) => string;
function setRootLogger
setRootLogger: (aLogger: ILogger) => void;
function split
split: (s: string, splitter: string) => IterableIterator<string>;
function startsWithIgnoreCase
startsWithIgnoreCase: (str: string, candidate: string) => boolean;
function unescapeInvisibleChars
unescapeInvisibleChars: (value: string) => string;
function unreachable
unreachable: (_never: never, message?: string) => never;
Throws when called and statically makes sure that all variants of a type were consumed.
function unsetRootLogger
unsetRootLogger: () => void;
Counterpart of the
#setRootLogger(ILogger)
. Restores theconsole.xxx
bindings to the original one. Invoking has no side-effect ifsetRootLogger
was not called before. Multiple function invocation has no side-effect either.
Classes
class AbstractChannel
abstract class AbstractChannel implements Channel {}
Reusable abstract Channel implementation that sets up the basic channel event listeners and offers a generic close method.
constructor
constructor();
property onClose
readonly onClose: Event<ChannelCloseEvent>;
property onCloseEmitter
onCloseEmitter: Emitter<ChannelCloseEvent>;
property onError
readonly onError: Event<unknown>;
property onErrorEmitter
onErrorEmitter: Emitter<unknown>;
property onMessage
readonly onMessage: Event<MessageProvider>;
property onMessageEmitter
onMessageEmitter: Emitter<MessageProvider>;
property toDispose
protected toDispose: DisposableCollection;
method close
close: () => void;
method getWriteBuffer
abstract getWriteBuffer: () => WriteBuffer;
class AbstractReferenceCollection
abstract class AbstractReferenceCollection<K, V extends Disposable> implements Disposable {}
Abstract class for a map of reference-counted disposable objects, with the following features:
- values are not inserted explicitly; instead, acquire() is used to create the value for a given key, or return the previously created value for it. How the value is created for a given key is implementation specific.
- any subsquent acquire() with the same key will bump the reference count on that value. acquire() returns not the value directly but a reference object that holds the value. Calling dispose() on the reference decreases the value's effective reference count.
- a contained value will have its dispose() function called when its reference count reaches zero. The key/value pair will be purged from the collection.
- calling dispose() on the value directly, instead of calling it on the reference returned by acquire(), will automatically dispose all outstanding references to that value and the key/value pair will be purged from the collection.
- supports synchronous and asynchronous implementations. acquire() will return a Promise if the value cannot be created immediately
- functions has|keys|values|get are always synchronous and the result excludes asynchronous additions in flight.
- functions values|get return the value directly and not a reference to the value. Use these functions to obtain a value without bumping its reference count.
- clients can register to be notified when values are added and removed; notification for asynchronous additions happen when the creation completes, not when it's requested.
- keys can be any value/object that can be successfully stringified using JSON.stringify(), sans arguments
- calling dispose() on the collection will dispose all outstanding references to all contained values, which results in the disposal of the values themselves.
constructor
constructor();
property onDidCreate
readonly onDidCreate: Event<V>;
property onDidCreateEmitter
protected readonly onDidCreateEmitter: Emitter<V>;
property onWillDispose
readonly onWillDispose: Event<V>;
property onWillDisposeEmitter
protected readonly onWillDisposeEmitter: Emitter<V>;
property references
protected readonly references: Map<string, DisposableCollection>;
property toDispose
protected readonly toDispose: DisposableCollection;
method acquire
abstract acquire: (args: K) => MaybePromise<Reference<V>>;
method clear
clear: () => void;
method createReferences
protected createReferences: (key: string, value: V) => DisposableCollection;
method dispose
dispose: () => void;
method doAcquire
protected doAcquire: (key: string, object: V) => Reference<V>;
method get
get: (args: K) => V | undefined;
method has
has: (args: K) => boolean;
method keys
keys: () => K[];
method toKey
protected toKey: (args: K) => string;
method values
values: () => V[];
class ActionMenuNode
class ActionMenuNode implements MenuNode, CommandMenuNode, Partial<AlternativeHandlerMenuNode> {}
Node representing an action in the menu tree structure. It's based on MenuAction for which it tries to determine the best label, icon and sortString with the given data.
constructor
constructor(action: MenuAction, commands: CommandRegistry);
property action
protected readonly action: MenuAction;
property altNode
readonly altNode: ActionMenuNode;
property command
readonly command: string;
property commands
protected readonly commands: CommandRegistry;
property icon
readonly icon: string;
property id
readonly id: string;
property label
readonly label: string;
property sortString
readonly sortString: string;
property when
readonly when: string;
class AsyncEmitter
class AsyncEmitter<T extends WaitUntilEvent> extends Emitter<T> {}
property deliveryQueue
protected deliveryQueue: Promise<void>;
method deliver
protected deliver: ( listeners: Callback[], event: WaitUntilData<T>, token: CancellationToken, promiseJoin?: (p: Promise<any>, listener: Function) => Promise<any>) => Promise<void>;
method fire
fire: ( event: WaitUntilData<T>, token?: CancellationToken, promiseJoin?: (p: Promise<any>, listener: Function) => Promise<any>) => Promise<void>;
Fire listeners async one after another.
class CancellationError
class CancellationError extends Error {}
constructor
constructor();
class CancellationTokenSource
class CancellationTokenSource {}
constructor
constructor(parent?: CancellationToken);
property token
readonly token: CancellationToken;
method cancel
cancel: () => void;
method dispose
dispose: () => void;
class CommandRegistry
class CommandRegistry implements CommandService {}
The command registry manages commands and handlers.
constructor
constructor(contributionProvider: ContributionProvider<CommandContribution>);
property commandIds
readonly commandIds: string[];
Get all registered commands identifiers.
property commands
readonly commands: Command[];
Get all registered commands.
property contributionProvider
protected readonly contributionProvider: ContributionProvider<CommandContribution>;
property fireDidChange
protected fireDidChange: () => Promise<void>;
property onCommandsChanged
readonly onCommandsChanged: Event<void>;
property onCommandsChangedEmitter
protected readonly onCommandsChangedEmitter: Emitter<void>;
property onDidExecuteCommand
readonly onDidExecuteCommand: Event<CommandEvent>;
property onDidExecuteCommandEmitter
protected readonly onDidExecuteCommandEmitter: Emitter<CommandEvent>;
property onWillExecuteCommand
readonly onWillExecuteCommand: Event<WillExecuteCommandEvent>;
property onWillExecuteCommandEmitter
protected readonly onWillExecuteCommandEmitter: Emitter<WillExecuteCommandEvent>;
property recent
recent: Command[];
Get the list of recently used commands.
property toUnregisterCommands
protected readonly toUnregisterCommands: Map<string, Disposable>;
method addRecentCommand
addRecentCommand: (recent: Command | Command[]) => void;
Adds a command to recently used list. Prioritizes commands that were recently executed to be most recent.
Parameter recent
a recent command, or array of recent commands.
method clearCommandHistory
clearCommandHistory: () => void;
Clear the list of recently used commands.
method doFireDidChange
protected doFireDidChange: () => void;
method doRegisterCommand
protected doRegisterCommand: (command: Command) => Disposable;
method executeCommand
executeCommand: <T>(commandId: string, ...args: any[]) => Promise<T | undefined>;
Execute the active handler for the given command and arguments.
Reject if a command cannot be executed.
method fireWillExecuteCommand
protected fireWillExecuteCommand: ( commandId: string, args?: any[]) => Promise<void>;
method getActiveHandler
getActiveHandler: ( commandId: string, ...args: any[]) => CommandHandler | undefined;
Get an active handler for the given command or
undefined
.
method getAllCommands
getAllCommands: () => IterableIterator< Readonly<Command & { handlers: CommandHandler[] }>>;
method getAllHandlers
getAllHandlers: (commandId: string) => CommandHandler[];
Returns with all handlers for the given command. If the command does not have any handlers, or the command is not registered, returns an empty array.
method getCommand
getCommand: (id: string) => Command | undefined;
Get a command for the given command identifier.
method getToggledHandler
getToggledHandler: ( commandId: string, ...args: any[]) => CommandHandler | undefined;
Get a toggled handler for the given command or
undefined
.
method getVisibleHandler
getVisibleHandler: ( commandId: string, ...args: any[]) => CommandHandler | undefined;
Get a visible handler for the given command or
undefined
.
method isEnabled
isEnabled: (command: string, ...args: any[]) => boolean;
Test whether there is an active handler for the given command.
method isToggled
isToggled: (command: string, ...args: any[]) => boolean;
Test whether there is a toggled handler for the given command.
method isVisible
isVisible: (command: string, ...args: any[]) => boolean;
Test whether there is a visible handler for the given command.
method onStart
onStart: () => void;
method registerCommand
registerCommand: (command: Command, handler?: CommandHandler) => Disposable;
Register the given command and handler if present.
Throw if a command is already registered for the given command identifier.
method registerHandler
registerHandler: (commandId: string, handler: CommandHandler) => Disposable;
Register the given handler for the given command identifier.
If there is already a handler for the given command then the given handler is registered as more specific, and has higher priority during enablement, visibility and toggle state evaluations.
method unregisterCommand
unregisterCommand: { (command: Command): void; (id: string): void };
Unregister command from the registry
Parameter command
Unregister command from the registry
Parameter id
class CompositeMenuNode
class CompositeMenuNode implements MutableCompoundMenuNode {}
Node representing a (sub)menu in the menu tree structure.
constructor
constructor( id: string, label?: string, options?: SubMenuOptions, parent?: MenuNodeMetadata & MenuNodeRenderingData & Partial<CompoundMenuNode> & Partial<CommandMenuNode> & Partial<AlternativeHandlerMenuNode> & CompoundMenuNode);
property children
readonly children: readonly MenuNode[];
property icon
readonly icon: string;
property iconClass
iconClass?: string;
property id
readonly id: string;
property isNavigationGroup
static isNavigationGroup: (node: MenuNode) => node is CompoundMenuNode;
Deprecated
1.28 use CompoundMenuNode.isNavigationGroup instead
property isSubmenu
readonly isSubmenu: boolean;
property label
label?: string;
property order
order?: string;
property parent
readonly parent?: MenuNodeMetadata & MenuNodeRenderingData & Partial<CompoundMenuNode> & Partial<CommandMenuNode> & Partial<AlternativeHandlerMenuNode> & CompoundMenuNode;
property role
readonly role: CompoundMenuNodeRole;
property sortString
readonly sortString: string;
property when
readonly when: string;
method addNode
addNode: (node: MenuNode) => Disposable;
method removeNode
removeNode: (id: string) => void;
method updateOptions
updateOptions: (options?: SubMenuOptions) => void;
class CompositeMenuNodeWrapper
class CompositeMenuNodeWrapper implements MutableCompoundMenuNode {}
constructor
constructor( wrapped: Readonly<MutableCompoundMenuNode>, parent: CompoundMenuNode, options?: SubMenuOptions);
property children
readonly children: readonly MenuNode[];
property icon
readonly icon: string;
property iconClass
readonly iconClass: string;
property id
readonly id: string;
property isSubmenu
readonly isSubmenu: boolean;
property label
readonly label: string;
property options
protected readonly options?: SubMenuOptions;
property order
readonly order: string;
property parent
readonly parent: CompoundMenuNode;
property role
readonly role: CompoundMenuNodeRole;
property sortString
readonly sortString: string;
property when
readonly when: string;
property wrapped
protected readonly wrapped: Readonly<MutableCompoundMenuNode>;
method addNode
addNode: (node: MenuNode) => Disposable;
method removeNode
removeNode: (id: string) => void;
method updateOptions
updateOptions: (options: SubMenuOptions) => void;
class ConnectionErrorHandler
class ConnectionErrorHandler {}
constructor
constructor(options: ConnectionErrorHandlerOptions);
property options
protected readonly options: ResolvedConnectionErrorHandlerOptions;
property restarts
protected readonly restarts: number[];
method shouldRestart
shouldRestart: () => boolean;
method shouldStop
shouldStop: (error: Error, count?: number) => boolean;
class ContributionFilterRegistryImpl
class ContributionFilterRegistryImpl implements ContributionFilterRegistry {}
Registry of contribution filters.
Implement/bind to the
FilterContribution
interface/symbol to register your contribution filters.
constructor
constructor(contributions?: FilterContribution[]);
property genericFilters
protected genericFilters: Filter<Object>[];
property initialized
protected initialized: boolean;
property typeToFilters
protected typeToFilters: Map< interfaces.ServiceIdentifier<any>, Filter<Object>[]>;
method addFilters
addFilters: (types: '*' | ContributionType[], filters: Filter<Object>[]) => void;
method applyFilters
applyFilters: <T extends Object>( toFilter: T[], type: interfaces.ServiceIdentifier<any>) => T[];
method getFilters
protected getFilters: ( type: interfaces.ServiceIdentifier<any>) => Filter<Object>[];
method getOrCreate
protected getOrCreate: ( type: interfaces.ServiceIdentifier<any>) => Filter<Object>[];
class DefaultBackendStopwatch
class DefaultBackendStopwatch {}
Default implementation of the (remote) back-end stopwatch service.
property idSequence
protected idSequence: number;
property measurements
readonly measurements: Map<number, Measurement>;
property stopwatch
protected readonly stopwatch: Stopwatch;
method start
start: (name: string, options?: MeasurementOptions) => RemoteMeasurement;
method stop
stop: ( measurementToken: RemoteMeasurement, message: string, messageArgs: any[]) => void;
class DefaultResourceProvider
class DefaultResourceProvider {}
constructor
constructor(resolversProvider: ContributionProvider<ResourceResolver>);
property resolversProvider
protected readonly resolversProvider: ContributionProvider<ResourceResolver>;
method get
get: (uri: URI) => Promise<Resource>;
Reject if a resource cannot be provided.
class DisposableCollection
class DisposableCollection implements Disposable {}
Utility for tracking a collection of Disposable objects.
This utility provides a number of benefits over just using an array of Disposables:
- the collection is auto-pruned when an element it contains is disposed by any code that has a reference to it - you can register to be notified when all elements in the collection have been disposed [1] - you can conveniently dispose all elements by calling dispose() on the collection
Unlike an array, however, this utility does not give you direct access to its elements.
Being notified when all elements are disposed is simple:
const dc = new DisposableCollection(myDisposables);dc.onDispose(() => {console.log('All elements in the collection have been disposed');});[1] The collection will notify only once. It will continue to function in so far as accepting new Disposables and pruning them when they are disposed, but such activity will never result in another notification.
constructor
constructor(...toDispose: Disposable[]);
property disposables
protected readonly disposables: Disposable[];
property disposed
readonly disposed: boolean;
property onDispose
readonly onDispose: Event<void>;
This event is fired only once on first dispose of not empty collection.
property onDisposeEmitter
protected readonly onDisposeEmitter: Emitter<void>;
method checkDisposed
protected checkDisposed: () => void;
method dispose
dispose: () => void;
method push
push: (disposable: Disposable) => Disposable;
method pushAll
pushAll: (disposables: Disposable[]) => Disposable[];
class DisposableWrapper
class DisposableWrapper implements Disposable {}
Wrapper for a Disposable that is not available immediately.
class Emitter
class Emitter<T = any> {}
constructor
constructor(_options?: EmitterOptions);
property event
readonly event: Event<T>;
For the public to allow to subscribe to events from this Emitter
method checkMaxListeners
protected checkMaxListeners: (maxListeners: number) => (() => void) | undefined;
method dispose
dispose: () => void;
method fire
fire: (event: T) => any;
To be kept private to fire an event to subscribers
method popLeakingStack
protected popLeakingStack: (stack: string) => void;
method pushLeakingStack
protected pushLeakingStack: () => () => void;
method sequence
sequence: ( processor: (listener: (e: T) => any) => MaybePromise<boolean>) => Promise<void>;
Process each listener one by one. Return
false
to stop iterating over the listeners,true
to continue.
class InMemoryResources
class InMemoryResources implements ResourceResolver {}
property resources
protected readonly resources: SyncReferenceCollection<string, MutableResource>;
method acquire
protected acquire: (uri: string) => ReferenceMutableResource;
method add
add: (uri: URI, contents: string) => Resource;
method resolve
resolve: (uri: URI) => Resource;
method update
update: (uri: URI, contents: string) => Resource;
class InMemoryTextResource
class InMemoryTextResource implements Resource {}
Resource implementation for 'mem-txt' URI scheme where content is saved in URI query.
constructor
constructor(uri: URI);
property uri
readonly uri: URI;
method dispose
dispose: () => void;
method readContents
readContents: ( options?: { encoding?: string | undefined } | undefined) => Promise<string>;
class InMemoryTextResourceResolver
class InMemoryTextResourceResolver implements ResourceResolver {}
ResourceResolver implementation for 'mem-txt' URI scheme.
method resolve
resolve: (uri: URI) => MaybePromise<Resource>;
class JsonRpcConnectionHandler
class JsonRpcConnectionHandler<T extends object> extends RpcConnectionHandler<T> {}
Deprecated
since 1.39.0 use
RpcConnectionHandler
instead
class JsonRpcProxyFactory
class JsonRpcProxyFactory<T extends object> extends RpcProxyFactory<T> {}
Deprecated
since 1.39.0 use
RpcProxyFactory
instead
class Logger
class Logger implements ILogger {}
property created
protected created: Promise<void>;
property factory
protected readonly factory: LoggerFactory;
property loggerWatcher
protected readonly loggerWatcher: LoggerWatcher;
property name
protected name: string;
property server
protected readonly server: ILoggerServer;
method child
child: (name: string) => ILogger;
method debug
debug: (arg: any | Loggable, ...params: any[]) => Promise<void>;
method error
error: (arg: any | Loggable, ...params: any[]) => Promise<void>;
method fatal
fatal: (arg: any | Loggable, ...params: any[]) => Promise<void>;
method format
protected format: (value: any) => any;
method getLog
protected getLog: (logLevel: number) => Promise<Log>;
method getLogLevel
getLogLevel: () => Promise<number>;
method ifDebug
ifDebug: () => Promise<void>;
method ifEnabled
ifEnabled: (logLevel: number) => Promise<void>;
method ifError
ifError: () => Promise<void>;
method ifFatal
ifFatal: () => Promise<void>;
method ifInfo
ifInfo: () => Promise<void>;
method ifTrace
ifTrace: () => Promise<void>;
method ifWarn
ifWarn: () => Promise<void>;
method info
info: (arg: any | Loggable, ...params: any[]) => Promise<void>;
method init
protected init: () => void;
method isDebug
isDebug: () => Promise<boolean>;
method isEnabled
isEnabled: (logLevel: number) => Promise<boolean>;
method isError
isError: () => Promise<boolean>;
method isFatal
isFatal: () => Promise<boolean>;
method isInfo
isInfo: () => Promise<boolean>;
method isTrace
isTrace: () => Promise<boolean>;
method isWarn
isWarn: () => Promise<boolean>;
method log
log: (logLevel: number, arg2: any | Loggable, ...params: any[]) => Promise<void>;
method setLogLevel
setLogLevel: (logLevel: number) => Promise<void>;
method trace
trace: (arg: any | Loggable, ...params: any[]) => Promise<void>;
method warn
warn: (arg: any | Loggable, ...params: any[]) => Promise<void>;
class MenuCommandAdapterRegistryImpl
class MenuCommandAdapterRegistryImpl implements MenuCommandAdapterRegistry {}
property adapters
protected readonly adapters: MenuCommandAdapter[];
method getAdapterFor
getAdapterFor: ( menuPath: MenuPath, command: string, ...commandArgs: unknown[]) => MenuCommandAdapter | undefined;
method registerAdapter
registerAdapter: (adapter: MenuCommandAdapter) => Disposable;
class MenuCommandExecutorImpl
class MenuCommandExecutorImpl implements MenuCommandExecutor {}
property adapterRegistry
protected readonly adapterRegistry: MenuCommandAdapterRegistry;
property commandRegistry
protected readonly commandRegistry: CommandRegistry;
method delegate
protected delegate: <T extends keyof MenuCommandExecutor>( menuPath: MenuPath, command: string, commandArgs: unknown[], method: T) => ReturnType<MenuCommandExecutor[T]>;
method executeCommand
executeCommand: ( menuPath: MenuPath, command: string, ...commandArgs: unknown[]) => Promise<unknown>;
method isEnabled
isEnabled: ( menuPath: MenuPath, command: string, ...commandArgs: unknown[]) => boolean;
method isToggled
isToggled: ( menuPath: MenuPath, command: string, ...commandArgs: unknown[]) => boolean;
method isVisible
isVisible: ( menuPath: MenuPath, command: string, ...commandArgs: unknown[]) => boolean;
class MenuModelRegistry
class MenuModelRegistry {}
The MenuModelRegistry allows to register and unregister menus, submenus and actions via strings and MenuActions without the need to access the underlying UI representation.
constructor
constructor( contributions: ContributionProvider<MenuContribution>, commands: CommandRegistry);
property commands
protected readonly commands: CommandRegistry;
property contributions
protected readonly contributions: ContributionProvider<MenuContribution>;
property independentSubmenus
protected readonly independentSubmenus: Map<string, MutableCompoundMenuNode>;
property isReady
protected isReady: boolean;
property onDidChange
readonly onDidChange: Event<void>;
property onDidChangeEmitter
protected readonly onDidChangeEmitter: Emitter<void>;
property root
protected readonly root: CompositeMenuNode;
method allChildrenCompound
protected allChildrenCompound: (children: ReadonlyArray<MenuNode>) => boolean;
method changeEventOnDispose
protected changeEventOnDispose: (disposable: Disposable) => Disposable;
method findGroup
protected findGroup: ( menuPath: MenuPath, options?: SubMenuOptions) => MutableCompoundMenuNode;
Finds a submenu as a descendant of the
root
node. See .
method findSubMenu
protected findSubMenu: ( current: MutableCompoundMenuNode, menuId: string, options?: SubMenuOptions) => MutableCompoundMenuNode;
Finds or creates a submenu as an immediate child of
current
.Throws
if a node with the given
menuId
exists but is not a MutableCompoundMenuNode.
method fireChangeEvent
protected fireChangeEvent: () => void;
method getMenu
getMenu: (menuPath?: MenuPath) => MutableCompoundMenuNode;
Returns the menu at the given path.
Parameter menuPath
the path specifying the menu to return. If not given the empty path will be used.
Returns
the root menu when
menuPath
is empty. IfmenuPath
is not empty the specified menu is returned if it exists, otherwise an error is thrown.
method getMenuNode
getMenuNode: ( menuPath: MenuPath | string, group?: string) => MutableCompoundMenuNode;
method getPath
getPath: (node: MenuNode) => MenuPath | undefined;
Returns the at which a given menu node can be accessed from this registry, if it can be determined. Returns
undefined
if theparent
of any node in the chain is unknown.
method isEmpty
protected isEmpty: (children: ReadonlyArray<MenuNode>) => boolean;
method linkSubmenu
linkSubmenu: ( parentPath: MenuPath | string, childId: string | MenuPath, options?: SubMenuOptions, group?: string) => Disposable;
method onStart
onStart: () => void;
method registerIndependentSubmenu
registerIndependentSubmenu: ( id: string, label: string, options?: SubMenuOptions) => Disposable;
method registerMenuAction
registerMenuAction: (menuPath: MenuPath, item: MenuAction) => Disposable;
Adds the given menu action to the menu denoted by the given path.
Returns
a disposable which, when called, will remove the menu action again.
method registerMenuNode
registerMenuNode: ( menuPath: MenuPath | string, menuNode: MenuNode, group?: string) => Disposable;
Adds the given menu node to the menu denoted by the given path.
Returns
a disposable which, when called, will remove the menu node again.
method registerSubmenu
registerSubmenu: ( menuPath: MenuPath, label: string, options?: SubMenuOptions) => Disposable;
Register a new menu at the given path with the given label. (If the menu already exists without a label, iconClass or order this method can be used to set them.)
Parameter menuPath
the path for which a new submenu shall be registered.
Parameter label
the label to be used for the new submenu.
Parameter options
optionally allows to set an icon class and specify the order of the new menu.
Returns
if the menu was successfully created a disposable will be returned which, when called, will remove the menu again. If the menu already existed a no-op disposable will be returned.
Note that if the menu already existed and was registered with a different label an error will be thrown.
method removeSingleRootNode
removeSingleRootNode: ( fullMenuModel: MutableCompoundMenuNode, menuPath: MenuPath) => CompoundMenuNode;
Checks the given menu model whether it will show a menu with a single submenu.
Parameter fullMenuModel
the menu model to analyze
Parameter menuPath
the menu's path
Returns
if the menu will show a single submenu this returns a menu that will show the child elements of the submenu, otherwise the given
fullMenuModel
is return
method unregisterMenuAction
unregisterMenuAction: { (item: MenuAction, menuPath?: MenuPath): void; (command: Command, menuPath?: MenuPath): void; (id: string, menuPath?: MenuPath): void;};
Unregister all menu nodes with the same id as the given menu action.
Parameter item
the item whose id will be used.
Parameter menuPath
if specified only nodes within the path will be unregistered.
Unregister all menu nodes with the same id as the given command.
Parameter command
the command whose id will be used.
Parameter menuPath
if specified only nodes within the path will be unregistered.
Unregister all menu nodes with the given id.
Parameter id
the id which shall be removed.
Parameter menuPath
if specified only nodes within the path will be unregistered.
method unregisterMenuNode
unregisterMenuNode: (id: string) => void;
Recurse all menus, removing any menus matching the
id
.Parameter id
technical identifier of the
MenuNode
.
class MessageClient
class MessageClient {}
method reportProgress
reportProgress: ( progressId: string, update: ProgressUpdate, message: ProgressMessage, cancellationToken: CancellationToken) => Promise<void>;
Update a previously created progress message.
To be implemented by an extension, e.g. by the messages extension.
method showMessage
showMessage: (message: Message) => Promise<string | undefined>;
Show a message of the given type and possible actions to the user. Resolve to a chosen action. Never reject.
To be implemented by an extension, e.g. by the messages extension.
method showProgress
showProgress: ( progressId: string, message: ProgressMessage, cancellationToken: CancellationToken) => Promise<string | undefined>;
Show a progress message with possible actions to user.
To be implemented by an extension, e.g. by the messages extension.
class MessageService
class MessageService {}
Service to log and categorize messages, show progress information and offer actions.
The messages are processed by this service and forwarded to an injected MessageClient. For example "@theia/messages" provides such a client, rendering messages as notifications in the frontend.
### Example usage
@inject(MessageService)protected readonly messageService: MessageService;messageService.warn("Typings not available");messageService.error("Could not restore state", ["Rollback", "Ignore"]).then(action => action === "Rollback" && rollback());
constructor
constructor(client: MessageClient);
property client
protected readonly client: MessageClient;
method error
error: { <T extends string>(message: string, ...actions: T[]): Promise<T | undefined>; <T extends string>( message: string, options?: MessageOptions, ...actions: T[] ): Promise<T>;};
Logs the message as "error" and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.Logs the message as "error" and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter options
additional options. Can be omitted
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.
method info
info: { <T extends string>(message: string, ...actions: T[]): Promise<T | undefined>; <T extends string>( message: string, options?: MessageOptions, ...actions: T[] ): Promise<T>;};
Logs the message as "info" and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.Logs the message as "info" and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter options
additional options. Can be omitted
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.
method log
log: { <T extends string>(message: string, ...actions: T[]): Promise<T | undefined>; <T extends string>( message: string, options?: MessageOptions, ...actions: T[] ): Promise<T>;};
Logs the message and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.Logs the message and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter options
additional options. Can be omitted
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.
method newProgressId
protected newProgressId: () => string;
method processMessage
protected processMessage: ( type: MessageType, text: string, args?: any[]) => Promise<string | undefined>;
method showProgress
showProgress: ( message: ProgressMessage, onDidCancel?: () => void) => Promise<Progress>;
Shows the given message as a progress.
Parameter message
the message to show for the progress.
Parameter onDidCancel
an optional callback which will be invoked if the progress indicator was canceled.
Returns
a promise resolving to a Progress object with which the progress can be updated.
### Example usage
@inject(MessageService)protected readonly messageService: MessageService;// this will show "Progress" as a cancelable messagethis.messageService.showProgress({text: 'Progress'});// this will show "Rolling back" with "Cancel" and an additional "Skip" actionthis.messageService.showProgress({text: `Rolling back`,actions: ["Skip"],},() => console.log("canceled")).then((progress) => {// register if interested in the result (only necessary for custom actions)progress.result.then((result) => {// will be 'Cancel', 'Skip' or `undefined`console.log("result is", result);});progress.report({message: "Cleaning references", work: {done: 10, total: 100}});progress.report({message: "Restoring previous state", work: {done: 80, total: 100}});progress.report({message: "Complete", work: {done: 100, total: 100}});// we are done so we can cancel the progress message, note that this will also invoke `onDidCancel`progress.cancel();});
method warn
warn: { <T extends string>(message: string, ...actions: T[]): Promise<T | undefined>; <T extends string>( message: string, options?: MessageOptions, ...actions: T[] ): Promise<T>;};
Logs the message as "warning" and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.Logs the message as "warning" and, if given, offers actions to act on it.
Parameter message
the message to log.
Parameter options
additional options. Can be omitted
Parameter actions
the actions to offer. Can be omitted.
Returns
the selected action if there is any,
undefined
when there was no action or none was selected.
class MutableResource
class MutableResource implements Resource {}
constructor
constructor(uri: URI);
property onDidChangeContents
readonly onDidChangeContents: Event<void>;
property onDidChangeContentsEmitter
protected readonly onDidChangeContentsEmitter: Emitter<void>;
property uri
readonly uri: URI;
method dispose
dispose: () => void;
method fireDidChangeContents
protected fireDidChangeContents: () => void;
method readContents
readContents: () => Promise<string>;
method saveContents
saveContents: (contents: string) => Promise<void>;
class NullBackendStopwatch
class NullBackendStopwatch implements BackendStopwatch {}
No-op implementation of the (remote) back-end stopwatch service.
class Path
class Path {}
constructor
constructor(raw: string);
The raw should be normalized, meaning that only '/' is allowed as a path separator.
property base
readonly base: string;
property dir
readonly dir: Path;
Returns the parent directory if it exists (
hasDir === true
) orthis
otherwise.
property ext
readonly ext: string;
property hasDir
readonly hasDir: boolean;
Returns
true
if this has a parent directory,false
otherwise._This implementation returns
true
if and only if this is not the root dir and there is a path separator in the raw path._
property isAbsolute
readonly isAbsolute: boolean;
property isRoot
readonly isRoot: boolean;
property name
readonly name: string;
property root
readonly root: Path;
property separator
static separator: string;
method computeDir
protected computeDir: () => Path;
method computeRoot
protected computeRoot: () => Path | undefined;
method fsPath
fsPath: (format?: Path.Format) => string;
Converts the current path into a file system path.
Parameter format
Determines the format of the path. If
undefined
, the format will be determined by theOS.backend.type
value.Returns
A file system path.
method isDrive
static isDrive: (segment: string) => boolean;
method isEqualOrParent
isEqualOrParent: (path: Path) => boolean;
method join
join: (...paths: string[]) => Path;
method normalize
normalize: () => Path;
method normalizeDrive
static normalizeDrive: (path: string) => string;
vscode-uri always normalizes drive letters to lower case: https://github.com/Microsoft/vscode-uri/blob/b1d3221579f97f28a839b6f996d76fc45e9964d8/src/index.ts#L1025 Theia path should be adjusted to this.
method normalizePathSeparator
static normalizePathSeparator: (path: string) => string;
Normalize path separator to use Path.separator
Parameter Path
candidate to normalize
Returns
Normalized string path
method relative
relative: (path: Path) => Path | undefined;
method relativity
relativity: (path: Path) => number;
method resolve
resolve: (...paths: string[]) => Path | undefined;
Parameter paths
portions of a path
Returns
a new Path if an absolute path can be computed from the segments passed in + this.raw If no absolute path can be computed, returns undefined.
Processes the path segments passed in from right to left (reverse order) concatenating until an absolute path is found.
method tildify
static tildify: (resourcePath: string, home: string) => string;
Tildify path, replacing
home
with~
if user'shome
is present at the beginning of the path. This is a non-operation for Windows.Parameter resourcePath
Parameter home
method toString
toString: () => string;
method untildify
static untildify: (resourcePath: string, home: string) => string;
Untildify path, replacing
~
withhome
if~
present at the beginning of the path. This is a non-operation for Windows.Parameter resourcePath
Parameter home
method windowsPath
static windowsPath: (path: string) => string;
Creates a windows path from the given path string. A windows path uses an upper case drive letter and backwards slashes.
Parameter path
The input path
Returns
Windows style path
class ProgressService
class ProgressService {}
property client
protected readonly client: ProgressClient;
property messageService
protected readonly messageService: MessageService;
method newProgressId
protected newProgressId: () => string;
method shouldDelegate
protected shouldDelegate: (message: ProgressMessage) => boolean;
method showProgress
showProgress: ( message: ProgressMessage, onDidCancel?: () => void) => Promise<Progress>;
method withProgress
withProgress: <T>( text: string, locationId: string, task: () => Promise<T>, onDidCancel?: () => void) => Promise<T>;
class QueueableEmitter
class QueueableEmitter<T> extends Emitter<T[]> {}
property currentQueue
currentQueue?: T[];
method fire
fire: () => void;
method queue
queue: (...arg: T[]) => void;
class ReferenceCollection
class ReferenceCollection< K, V extends Disposable> extends AbstractReferenceCollection<K, V> {}
Asynchronous implementation of AbstractReferenceCollection that requires the client to provide a value factory, used to service the acquire() function. That factory may return a Promise if the value cannot be created immediately.
constructor
constructor(factory: (key: K) => MaybePromise<V>);
property factory
protected readonly factory: (key: K) => MaybePromise<V>;
property pendingValues
protected readonly pendingValues: Map<string, MaybePromise<V>>;
method acquire
acquire: (args: K) => Promise<Reference<V>>;
method getOrCreateValue
protected getOrCreateValue: (key: string, args: K) => Promise<V>;
class ReferenceMutableResource
class ReferenceMutableResource implements Resource {}
constructor
constructor(reference: Reference<MutableResource>);
property onDidChangeContents
readonly onDidChangeContents: Event<void>;
property reference
protected reference: Reference<MutableResource>;
property uri
readonly uri: URI;
method dispose
dispose: () => void;
method readContents
readContents: () => Promise<string>;
method saveContents
saveContents: (contents: string) => Promise<void>;
class RpcConnectionHandler
class RpcConnectionHandler<T extends object> implements ConnectionHandler {}
constructor
constructor( path: string, targetFactory: (proxy: RpcProxy<T>) => any, factoryConstructor?: new () => RpcProxyFactory<T>);
property factoryConstructor
readonly factoryConstructor: new () => RpcProxyFactory<T>;
property path
readonly path: string;
property targetFactory
readonly targetFactory: (proxy: RpcProxy<T>) => any;
method onConnection
onConnection: (connection: Channel) => void;
class RpcProtocol
class RpcProtocol {}
Establish a RPC protocol on top of a given channel. By default the rpc protocol is bi-directional, meaning it is possible to send requests and notifications to the remote side (i.e. acts as client) as well as receiving requests and notifications from the remote side (i.e. acts as a server). Clients can get a promise for a remote request result that will be either resolved or rejected depending on the success of the request. Keeps track of outstanding requests and matches replies to the appropriate request Currently, there is no timeout handling for long running requests implemented. The bi-directional mode can be reconfigured using the RpcProtocolOptions to construct an RPC protocol instance that acts only as client or server instead.
constructor
constructor( channel: Channel, requestHandler: RequestHandler, options?: RpcProtocolOptions);
property CANCELLATION_TOKEN_KEY
static readonly CANCELLATION_TOKEN_KEY: string;
property cancellationTokenSources
protected readonly cancellationTokenSources: Map< number, CancellationTokenSource>;
property channel
readonly channel: Channel;
property decoder
protected readonly decoder: RpcMessageDecoder;
property encoder
protected readonly encoder: RpcMessageEncoder;
property mode
protected readonly mode: 'default' | 'clientOnly' | 'serverOnly';
property nextMessageId
protected nextMessageId: number;
property onNotification
readonly onNotification: Event<{ method: string; args: any[] }>;
property onNotificationEmitter
protected readonly onNotificationEmitter: Emitter<{ method: string; args: any[];}>;
property pendingRequestCancellationEventListeners
protected readonly pendingRequestCancellationEventListeners: Map< number, DisposableWrapper>;
property pendingRequests
protected readonly pendingRequests: Map<number, Deferred<any>>;
property requestHandler
readonly requestHandler: RequestHandler;
property toDispose
protected toDispose: DisposableCollection;
method disposeCancellationEventListener
protected disposeCancellationEventListener: (id: number) => void;
method handleCancel
protected handleCancel: (id: number) => void;
method handleMessage
handleMessage: (message: RpcMessage) => void;
method handleNotify
protected handleNotify: ( method: string, args: any[], id?: number) => Promise<void>;
method handleReply
protected handleReply: (id: number, value: any) => void;
method handleReplyErr
protected handleReplyErr: (id: number, error: any) => void;
method handleRequest
protected handleRequest: ( id: number, method: string, args: any[]) => Promise<void>;
method sendCancel
sendCancel: (requestId: number) => void;
method sendNotification
sendNotification: (method: string, args: any[]) => void;
method sendRequest
sendRequest: <T>(method: string, args: any[]) => Promise<T>;
class RpcProxyFactory
class RpcProxyFactory<T extends object> implements ProxyHandler<T> {}
Factory for RPC proxy objects.
A RPC proxy exposes the programmatic interface of an object through Theia's RPC protocol. This allows remote programs to call methods of this objects by sending RPC requests. This takes place over a bi-directional stream, where both ends can expose an object and both can call methods on each other' exposed object.
For example, assuming we have an object of the following type on one end:
class Foo { bar(baz: number): number { return baz + 1 } }
which we want to expose through a RPC interface. We would do:
let target = new Foo() let factory = new RpcProxyFactory('/foo', target) factory.onConnection(connection)
The party at the other end of the
connection
, in order to remotely call methods on this object would do:let factory = new RpcProxyFactory('/foo') factory.onConnection(connection) let proxy = factory.createProxy(); let result = proxy.bar(42) // result is equal to 43
One the wire, it would look like this:
--> { "type":"1", "id": 1, "method": "bar", "args": [42]} <-- { "type":"3", "id": 1, "res": 43}
Note that in the code of the caller, we didn't pass a target object to RpcProxyFactory, because we don't want/need to expose an object. If we had passed a target object, the other side could've called methods on it.
Parameter
- The type of the object to expose to RPC.
constructor
constructor(target?: any, rpcProtocolFactory?: RpcProtocolFactory);
Build a new RpcProxyFactory.
Parameter target
The object to expose to RPC methods calls. If this is omitted, the proxy won't be able to handle requests, only send them.
property onDidCloseConnectionEmitter
protected readonly onDidCloseConnectionEmitter: Emitter<void>;
property onDidOpenConnectionEmitter
protected readonly onDidOpenConnectionEmitter: Emitter<void>;
property rpcDeferred
protected rpcDeferred: Deferred<RpcProtocol>;
property rpcProtocolFactory
protected rpcProtocolFactory: RpcProtocolFactory;
property target
target?: any;
method createProxy
createProxy: () => RpcProxy<T>;
Create a Proxy exposing the interface of an object of type T. This Proxy can be used to do RPC method calls on the remote target object as if it was local.
If
T
implementsRpcServer
then a client is used as a target object for a remote target object.
method deserializeError
protected deserializeError: (capturedError: Error, e: any) => any;
method get
get: (target: T, p: PropertyKey, receiver: any) => any;
Get a callable object that executes a RPC method call.
Getting a property on the Proxy object returns a callable that, when called, executes a RPC call. The name of the property defines the method to be called. The callable takes a variable number of arguments, which are passed in the RPC method call.
For example, if you have a Proxy object:
let fooProxyFactory = RpcProxyFactory('/foo') let fooProxy = fooProxyFactory.createProxy()
accessing
fooProxy.bar
will return a callable that, when called, executes a RPC method call to methodbar
. Therefore, doingfooProxy.bar()
will call thebar
method on the remote Foo object.Parameter target
unused.
Parameter p
The property accessed on the Proxy object.
Parameter receiver
unused.
Returns
A callable that executes the RPC call.
method isNotification
protected isNotification: (p: PropertyKey) => boolean;
Return whether the given property represents a notification.
A property leads to a notification rather than a method call if its name begins with
notify
oron
.Parameter p
The property being called on the proxy. Whether
p
represents a notification.
method listen
listen: (channel: Channel) => void;
Connect a Channel to the factory by creating an RpcProtocol on top of it.
This protocol will be used to send/receive RPC requests and responses.
method onNotification
protected onNotification: (method: string, ...args: any[]) => void;
Process an incoming RPC notification.
Same as [[onRequest]], but called on incoming notifications rather than methods calls.
method onRequest
protected onRequest: (method: string, ...args: any[]) => Promise<any>;
Process an incoming RPC method call.
onRequest is called when the RPC connection received a method call request. It calls the corresponding method on [[target]].
The return value is a Promise object that is resolved with the return value of the method call, if it is successful. The promise is rejected if the called method does not exist or if it throws.
Returns
A promise of the method call completion.
method serializeError
protected serializeError: (e: any) => any;
method waitForConnection
protected waitForConnection: () => void;
class SelectionService
class SelectionService implements SelectionProvider<Object | undefined> {}
Singleton service that is used to share the current selection globally in a Theia application. On each change of selection, subscribers are notified and receive the updated selection object.
property onSelectionChanged
readonly onSelectionChanged: Event<any>;
property onSelectionChangedEmitter
protected readonly onSelectionChangedEmitter: Emitter<any>;
property selection
selection: Object;
class Stopwatch
abstract class Stopwatch {}
A factory of Measurements for performance logging.
constructor
constructor(defaultLogOptions: LogOptions);
property defaultLogOptions
protected readonly defaultLogOptions: LogOptions;
property logger
protected readonly logger: ILogger;
property onDidAddMeasurementResult
readonly onDidAddMeasurementResult: Event<MeasurementResult>;
property onDidAddMeasurementResultEmitter
protected onDidAddMeasurementResultEmitter: Emitter<MeasurementResult>;
property storedMeasurements
readonly storedMeasurements: readonly MeasurementResult[];
method atLevel
protected atLevel: ( logOptions: LogOptions, levelOverride?: