Vscode merge (#4582)

* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd

* fix issues with merges

* bump node version in azpipe

* replace license headers

* remove duplicate launch task

* fix build errors

* fix build errors

* fix tslint issues

* working through package and linux build issues

* more work

* wip

* fix packaged builds

* working through linux build errors

* wip

* wip

* wip

* fix mac and linux file limits

* iterate linux pipeline

* disable editor typing

* revert series to parallel

* remove optimize vscode from linux

* fix linting issues

* revert testing change

* add work round for new node

* readd packaging for extensions

* fix issue with angular not resolving decorator dependencies
This commit is contained in:
Anthony Dresser
2019-03-19 17:44:35 -07:00
committed by GitHub
parent 833d197412
commit 87765e8673
1879 changed files with 54505 additions and 38058 deletions

View File

@@ -30,6 +30,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { contrastBorder, editorWidgetBackground, widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey<boolean>('accessibilityHelpWidgetVisible', false);
@@ -43,8 +44,8 @@ class AccessibilityHelpController extends Disposable
);
}
private _editor: ICodeEditor;
private _widget: AccessibilityHelpWidget;
private readonly _editor: ICodeEditor;
private readonly _widget: AccessibilityHelpWidget;
constructor(
editor: ICodeEditor,
@@ -106,11 +107,11 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
private static readonly WIDTH = 500;
private static readonly HEIGHT = 300;
private _editor: ICodeEditor;
private _domNode: FastDomNode<HTMLElement>;
private _contentDomNode: FastDomNode<HTMLElement>;
private readonly _editor: ICodeEditor;
private readonly _domNode: FastDomNode<HTMLElement>;
private readonly _contentDomNode: FastDomNode<HTMLElement>;
private _isVisible: boolean;
private _isVisibleKey: IContextKey<boolean>;
private readonly _isVisibleKey: IContextKey<boolean>;
constructor(
editor: ICodeEditor,
@@ -263,13 +264,13 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
: nls.localize("changeConfigToOnWinLinux", "To configure the editor to be optimized for usage with a Screen Reader press Control+E now.")
);
switch (opts.accessibilitySupport) {
case platform.AccessibilitySupport.Unknown:
case AccessibilitySupport.Unknown:
text += '\n\n - ' + turnOnMessage;
break;
case platform.AccessibilitySupport.Enabled:
case AccessibilitySupport.Enabled:
text += '\n\n - ' + nls.localize("auto_on", "The editor is configured to be optimized for usage with a Screen Reader.");
break;
case platform.AccessibilitySupport.Disabled:
case AccessibilitySupport.Disabled:
text += '\n\n - ' + nls.localize("auto_off", "The editor is configured to never be optimized for usage with a Screen Reader, which is not the case at this time.");
text += ' ' + turnOnMessage;
break;

View File

@@ -13,6 +13,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { RenderLineInput, renderViewLine2 as renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
import { ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel';
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
import { MonarchTokenizer } from 'vs/editor/standalone/common/monarch/monarchLexer';
export interface IColorizerOptions {
tabSize?: number;
@@ -64,7 +65,17 @@ export class Colorizer {
let tokenizationSupport = TokenizationRegistry.get(language);
if (tokenizationSupport) {
return Promise.resolve(_colorize(lines, tabSize, tokenizationSupport));
return _colorize(lines, tabSize, tokenizationSupport);
}
let tokenizationSupportPromise = TokenizationRegistry.getPromise(language);
if (tokenizationSupportPromise) {
// A tokenizer will be registered soon
return new Promise<string>((resolve, reject) => {
tokenizationSupportPromise!.then(tokenizationSupport => {
_colorize(lines, tabSize, tokenizationSupport).then(resolve, reject);
}, reject);
});
}
return new Promise<string>((resolve, reject) => {
@@ -82,9 +93,10 @@ export class Colorizer {
}
const tokenizationSupport = TokenizationRegistry.get(language!);
if (tokenizationSupport) {
return resolve(_colorize(lines, tabSize, tokenizationSupport));
_colorize(lines, tabSize, tokenizationSupport).then(resolve, reject);
return;
}
return resolve(_fakeColorize(lines, tabSize));
resolve(_fakeColorize(lines, tabSize));
};
// wait 500ms for mode to load, then give up
@@ -130,8 +142,21 @@ export class Colorizer {
}
}
function _colorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
return _actualColorize(lines, tabSize, tokenizationSupport);
function _colorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): Promise<string> {
return new Promise<string>((c, e) => {
const execute = () => {
const result = _actualColorize(lines, tabSize, tokenizationSupport);
if (tokenizationSupport instanceof MonarchTokenizer) {
const status = tokenizationSupport.getLoadStatus();
if (status.loaded === false) {
status.promise.then(execute, e);
return;
}
}
c(result);
};
execute();
});
}
function _fakeColorize(lines: string[], tabSize: number): string {

View File

@@ -15,7 +15,7 @@ export class IPadShowKeyboard implements IEditorContribution {
private static readonly ID = 'editor.contrib.iPadShowKeyboard';
private editor: ICodeEditor;
private readonly editor: ICodeEditor;
private widget: ShowKeyboardWidget | null;
private toDispose: IDisposable[];
@@ -60,9 +60,9 @@ class ShowKeyboardWidget implements IOverlayWidget {
private static readonly ID = 'editor.contrib.ShowKeyboardWidget';
private editor: ICodeEditor;
private readonly editor: ICodeEditor;
private _domNode: HTMLElement;
private readonly _domNode: HTMLElement;
private _toDispose: IDisposable[];
constructor(editor: ICodeEditor) {

View File

@@ -31,8 +31,8 @@ class InspectTokensController extends Disposable implements IEditorContribution
return editor.getContribution<InspectTokensController>(InspectTokensController.ID);
}
private _editor: ICodeEditor;
private _modeService: IModeService;
private readonly _editor: ICodeEditor;
private readonly _modeService: IModeService;
private _widget: InspectTokensWidget | null;
constructor(
@@ -162,11 +162,11 @@ class InspectTokensWidget extends Disposable implements IContentWidget {
// Editor.IContentWidget.allowEditorOverflow
public allowEditorOverflow = true;
private _editor: IActiveCodeEditor;
private _modeService: IModeService;
private _tokenizationSupport: ITokenizationSupport;
private _model: ITextModel;
private _domNode: HTMLElement;
private readonly _editor: IActiveCodeEditor;
private readonly _modeService: IModeService;
private readonly _tokenizationSupport: ITokenizationSupport;
private readonly _model: ITextModel;
private readonly _domNode: HTMLElement;
constructor(
editor: IActiveCodeEditor,

View File

@@ -30,10 +30,10 @@ export class QuickOpenController implements editorCommon.IEditorContribution, ID
return editor.getContribution<QuickOpenController>(QuickOpenController.ID);
}
private editor: ICodeEditor;
private widget: QuickOpenEditorWidget;
private rangeHighlightDecorationId: string;
private lastKnownEditorSelection: Selection;
private readonly editor: ICodeEditor;
private widget: QuickOpenEditorWidget | null;
private rangeHighlightDecorationId: string | null;
private lastKnownEditorSelection: Selection | null;
constructor(editor: ICodeEditor, @IThemeService private readonly themeService: IThemeService) {
this.editor = editor;
@@ -83,7 +83,7 @@ export class QuickOpenController implements editorCommon.IEditorContribution, ID
() => onClose(false),
() => onClose(true),
(value: string) => {
this.widget.setInput(opts.getModel(value), opts.getAutoFocus(value));
this.widget!.setInput(opts.getModel(value), opts.getAutoFocus(value));
},
{
inputAriaLabel: opts.inputAriaLabel
@@ -148,7 +148,7 @@ export interface IQuickOpenOpts {
*/
export abstract class BaseEditorQuickOpenAction extends EditorAction {
private _inputAriaLabel: string;
private readonly _inputAriaLabel: string;
constructor(inputAriaLabel: string, opts: IActionOptions) {
super(opts);

View File

@@ -6,8 +6,8 @@
import 'vs/css!./gotoLine';
import * as nls from 'vs/nls';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IContext, QuickOpenEntry, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenEntry, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IAutoFocus, Mode, IEntryRunContext } from 'vs/base/parts/quickopen/common/quickOpen';
import { ICodeEditor, IDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
import { Position } from 'vs/editor/common/core/position';
@@ -25,9 +25,9 @@ interface ParseResult {
}
export class GotoLineEntry extends QuickOpenEntry {
private parseResult: ParseResult;
private decorator: IDecorator;
private editor: editorCommon.IEditor;
private readonly parseResult: ParseResult;
private readonly decorator: IDecorator;
private readonly editor: editorCommon.IEditor;
constructor(line: string, editor: editorCommon.IEditor, decorator: IDecorator) {
super();
@@ -49,14 +49,15 @@ export class GotoLineEntry extends QuickOpenEntry {
position = new Position(numbers[0], numbers[1]);
}
let model: ITextModel;
let model: ITextModel | null;
if (isCodeEditor(this.editor)) {
model = this.editor.getModel();
} else {
model = (<IDiffEditor>this.editor).getModel().modified;
const diffModel = (<IDiffEditor>this.editor).getModel();
model = diffModel ? diffModel.modified : null;
}
const isValid = model.validatePosition(position).equals(position);
const isValid = model ? model.validatePosition(position).equals(position) : false;
let label: string;
if (isValid) {
@@ -65,10 +66,10 @@ export class GotoLineEntry extends QuickOpenEntry {
} else {
label = nls.localize('gotoLineLabelValidLine', "Go to line {0}", position.lineNumber, position.column);
}
} else if (position.lineNumber < 1 || position.lineNumber > model.getLineCount()) {
label = nls.localize('gotoLineLabelEmptyWithLineLimit', "Type a line number between 1 and {0} to navigate to", model.getLineCount());
} else if (position.lineNumber < 1 || position.lineNumber > (model ? model.getLineCount() : 0)) {
label = nls.localize('gotoLineLabelEmptyWithLineLimit', "Type a line number between 1 and {0} to navigate to", model ? model.getLineCount() : 0);
} else {
label = nls.localize('gotoLineLabelEmptyWithLineAndColumnLimit', "Type a character between 1 and {0} to navigate to", model.getLineMaxColumn(position.lineNumber));
label = nls.localize('gotoLineLabelEmptyWithLineAndColumnLimit', "Type a character between 1 and {0} to navigate to", model ? model.getLineMaxColumn(position.lineNumber) : 0);
}
return {
@@ -83,12 +84,12 @@ export class GotoLineEntry extends QuickOpenEntry {
}
getAriaLabel(): string {
const currentLine = this.editor.getPosition().lineNumber;
const position = this.editor.getPosition();
const currentLine = position ? position.lineNumber : 0;
return nls.localize('gotoLineAriaLabel', "Current Line: {0}. Go to line {0}.", currentLine, this.parseResult.label);
}
run(mode: Mode, context: IContext): boolean {
run(mode: Mode, _context: IEntryRunContext): boolean {
if (mode === Mode.OPEN) {
return this.runOpen();
}

View File

@@ -8,8 +8,8 @@ import * as browser from 'vs/base/browser/browser';
import { onUnexpectedError } from 'vs/base/common/errors';
import { matchesFuzzy } from 'vs/base/common/filters';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
import { IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IAutoFocus, Mode, IEntryRunContext } from 'vs/base/parts/quickopen/common/quickOpen';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
import { IEditor, IEditorAction } from 'vs/editor/common/editorCommon';
@@ -19,10 +19,10 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
export class EditorActionCommandEntry extends QuickOpenEntryGroup {
private key: string;
private action: IEditorAction;
private editor: IEditor;
private keyAriaLabel: string;
private readonly key: string;
private readonly action: IEditorAction;
private readonly editor: IEditor;
private readonly keyAriaLabel: string;
constructor(key: string, keyAriaLabel: string, highlights: IHighlight[], action: IEditorAction, editor: IEditor) {
super();
@@ -50,7 +50,7 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
return this.key;
}
public run(mode: Mode, context: IContext): boolean {
public run(mode: Mode, context: IEntryRunContext): boolean {
if (mode === Mode.OPEN) {
// Use a timeout to give the quick open widget a chance to close itself first
@@ -112,8 +112,8 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction {
}
private _sort(elementA: QuickOpenEntryGroup, elementB: QuickOpenEntryGroup): number {
let elementAName = elementA.getLabel().toLowerCase();
let elementBName = elementB.getLabel().toLowerCase();
let elementAName = (elementA.getLabel() || '').toLowerCase();
let elementBName = (elementB.getLabel() || '').toLowerCase();
return elementAName.localeCompare(elementBName);
}
@@ -129,7 +129,7 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction {
if (action.label) {
let highlights = matchesFuzzy(searchValue, action.label);
if (highlights) {
entries.push(new EditorActionCommandEntry(keybinding ? keybinding.getLabel() : '', keybinding ? keybinding.getAriaLabel() : '', highlights, action, editor));
entries.push(new EditorActionCommandEntry(keybinding ? keybinding.getLabel() || '' : '', keybinding ? keybinding.getAriaLabel() || '' : '', highlights, action, editor));
}
}
}

View File

@@ -21,8 +21,8 @@ export class QuickOpenEditorWidget implements IOverlayWidget {
private static readonly ID = 'editor.contrib.quickOpenEditorWidget';
private codeEditor: ICodeEditor;
private themeService: IThemeService;
private readonly codeEditor: ICodeEditor;
private readonly themeService: IThemeService;
private visible: boolean;
private quickOpenWidget: QuickOpenWidget;
private domNode: HTMLElement;
@@ -45,7 +45,7 @@ export class QuickOpenEditorWidget implements IOverlayWidget {
onCancel: onCancel,
onType: onType
}, {
inputPlaceHolder: null,
inputPlaceHolder: undefined,
inputAriaLabel: configuration.inputAriaLabel,
keyboardSupport: true
}
@@ -98,7 +98,7 @@ export class QuickOpenEditorWidget implements IOverlayWidget {
this.codeEditor.layoutOverlayWidget(this);
}
public getPosition(): IOverlayWidgetPosition {
public getPosition(): IOverlayWidgetPosition | null {
if (this.visible) {
return {
preference: OverlayWidgetPositionPreference.TOP_CENTER

View File

@@ -9,8 +9,8 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { matchesFuzzy } from 'vs/base/common/filters';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import * as strings from 'vs/base/common/strings';
import { IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
import { IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IAutoFocus, Mode, IEntryRunContext } from 'vs/base/parts/quickopen/common/quickOpen';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
import { IRange, Range } from 'vs/editor/common/core/range';
@@ -24,14 +24,14 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
let SCOPE_PREFIX = ':';
export class SymbolEntry extends QuickOpenEntryGroup {
private name: string;
private type: string;
private description: string;
private range: Range;
private editor: ICodeEditor;
private decorator: IDecorator;
private readonly name: string;
private readonly type: string;
private readonly description: string | null;
private readonly range: Range;
private readonly editor: ICodeEditor;
private readonly decorator: IDecorator;
constructor(name: string, type: string, description: string, range: Range, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator) {
constructor(name: string, type: string, description: string | null, range: Range, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator) {
super();
this.name = name;
@@ -55,7 +55,7 @@ export class SymbolEntry extends QuickOpenEntryGroup {
return this.type;
}
public getDescription(): string {
public getDescription(): string | null {
return this.description;
}
@@ -67,7 +67,7 @@ export class SymbolEntry extends QuickOpenEntryGroup {
return this.range;
}
public run(mode: Mode, context: IContext): boolean {
public run(mode: Mode, context: IEntryRunContext): boolean {
if (mode === Mode.OPEN) {
return this.runOpen(context);
}
@@ -75,7 +75,7 @@ export class SymbolEntry extends QuickOpenEntryGroup {
return this.runPreview();
}
private runOpen(context: IContext): boolean {
private runOpen(_context: IEntryRunContext): boolean {
// Apply selection and focus
let range = this.toSelection();
@@ -128,12 +128,15 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
public run(accessor: ServicesAccessor, editor: ICodeEditor) {
if (!editor.hasModel()) {
return undefined;
}
let model = editor.getModel();
const model = editor.getModel();
if (!DocumentSymbolProviderRegistry.has(model)) {
return null;
return undefined;
}
// Resolve outline
@@ -166,7 +169,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
});
}
private symbolEntry(name: string, type: string, description: string, range: IRange, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator): SymbolEntry {
private symbolEntry(name: string, type: string, description: string | null, range: IRange, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator): SymbolEntry {
return new SymbolEntry(name, type, description, Range.lift(range), highlights, editor, decorator);
}
@@ -222,7 +225,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
// Update previous result with count
if (currentResult) {
currentResult.setGroupLabel(this.typeToLabel(currentType, typeCounter));
currentResult.setGroupLabel(this.typeToLabel(currentType || '', typeCounter));
}
currentType = result.getType();
@@ -240,7 +243,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
// Update previous result with count
if (currentResult) {
currentResult.setGroupLabel(this.typeToLabel(currentType, typeCounter));
currentResult.setGroupLabel(this.typeToLabel(currentType || '', typeCounter));
}
}

View File

@@ -22,7 +22,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import { ITextModel } from 'vs/editor/common/model';
import { TextEdit, WorkspaceEdit, isResourceTextEdit } from 'vs/editor/common/modes';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ITextEditorModel, ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService';
import { IResolvedTextEditorModel, ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService';
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { CommandsRegistry, ICommand, ICommandEvent, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationChangeEvent, IConfigurationData, IConfigurationOverrides, IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -42,10 +42,11 @@ import { IProgressRunner, IProgressService } from 'vs/platform/progress/common/p
import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutService';
export class SimpleModel implements ITextEditorModel {
export class SimpleModel implements IResolvedTextEditorModel {
private model: ITextModel;
private readonly model: ITextModel;
private readonly _onDispose: Emitter<void>;
constructor(model: ITextModel) {
@@ -97,7 +98,7 @@ export class SimpleEditorModelResolverService implements ITextModelService {
this.editor = editor;
}
public createModelReference(resource: URI): Promise<IReference<ITextEditorModel>> {
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)
@@ -220,7 +221,7 @@ export class StandaloneCommandService implements ICommandService {
_serviceBrand: any;
private readonly _instantiationService: IInstantiationService;
private _dynamicCommands: { [id: string]: ICommand; };
private readonly _dynamicCommands: { [id: string]: ICommand; };
private readonly _onWillExecuteCommand = new Emitter<ICommandEvent>();
public readonly onWillExecuteCommand: Event<ICommandEvent> = this._onWillExecuteCommand.event;
@@ -256,7 +257,7 @@ export class StandaloneCommandService implements ICommandService {
export class StandaloneKeybindingService extends AbstractKeybindingService {
private _cachedResolver: KeybindingResolver | null;
private _dynamicKeybindings: IKeybindingItem[];
private readonly _dynamicKeybindings: IKeybindingItem[];
constructor(
contextKeyService: IContextKeyService,
@@ -369,13 +370,17 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
keyboardEvent.altKey,
keyboardEvent.metaKey,
keyboardEvent.keyCode
);
).toChord();
return new USLayoutResolvedKeybinding(keybinding, OS);
}
public resolveUserBinding(userBinding: string): ResolvedKeybinding[] {
return [];
}
public _dumpDebugInfo(): string {
return '';
}
}
function isConfigurationOverrides(thing: any): thing is IConfigurationOverrides {
@@ -392,7 +397,7 @@ export class SimpleConfigurationService implements IConfigurationService {
private _onDidChangeConfiguration = new Emitter<IConfigurationChangeEvent>();
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
private _configuration: Configuration;
private readonly _configuration: Configuration;
constructor() {
this._configuration = new Configuration(new DefaultConfigurationModel(), new ConfigurationModel());
@@ -409,7 +414,7 @@ export class SimpleConfigurationService implements IConfigurationService {
getValue(arg1?: any, arg2?: any): any {
const section = typeof arg1 === 'string' ? arg1 : undefined;
const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {};
return this.configuration().getValue(section, overrides, null);
return this.configuration().getValue(section, overrides, undefined);
}
public updateValue(key: string, value: any, arg3?: any, arg4?: any): Promise<void> {
@@ -424,11 +429,11 @@ export class SimpleConfigurationService implements IConfigurationService {
workspaceFolder?: C
value: C,
} {
return this.configuration().inspect<C>(key, options, null);
return this.configuration().inspect<C>(key, options, undefined);
}
public keys() {
return this.configuration().keys(null);
return this.configuration().keys(undefined);
}
public reloadConfiguration(): Promise<void> {
@@ -447,7 +452,7 @@ export class SimpleResourceConfigurationService implements ITextResourceConfigur
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent>;
private readonly _onDidChangeConfigurationEmitter = new Emitter();
constructor(private configurationService: SimpleConfigurationService) {
constructor(private readonly configurationService: SimpleConfigurationService) {
this.configurationService.onDidChangeConfiguration((e) => {
this._onDidChangeConfigurationEmitter.fire(e);
});
@@ -576,7 +581,7 @@ export class SimpleBulkEditService implements IBulkEditService {
//
}
apply(workspaceEdit: WorkspaceEdit, options: IBulkEditOptions): Promise<IBulkEditResult> {
apply(workspaceEdit: WorkspaceEdit, options?: IBulkEditOptions): Promise<IBulkEditResult> {
let edits = new Map<ITextModel, TextEdit[]>();
@@ -629,6 +634,10 @@ export class SimpleUriLabelService implements ILabelService {
return '';
}
public getSeparator(scheme: string, authority?: string): '/' | '\\' {
return '/';
}
public registerFormatter(formatter: ResourceLabelFormatter): IDisposable {
throw new Error('Not implemented');
}
@@ -637,3 +646,28 @@ export class SimpleUriLabelService implements ILabelService {
return '';
}
}
export class SimpleLayoutService implements ILayoutService {
_serviceBrand: any;
public onLayout = Event.None;
private _dimension: IDimension;
get dimension(): IDimension {
if (!this._dimension) {
this._dimension = dom.getClientArea(window.document.body);
}
return this._dimension;
}
get container(): HTMLElement {
return this._container;
}
get hasWorkbench(): boolean {
return false;
}
constructor(private _container: HTMLElement) { }
}

View File

@@ -28,6 +28,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
/**
* Description of an action contribution
@@ -152,7 +153,7 @@ function createAriaDomNode() {
*/
export class StandaloneCodeEditor extends CodeEditorWidget implements IStandaloneCodeEditor {
private _standaloneKeybindingService: StandaloneKeybindingService;
private readonly _standaloneKeybindingService: StandaloneKeybindingService;
constructor(
domElement: HTMLElement,
@@ -163,7 +164,8 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
@IContextKeyService contextKeyService: IContextKeyService,
@IKeybindingService keybindingService: IKeybindingService,
@IThemeService themeService: IThemeService,
@INotificationService notificationService: INotificationService
@INotificationService notificationService: INotificationService,
@IAccessibilityService accessibilityService: IAccessibilityService
) {
options = options || {};
options.ariaLabel = options.ariaLabel || nls.localize('editorViewAccessibleLabel', "Editor content");
@@ -172,7 +174,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
? nls.localize('accessibilityHelpMessageIE', "Press Ctrl+F1 for Accessibility Options.")
: nls.localize('accessibilityHelpMessage', "Press Alt+F1 for Accessibility Options.")
);
super(domElement, options, {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService);
super(domElement, options, {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService);
if (keybindingService instanceof StandaloneKeybindingService) {
this._standaloneKeybindingService = keybindingService;
@@ -278,7 +280,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
export class StandaloneEditor extends StandaloneCodeEditor implements IStandaloneCodeEditor {
private _contextViewService: ContextViewService;
private readonly _contextViewService: ContextViewService;
private readonly _configurationService: IConfigurationService;
private _ownsModel: boolean;
@@ -294,7 +296,8 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
@IContextViewService contextViewService: IContextViewService,
@IStandaloneThemeService themeService: IStandaloneThemeService,
@INotificationService notificationService: INotificationService,
@IConfigurationService configurationService: IConfigurationService
@IConfigurationService configurationService: IConfigurationService,
@IAccessibilityService accessibilityService: IAccessibilityService
) {
applyConfigurationValues(configurationService, options, false);
options = options || {};
@@ -303,7 +306,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
}
let _model: ITextModel | null | undefined = options.model;
delete options.model;
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService);
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService, accessibilityService);
this._contextViewService = <ContextViewService>contextViewService;
this._configurationService = configurationService;
@@ -355,7 +358,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
export class StandaloneDiffEditor extends DiffEditorWidget implements IStandaloneDiffEditor {
private _contextViewService: ContextViewService;
private readonly _contextViewService: ContextViewService;
private readonly _configurationService: IConfigurationService;
constructor(

View File

@@ -36,6 +36,8 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IMarker, IMarkerData } from 'vs/platform/markers/common/markers';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { clearAllFontInfos } from 'vs/editor/browser/config/configuration';
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
@@ -81,6 +83,7 @@ export function create(domElement: HTMLElement, options?: IEditorConstructionOpt
services.get(IStandaloneThemeService),
services.get(INotificationService),
services.get(IConfigurationService),
services.get(IAccessibilityService)
);
});
}
@@ -309,6 +312,13 @@ export function setTheme(themeName: string): void {
StaticServices.standaloneThemeService.get().setTheme(themeName);
}
/**
* Clears all cached font measurements and triggers re-measurement.
*/
export function remeasureFonts(): void {
clearAllFontInfos();
}
/**
* @internal
*/
@@ -338,6 +348,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
tokenize: <any>tokenize,
defineTheme: <any>defineTheme,
setTheme: <any>setTheme,
remeasureFonts: remeasureFonts,
// enums
ScrollbarVisibility: standaloneEnums.ScrollbarVisibility,

View File

@@ -292,31 +292,47 @@ export interface EncodedTokensProvider {
function isEncodedTokensProvider(provider: TokensProvider | EncodedTokensProvider): provider is EncodedTokensProvider {
return provider['tokenizeEncoded'];
}
function isThenable<T>(obj: any): obj is Thenable<T> {
if (typeof obj.then === 'function') {
return true;
}
return false;
}
/**
* Set the tokens provider for a language (manual implementation).
*/
export function setTokensProvider(languageId: string, provider: TokensProvider | EncodedTokensProvider): IDisposable {
export function setTokensProvider(languageId: string, provider: TokensProvider | EncodedTokensProvider | Thenable<TokensProvider | EncodedTokensProvider>): IDisposable {
let languageIdentifier = StaticServices.modeService.get().getLanguageIdentifier(languageId);
if (!languageIdentifier) {
throw new Error(`Cannot set tokens provider for unknown language ${languageId}`);
}
let adapter: modes.ITokenizationSupport;
if (isEncodedTokensProvider(provider)) {
adapter = new EncodedTokenizationSupport2Adapter(provider);
} else {
adapter = new TokenizationSupport2Adapter(StaticServices.standaloneThemeService.get(), languageIdentifier, provider);
const create = (provider: TokensProvider | EncodedTokensProvider) => {
if (isEncodedTokensProvider(provider)) {
return new EncodedTokenizationSupport2Adapter(provider);
} else {
return new TokenizationSupport2Adapter(StaticServices.standaloneThemeService.get(), languageIdentifier!, provider);
}
};
if (isThenable<TokensProvider | EncodedTokensProvider>(provider)) {
return modes.TokenizationRegistry.registerPromise(languageId, provider.then(provider => create(provider)));
}
return modes.TokenizationRegistry.register(languageId, adapter);
return modes.TokenizationRegistry.register(languageId, create(provider));
}
/**
* Set the tokens provider for a language (monarch implementation).
*/
export function setMonarchTokensProvider(languageId: string, languageDef: IMonarchLanguage): IDisposable {
let lexer = compile(languageId, languageDef);
let adapter = createTokenizationSupport(StaticServices.modeService.get(), StaticServices.standaloneThemeService.get(), languageId, lexer);
return modes.TokenizationRegistry.register(languageId, adapter);
export function setMonarchTokensProvider(languageId: string, languageDef: IMonarchLanguage | Thenable<IMonarchLanguage>): IDisposable {
const create = (languageDef: IMonarchLanguage) => {
return createTokenizationSupport(StaticServices.modeService.get(), StaticServices.standaloneThemeService.get(), languageId, compile(languageId, languageDef));
};
if (isThenable<IMonarchLanguage>(languageDef)) {
return modes.TokenizationRegistry.registerPromise(languageId, languageDef.then(languageDef => create(languageDef)));
}
return modes.TokenizationRegistry.register(languageId, create(languageDef));
}
/**

View File

@@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService } from 'vs/editor/standalone/browser/simpleServices';
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices';
import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl';
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
@@ -45,6 +45,9 @@ import { MenuService } from 'vs/platform/actions/common/menuService';
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
import { MarkerDecorationsService } from 'vs/editor/common/services/markerDecorationsServiceImpl';
import { ISuggestMemoryService, SuggestMemoryService } from 'vs/editor/contrib/suggest/suggestMemory';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { BrowserAccessibilityService } from 'vs/platform/accessibility/common/accessibilityService';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
export interface IEditorOverrideServices {
[index: string]: any;
@@ -55,8 +58,8 @@ export module StaticServices {
const _serviceCollection = new ServiceCollection();
export class LazyStaticService<T> {
private _serviceId: ServiceIdentifier<T>;
private _factory: (overrides?: IEditorOverrideServices) => T;
private readonly _serviceId: ServiceIdentifier<T>;
private readonly _factory: (overrides?: IEditorOverrideServices) => T;
private _value: T | null;
public get id() { return this._serviceId; }
@@ -132,6 +135,8 @@ export module StaticServices {
export const notificationService = define(INotificationService, () => new SimpleNotificationService());
export const accessibilityService = define(IAccessibilityService, () => new BrowserAccessibilityService());
export const markerService = define(IMarkerService, () => new MarkerService());
export const modeService = define(IModeService, (o) => new ModeServiceImpl());
@@ -158,8 +163,8 @@ export module StaticServices {
export class DynamicStandaloneServices extends Disposable {
private _serviceCollection: ServiceCollection;
private _instantiationService: IInstantiationService;
private readonly _serviceCollection: ServiceCollection;
private readonly _instantiationService: IInstantiationService;
constructor(domElement: HTMLElement, overrides: IEditorOverrideServices) {
super();
@@ -193,9 +198,11 @@ export class DynamicStandaloneServices extends Disposable {
let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, new NullLogService())));
let layoutService = ensure(ILayoutService, () => new SimpleLayoutService(domElement));
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService, keybindingService, themeService)));
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(layoutService)));
ensure(IContextMenuService, () => this._register(new ContextMenuService(layoutService, telemetryService, notificationService, contextViewService, keybindingService, themeService)));
ensure(IMenuService, () => new MenuService(commandService));

View File

@@ -26,9 +26,9 @@ class StandaloneTheme implements IStandaloneTheme {
public readonly id: string;
public readonly themeName: string;
private themeData: IStandaloneThemeData;
private readonly themeData: IStandaloneThemeData;
private colors: { [colorId: string]: Color } | null;
private defaultColors: { [colorId: string]: Color | null; };
private readonly defaultColors: { [colorId: string]: Color | undefined; };
private _tokenTheme: TokenTheme | null;
constructor(name: string, standaloneThemeData: IStandaloneThemeData) {
@@ -77,7 +77,7 @@ class StandaloneTheme implements IStandaloneTheme {
return this.colors;
}
public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color | null {
public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color | undefined {
const color = this.getColors()[colorId];
if (color) {
return color;
@@ -85,10 +85,10 @@ class StandaloneTheme implements IStandaloneTheme {
if (useDefault !== false) {
return this.getDefault(colorId);
}
return null;
return undefined;
}
private getDefault(colorId: ColorIdentifier): Color | null {
private getDefault(colorId: ColorIdentifier): Color | undefined {
let color = this.defaultColors[colorId];
if (color) {
return color;
@@ -159,12 +159,12 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
_serviceBrand: any;
private _knownThemes: Map<string, StandaloneTheme>;
private _styleElement: HTMLStyleElement;
private readonly _knownThemes: Map<string, StandaloneTheme>;
private readonly _styleElement: HTMLStyleElement;
private _theme: IStandaloneTheme;
private readonly _onThemeChange: Emitter<IStandaloneTheme>;
private readonly _onIconThemeChange: Emitter<IIconTheme>;
private environment: IEnvironmentService = Object.create(null);
private readonly environment: IEnvironmentService = Object.create(null);
constructor() {
this._onThemeChange = new Emitter<IStandaloneTheme>();