提交 8abc9e4a 编写于 作者: A Alex Dima

more improvements for #78168

上级 3015179c
......@@ -70,6 +70,7 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
private readonly _markerDecorationsService: IMarkerDecorationsService
) {
this._editor = editor;
this._result = [];
}
setRange(range: Range): void {
......
......@@ -27,6 +27,7 @@ class MarginComputer implements IHoverComputer<IHoverMessage[]> {
constructor(editor: ICodeEditor) {
this._editor = editor;
this._lineNumber = -1;
this._result = [];
}
public setLineNumber(lineNumber: number): void {
......@@ -100,6 +101,7 @@ export class ModesGlyphHoverWidget extends GlyphHoverWidget {
) {
super(ModesGlyphHoverWidget.ID, editor);
this._messages = [];
this._lastLineNumber = -1;
this._markdownRenderer = this._register(new MarkdownRenderer(this._editor, modeService, openerService));
......
......@@ -378,11 +378,12 @@ export class AutoIndentOnPasteCommand implements ICommand {
private readonly _edits: { range: IRange; text: string; eol?: EndOfLineSequence; }[];
private readonly _initialSelection: Selection;
private _selectionId: string;
private _selectionId: string | null;
constructor(edits: TextEdit[], initialSelection: Selection) {
this._initialSelection = initialSelection;
this._edits = [];
this._selectionId = null;
for (let edit of edits) {
if (edit.range && typeof edit.text === 'string') {
......@@ -415,7 +416,7 @@ export class AutoIndentOnPasteCommand implements ICommand {
}
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
return helper.getTrackedSelection(this._selectionId);
return helper.getTrackedSelection(this._selectionId!);
}
}
......@@ -651,7 +652,7 @@ function getIndentationEditOperations(model: ITextModel, builder: IEditOperation
export class IndentationToSpacesCommand implements ICommand {
private selectionId: string;
private selectionId: string | null = null;
constructor(private readonly selection: Selection, private tabSize: number) { }
......@@ -661,13 +662,13 @@ export class IndentationToSpacesCommand implements ICommand {
}
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
return helper.getTrackedSelection(this.selectionId);
return helper.getTrackedSelection(this.selectionId!);
}
}
export class IndentationToTabsCommand implements ICommand {
private selectionId: string;
private selectionId: string | null = null;
constructor(private readonly selection: Selection, private tabSize: number) { }
......@@ -677,7 +678,7 @@ export class IndentationToTabsCommand implements ICommand {
}
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
return helper.getTrackedSelection(this.selectionId);
return helper.getTrackedSelection(this.selectionId!);
}
}
......@@ -688,4 +689,4 @@ registerEditorAction(IndentUsingTabs);
registerEditorAction(IndentUsingSpaces);
registerEditorAction(DetectIndentation);
registerEditorAction(ReindentLinesAction);
registerEditorAction(ReindentSelectedLinesAction);
\ No newline at end of file
registerEditorAction(ReindentSelectedLinesAction);
......@@ -14,13 +14,17 @@ export class CopyLinesCommand implements editorCommon.ICommand {
private readonly _isCopyingDown: boolean;
private _selectionDirection: SelectionDirection;
private _selectionId: string;
private _selectionId: string | null;
private _startLineNumberDelta: number;
private _endLineNumberDelta: number;
constructor(selection: Selection, isCopyingDown: boolean) {
this._selection = selection;
this._isCopyingDown = isCopyingDown;
this._selectionDirection = SelectionDirection.LTR;
this._selectionId = null;
this._startLineNumberDelta = 0;
this._endLineNumberDelta = 0;
}
public getEditOperations(model: ITextModel, builder: editorCommon.IEditOperationBuilder): void {
......@@ -58,7 +62,7 @@ export class CopyLinesCommand implements editorCommon.ICommand {
}
public computeCursorState(model: ITextModel, helper: editorCommon.ICursorStateComputerData): Selection {
let result = helper.getTrackedSelection(this._selectionId);
let result = helper.getTrackedSelection(this._selectionId!);
if (this._startLineNumberDelta !== 0 || this._endLineNumberDelta !== 0) {
let startLineNumber = result.startLineNumber;
......
......@@ -20,7 +20,7 @@ export class MoveLinesCommand implements ICommand {
private readonly _isMovingDown: boolean;
private readonly _autoIndent: boolean;
private _selectionId: string;
private _selectionId: string | null;
private _moveEndPositionDown?: boolean;
private _moveEndLineSelectionShrink: boolean;
......@@ -28,6 +28,7 @@ export class MoveLinesCommand implements ICommand {
this._selection = selection;
this._isMovingDown = isMovingDown;
this._autoIndent = autoIndent;
this._selectionId = null;
this._moveEndLineSelectionShrink = false;
}
......@@ -36,9 +37,11 @@ export class MoveLinesCommand implements ICommand {
let modelLineCount = model.getLineCount();
if (this._isMovingDown && this._selection.endLineNumber === modelLineCount) {
this._selectionId = builder.trackSelection(this._selection);
return;
}
if (!this._isMovingDown && this._selection.startLineNumber === 1) {
this._selectionId = builder.trackSelection(this._selection);
return;
}
......@@ -328,7 +331,7 @@ export class MoveLinesCommand implements ICommand {
}
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
let result = helper.getTrackedSelection(this._selectionId);
let result = helper.getTrackedSelection(this._selectionId!);
if (this._moveEndPositionDown) {
result = result.setEndPosition(result.endLineNumber + 1, 1);
......
......@@ -12,12 +12,13 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod
export class SortLinesCommand implements editorCommon.ICommand {
private readonly selection: Selection;
private selectionId: string;
private readonly descending: boolean;
private selectionId: string | null;
constructor(selection: Selection, descending: boolean) {
this.selection = selection;
this.descending = descending;
this.selectionId = null;
}
public getEditOperations(model: ITextModel, builder: editorCommon.IEditOperationBuilder): void {
......@@ -30,7 +31,7 @@ export class SortLinesCommand implements editorCommon.ICommand {
}
public computeCursorState(model: ITextModel, helper: editorCommon.ICursorStateComputerData): Selection {
return helper.getTrackedSelection(this.selectionId);
return helper.getTrackedSelection(this.selectionId!);
}
public static canRun(model: ITextModel | null, selection: Selection, descending: boolean): boolean {
......
......@@ -469,6 +469,7 @@ class WordHighlighterContribution extends Disposable implements editorCommon.IEd
constructor(editor: ICodeEditor, @IContextKeyService contextKeyService: IContextKeyService) {
super();
this.wordHighligher = null;
const createWordHighlighterIfPossible = () => {
if (editor.hasModel()) {
this.wordHighligher = new WordHighlighter(editor, contextKeyService);
......
......@@ -21,6 +21,7 @@ export class IPadShowKeyboard extends Disposable implements IEditorContribution
constructor(editor: ICodeEditor) {
super();
this.editor = editor;
this.widget = null;
if (browser.isIPad) {
this._register(editor.onDidChangeConfiguration(() => this.update()));
this.update();
......
......@@ -98,17 +98,20 @@ function withTypedEditor<T>(widget: editorCommon.IEditor, codeEditorCallback: (e
export class SimpleEditorModelResolverService implements ITextModelService {
public _serviceBrand: any;
private editor: editorCommon.IEditor;
private editor?: editorCommon.IEditor;
public setEditor(editor: editorCommon.IEditor): void {
this.editor = editor;
}
public createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
let model: ITextModel | null = withTypedEditor(this.editor,
(editor) => this.findModel(editor, resource),
(diffEditor) => this.findModel(diffEditor.getOriginalEditor(), resource) || this.findModel(diffEditor.getModifiedEditor(), resource)
);
let model: ITextModel | null = null;
if (this.editor) {
model = withTypedEditor(this.editor,
(editor) => this.findModel(editor, resource),
(diffEditor) => this.findModel(diffEditor.getOriginalEditor(), resource) || this.findModel(diffEditor.getModifiedEditor(), resource)
);
}
if (!model) {
return Promise.reject(new Error(`Model not found`));
......@@ -477,12 +480,12 @@ export class SimpleResourceConfigurationService implements ITextResourceConfigur
_serviceBrand: any;
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent>;
private readonly _onDidChangeConfigurationEmitter = new Emitter();
private readonly _onDidChangeConfiguration = new Emitter<IConfigurationChangeEvent>();
public readonly onDidChangeConfiguration = this._onDidChangeConfiguration.event;
constructor(private readonly configurationService: SimpleConfigurationService) {
this.configurationService.onDidChangeConfiguration((e) => {
this._onDidChangeConfigurationEmitter.fire(e);
this._onDidChangeConfiguration.fire(e);
});
}
......@@ -519,7 +522,7 @@ export class SimpleResourcePropertiesService implements ITextResourcePropertiesS
}
export class StandaloneTelemetryService implements ITelemetryService {
_serviceBrand: void;
_serviceBrand: void = undefined;
public isOptedIn = false;
......@@ -687,7 +690,7 @@ export class SimpleLayoutService implements ILayoutService {
public onLayout = Event.None;
private _dimension: IDimension;
private _dimension?: IDimension;
get dimension(): IDimension {
if (!this._dimension) {
this._dimension = dom.getClientArea(window.document.body);
......
......@@ -176,9 +176,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
);
super(domElement, options, {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService);
if (keybindingService instanceof StandaloneKeybindingService) {
this._standaloneKeybindingService = keybindingService;
}
this._standaloneKeybindingService = <StandaloneKeybindingService>keybindingService;
// Create the ARIA dom node as soon as the first editor is instantiated
createAriaDomNode();
......
......@@ -160,7 +160,7 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
private readonly _knownThemes: Map<string, StandaloneTheme>;
private readonly _styleElement: HTMLStyleElement;
private _theme: IStandaloneTheme;
private _theme!: IStandaloneTheme;
private readonly _onThemeChange: Emitter<IStandaloneTheme>;
private readonly _onIconThemeChange: Emitter<IIconTheme>;
private readonly environment: IEnvironmentService = Object.create(null);
......
......@@ -33,7 +33,7 @@ export class RemoteExtensionsFileSystemProvider extends Disposable implements IF
private readonly _onDidChangeCapabilities = this._register(new Emitter<void>());
readonly onDidChangeCapabilities: Event<void> = this._onDidChangeCapabilities.event;
private _capabilities: FileSystemProviderCapabilities;
private _capabilities!: FileSystemProviderCapabilities;
get capabilities(): FileSystemProviderCapabilities { return this._capabilities; }
constructor(private readonly channel: IChannel, environment: Promise<IRemoteAgentEnvironment | null>) {
......
......@@ -75,7 +75,7 @@ export class VSCodeNodeModuleFactory implements INodeModuleFactory {
public readonly nodeModuleName = 'vscode';
private readonly _extApiImpl = new Map<string, typeof vscode>();
private _defaultApiImpl: typeof vscode;
private _defaultApiImpl?: typeof vscode;
constructor(
private readonly _apiFactory: IExtensionApiFactory,
......@@ -191,7 +191,7 @@ export class OpenNodeModuleFactory implements INodeModuleFactory {
public readonly nodeModuleName: string[] = ['open', 'opn'];
private _extensionId: string | undefined;
private _original: IOriginalOpen;
private _original?: IOriginalOpen;
private _impl: IOpenModule;
constructor(mainThreadWindow: MainThreadWindowShape, private _mainThreadTelemerty: MainThreadTelemetryShape, private readonly _extensionPaths: TernarySearchTree<IExtensionDescription>) {
......@@ -224,7 +224,7 @@ export class OpenNodeModuleFactory implements INodeModuleFactory {
private callOriginal(target: string, options: OpenOptions | undefined): Thenable<any> {
this.sendNoForwardTelemetry();
return this._original(target, options);
return this._original!(target, options);
}
private sendShimmingTelemetry(): void {
......
......@@ -17,9 +17,9 @@ export class ExtensionDescriptionRegistry {
public readonly onDidChange = this._onDidChange.event;
private _extensionDescriptions: IExtensionDescription[];
private _extensionsMap: Map<string, IExtensionDescription>;
private _extensionsArr: IExtensionDescription[];
private _activationMap: Map<string, IExtensionDescription[]>;
private _extensionsMap!: Map<string, IExtensionDescription>;
private _extensionsArr!: IExtensionDescription[];
private _activationMap!: Map<string, IExtensionDescription[]>;
constructor(extensionDescriptions: IExtensionDescription[]) {
this._extensionDescriptions = extensionDescriptions;
......
......@@ -20,10 +20,10 @@ export interface IRPCProtocol {
assertRegistered(identifiers: ProxyIdentifier<any>[]): void;
}
// @ts-ignore
export class ProxyIdentifier<T> {
public static count = 0;
_proxyIdentifierBrand: void;
_suppressCompilerUnusedWarning: T;
public readonly isMain: boolean;
public readonly sid: string;
......
......@@ -48,8 +48,8 @@ function getExtraDevSystemExtensionsRoot(): string {
export class CachedExtensionScanner {
public readonly scannedExtensions: Promise<IExtensionDescription[]>;
private _scannedExtensionsResolve: (result: IExtensionDescription[]) => void;
private _scannedExtensionsReject: (err: any) => void;
private _scannedExtensionsResolve!: (result: IExtensionDescription[]) => void;
private _scannedExtensionsReject!: (err: any) => void;
public readonly translationConfig: Promise<Translations>;
constructor(
......
......@@ -409,7 +409,7 @@ class ExtensionManifestValidator extends ExtensionManifestHandler {
export class ExtensionScannerInput {
public mtime: number;
public mtime: number | undefined;
constructor(
public readonly ourVersion: string,
......@@ -609,4 +609,4 @@ export class ExtensionScanner {
return resultArr;
});
}
}
\ No newline at end of file
}
......@@ -14,7 +14,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
suite('RPCProtocol', () => {
class MessagePassingProtocol implements IMessagePassingProtocol {
private _pair: MessagePassingProtocol;
private _pair?: MessagePassingProtocol;
private readonly _onMessage = new Emitter<VSBuffer>();
public readonly onMessage: Event<VSBuffer> = this._onMessage.event;
......@@ -25,7 +25,7 @@ suite('RPCProtocol', () => {
public send(buffer: VSBuffer): void {
process.nextTick(() => {
this._pair._onMessage.fire(buffer);
this._pair!._onMessage.fire(buffer);
});
}
}
......
......@@ -31,6 +31,7 @@ export abstract class AbstractRemoteAgentService extends Disposable {
@IEnvironmentService protected readonly _environmentService: IEnvironmentService
) {
super();
this._environment = null;
}
abstract getConnection(): IRemoteAgentConnection | null;
......
......@@ -31,7 +31,7 @@ export class TMScopeRegistry extends Disposable {
constructor() {
super();
this.reset();
this._scopeNameToLanguageRegistration = Object.create(null);
}
public reset(): void {
......
......@@ -80,7 +80,7 @@ class TextMateWorkerModel extends MirrorTextModel {
const languageId = this._languageId;
this._worker.getOrCreateGrammar(languageId).then((r) => {
if (this._isDisposed || languageId !== this._languageId) {
if (this._isDisposed || languageId !== this._languageId || !r) {
return;
}
......@@ -118,7 +118,7 @@ export class TextMateWorker {
private readonly _host: TextMateWorkerHost;
private readonly _models: { [uri: string]: TextMateWorkerModel; };
private readonly _grammarCache: Promise<ICreateGrammarResult>[];
private readonly _grammarFactory: TMGrammarFactory;
private readonly _grammarFactory: TMGrammarFactory | null;
constructor(ctx: IWorkerContext<TextMateWorkerHost>, createData: ICreateData) {
this._host = ctx.host;
......@@ -135,23 +135,23 @@ export class TextMateWorker {
};
});
let vscodeTextmate: typeof import('vscode-textmate');
const globalDefine = (<any>self).define;
try {
(<any>self).define.amd = undefined;
vscodeTextmate = require.__$__nodeRequire('vscode-textmate');
const vscodeTextmate = <typeof import('vscode-textmate')>require.__$__nodeRequire('vscode-textmate');
this._grammarFactory = new TMGrammarFactory({
logTrace: (msg: string) => {/* console.log(msg) */ },
logError: (msg: string, err: any) => console.error(msg, err),
readFile: (resource: URI) => this._host.readFile(resource)
}, grammarDefinitions, vscodeTextmate, undefined);
} catch (err) {
console.error(err);
this._grammarFactory = null;
return;
} finally {
(<any>self).define = globalDefine;
}
this._grammarFactory = new TMGrammarFactory({
logTrace: (msg: string) => {/* console.log(msg) */ },
logError: (msg: string, err: any) => console.error(msg, err),
readFile: (resource: URI) => this._host.readFile(resource)
}, grammarDefinitions, vscodeTextmate, undefined);
}
public acceptNewModel(data: IRawModelData): void {
......@@ -175,7 +175,10 @@ export class TextMateWorker {
}
}
public getOrCreateGrammar(languageId: LanguageId): Promise<ICreateGrammarResult> {
public getOrCreateGrammar(languageId: LanguageId): Promise<ICreateGrammarResult | null> {
if (!this._grammarFactory) {
return Promise.resolve(null);
}
if (!this._grammarCache[languageId]) {
this._grammarCache[languageId] = this._grammarFactory.createGrammar(languageId);
}
......@@ -183,7 +186,9 @@ export class TextMateWorker {
}
public acceptTheme(theme: IRawTheme): void {
this._grammarFactory.setTheme(theme);
if (this._grammarFactory) {
this._grammarFactory.setTheme(theme);
}
}
public _setTokens(resource: URI, versionId: number, tokens: Uint8Array): void {
......
......@@ -27,7 +27,7 @@ export class TestRPCProtocol implements IExtHostContext {
private _callCountValue: number = 0;
private _idle?: Promise<any>;
private _completeIdle: Function;
private _completeIdle?: Function;
private readonly _locals: { [id: string]: any; };
private readonly _proxies: { [id: string]: any; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册