Skip to content

Commit

Permalink
Clean Up theia.d.ts (#11493)
Browse files Browse the repository at this point in the history
- Changes link format to JSDoc style
- Cleans up unresolved type references (typos)
- Removes syntax errors
- Adds access modifiers where appropriate to conform to VSCode
  • Loading branch information
colin-grant-work authored Aug 30, 2022
1 parent da356b5 commit 77e8a60
Show file tree
Hide file tree
Showing 8 changed files with 609 additions and 590 deletions.
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ export interface TransferQuickPickSeparator extends theia.QuickPickItem {
}

export interface TransferQuickInputButton extends theia.QuickInputButton {
iconPath: theia.Uri | { light: theia.Uri, dark: theia.Uri } | ThemeIcon
handle?: number;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/main/browser/terminal-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { RPCProtocol } from '../../common/rpc-protocol';
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
import { SerializableEnvironmentVariableCollection } from '@theia/terminal/lib/common/base-terminal-protocol';
import { ShellTerminalServerProxy } from '@theia/terminal/lib/common/shell-terminal-protocol';
import { URI } from '@theia/core/lib/common/uri';

/**
* Plugin api service allows working with terminal emulator.
Expand Down Expand Up @@ -122,7 +123,7 @@ export class TerminalServiceMainImpl implements TerminalServiceMain, Disposable
title: options.name,
shellPath: options.shellPath,
shellArgs: options.shellArgs,
cwd: options.cwd,
cwd: new URI(options.cwd),
env: options.env,
destroyTermOnClose: true,
useServerTitle: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/authentication-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from '../common/plugin-api-rpc';
import { RPCProtocol } from '../common/rpc-protocol';
import { Emitter, Event } from '@theia/core/lib/common/event';
import * as theia from '@theia/plugin/';
import * as theia from '@theia/plugin';

export class AuthenticationExtImpl implements AuthenticationExt {
private proxy: AuthenticationMain;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/custom-editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class CustomEditorsExtImpl implements CustomEditorsExt {
disposables.push(this.editorProviders.addCustomProvider(viewType, plugin, provider));

if (this.supportEditing(provider)) {
disposables.push(provider.onDidChangeCustomDocument(e => {
disposables.push(provider.onDidChangeCustomDocument((e: theia.CustomDocumentEditEvent | theia.CustomDocumentContentChangeEvent) => {
const entry = this.getCustomDocumentEntry(viewType, e.document.uri);
if (isEditEvent(e)) {
const editId = entry.addEdit(e);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/type-converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ export function fromShellExecution(execution: theia.ShellExecution, taskDto: Tas
}
}

export function fromCustomExecution(execution: theia.CustomExecution, taskDto: TaskDto): TaskDto {
export function fromCustomExecution(execution: types.CustomExecution, taskDto: TaskDto): TaskDto {
taskDto.taskType = 'customExecution';
const callback = execution.callback;
if (callback) {
Expand Down
17 changes: 7 additions & 10 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,7 @@ export class SnippetString {

@es5ClassCompat
export class ThemeColor {
constructor(public id: string) {
}
constructor(public id: string) { }
}

@es5ClassCompat
Expand Down Expand Up @@ -1098,18 +1097,18 @@ export class SignatureHelp {
@es5ClassCompat
export class Hover {

public contents: theia.MarkdownString[] | theia.MarkedString[];
public contents: Array<theia.MarkdownString | theia.MarkedString>;
public range?: Range;

constructor(
contents: theia.MarkdownString | theia.MarkedString | theia.MarkdownString[] | theia.MarkedString[],
contents: theia.MarkdownString | theia.MarkedString | Array<theia.MarkdownString | theia.MarkedString>,
range?: Range
) {
if (!contents) {
illegalArgument('contents must be defined');
}
if (Array.isArray(contents)) {
this.contents = <theia.MarkdownString[] | theia.MarkedString[]>contents;
this.contents = contents;
} else {
this.contents = [contents];
}
Expand Down Expand Up @@ -1554,8 +1553,6 @@ export class QuickInputButtons {
static readonly Back: theia.QuickInputButton = {
iconPath: {
id: 'Back',
dark: '',
light: ''
},
tooltip: 'Back'
};
Expand Down Expand Up @@ -2739,7 +2736,7 @@ export class SemanticTokensBuilder {

@es5ClassCompat
export class SemanticTokens {
readonly resultId?: string;
readonly resultId: string | undefined;
readonly data: Uint32Array;

constructor(data: Uint32Array, resultId?: string) {
Expand All @@ -2752,7 +2749,7 @@ export class SemanticTokens {
export class SemanticTokensEdit {
readonly start: number;
readonly deleteCount: number;
readonly data?: Uint32Array;
readonly data: Uint32Array | undefined;

constructor(start: number, deleteCount: number, data?: Uint32Array) {
this.start = start;
Expand All @@ -2763,7 +2760,7 @@ export class SemanticTokensEdit {

@es5ClassCompat
export class SemanticTokensEdits {
readonly resultId?: string;
readonly resultId: string | undefined;
readonly edits: SemanticTokensEdit[];

constructor(edits: SemanticTokensEdit[], resultId?: string) {
Expand Down
47 changes: 47 additions & 0 deletions packages/plugin/src/theia-proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,23 @@ export module '@theia/plugin' {
matches: Range | Range[];
}

/**
* Options to specify the size of the result text preview.
* These options don't affect the size of the match itself, just the amount of preview text.
*/
export interface TextSearchPreviewOptions {
/**
* The maximum number of lines in the preview.
* Only search providers that support multiline search will ever return more than one line in the match.
*/
matchLines: number;

/**
* The maximum number of characters included per line.
*/
charsPerLine: number;
}

/**
* A line of context surrounding a TextSearchMatch.
*/
Expand Down Expand Up @@ -368,6 +385,18 @@ export module '@theia/plugin' {
*/
limitHit?: boolean;
}

export namespace workspace {
/**
* Find text in files across all [workspace folders] in the workspace
* @param query What to search
* @param optionsOrCallback
* @param callbackOrToken
* @param token
*/
export function findTextInFiles(query: TextSearchQuery, optionsOrCallback: FindTextInFilesOptions | ((result: TextSearchResult) => void),
callbackOrToken?: CancellationToken | ((result: TextSearchResult) => void), token?: CancellationToken): Promise<TextSearchComplete>;
}
// #endregion

// #region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
Expand Down Expand Up @@ -581,3 +610,21 @@ export module '@theia/plugin' {

// #endregion
}

/**
* Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
* and others. This API makes no assumption about what promise library is being used which
* enables reusing existing code without migrating to a specific promise implementation. Still,
* we recommend the use of native promises which are available in this editor.
*/
interface Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}

Loading

0 comments on commit 77e8a60

Please sign in to comment.