mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -115,9 +115,9 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
|
||||
|
||||
constructor(
|
||||
editor: ICodeEditor,
|
||||
@IContextKeyService private _contextKeyService: IContextKeyService,
|
||||
@IKeybindingService private _keybindingService: IKeybindingService,
|
||||
@IOpenerService private _openerService: IOpenerService
|
||||
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService,
|
||||
@IOpenerService private readonly _openerService: IOpenerService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IModel } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ColorId, MetadataConsts, FontStyle, TokenizationRegistry, ITokenizationSupport } from 'vs/editor/common/modes';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { renderViewLine2 as renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { LineTokens, IViewLineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
|
||||
@@ -38,7 +37,7 @@ export class Colorizer {
|
||||
themeService.setTheme(theme);
|
||||
|
||||
let text = domNode.firstChild.nodeValue;
|
||||
domNode.className += 'monaco-editor ' + theme;
|
||||
domNode.className += ' ' + theme;
|
||||
let render = (str: string) => {
|
||||
domNode.innerHTML = str;
|
||||
};
|
||||
@@ -94,7 +93,7 @@ export class Colorizer {
|
||||
});
|
||||
}
|
||||
|
||||
public static colorizeLine(line: string, mightContainRTL: boolean, tokens: ViewLineToken[], tabSize: number = 4): string {
|
||||
public static colorizeLine(line: string, mightContainRTL: boolean, tokens: IViewLineTokens, tabSize: number = 4): string {
|
||||
let renderResult = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
line,
|
||||
@@ -112,7 +111,7 @@ export class Colorizer {
|
||||
return renderResult.html;
|
||||
}
|
||||
|
||||
public static colorizeModelLine(model: IModel, lineNumber: number, tabSize: number = 4): string {
|
||||
public static colorizeModelLine(model: ITextModel, lineNumber: number, tabSize: number = 4): string {
|
||||
let content = model.getLineContent(lineNumber);
|
||||
model.forceTokenization(lineNumber);
|
||||
let tokens = model.getLineTokens(lineNumber);
|
||||
@@ -134,15 +133,22 @@ function _fakeColorize(lines: string[], tabSize: number): string {
|
||||
| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)
|
||||
) >>> 0;
|
||||
|
||||
const tokens = new Uint32Array(2);
|
||||
tokens[0] = 0;
|
||||
tokens[1] = defaultMetadata;
|
||||
|
||||
for (let i = 0, length = lines.length; i < length; i++) {
|
||||
let line = lines[i];
|
||||
|
||||
tokens[0] = line.length;
|
||||
const lineTokens = new LineTokens(tokens, line);
|
||||
|
||||
let renderResult = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
line,
|
||||
false,
|
||||
0,
|
||||
[new ViewLineToken(line.length, defaultMetadata)],
|
||||
lineTokens,
|
||||
[],
|
||||
tabSize,
|
||||
0,
|
||||
@@ -166,6 +172,7 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport:
|
||||
for (let i = 0, length = lines.length; i < length; i++) {
|
||||
let line = lines[i];
|
||||
let tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
|
||||
LineTokens.convertToEndOffset(tokenizeResult.tokens, line.length);
|
||||
let lineTokens = new LineTokens(tokenizeResult.tokens, line);
|
||||
let renderResult = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
|
||||
@@ -9,12 +9,12 @@ import * as nls from 'vs/nls';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { escape } from 'vs/base/common/strings';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IEditorContribution, IModel } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { registerEditorAction, registerEditorContribution, EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditor, ContentWidgetPositionPreference, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { TokenMetadata } from 'vs/editor/common/model/tokensBinaryEncoding';
|
||||
import { TokenizationRegistry, LanguageIdentifier, FontStyle, StandardTokenType, ITokenizationSupport, IState } from 'vs/editor/common/modes';
|
||||
import { TokenizationRegistry, LanguageIdentifier, FontStyle, StandardTokenType, ITokenizationSupport, IState, TokenMetadata } from 'vs/editor/common/modes';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { NULL_STATE, nullTokenize, nullTokenize2 } from 'vs/editor/common/modes/nullMode';
|
||||
@@ -168,7 +168,7 @@ class InspectTokensWidget extends Disposable implements IContentWidget {
|
||||
private _editor: ICodeEditor;
|
||||
private _modeService: IModeService;
|
||||
private _tokenizationSupport: ITokenizationSupport;
|
||||
private _model: IModel;
|
||||
private _model: ITextModel;
|
||||
private _domNode: HTMLElement;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -13,7 +13,8 @@ import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { registerEditorContribution, IActionOptions, EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { IModelDecorationsChangeAccessor, IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
|
||||
export interface IQuickOpenControllerOpts {
|
||||
inputAriaLabel: string;
|
||||
@@ -99,14 +100,14 @@ export class QuickOpenController implements editorCommon.IEditorContribution, ID
|
||||
});
|
||||
|
||||
public decorateLine(range: Range, editor: ICodeEditor): void {
|
||||
editor.changeDecorations((changeAccessor: editorCommon.IModelDecorationsChangeAccessor) => {
|
||||
editor.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => {
|
||||
const oldDecorations: string[] = [];
|
||||
if (this.rangeHighlightDecorationId) {
|
||||
oldDecorations.push(this.rangeHighlightDecorationId);
|
||||
this.rangeHighlightDecorationId = null;
|
||||
}
|
||||
|
||||
const newDecorations: editorCommon.IModelDeltaDecoration[] = [
|
||||
const newDecorations: IModelDeltaDecoration[] = [
|
||||
{
|
||||
range: range,
|
||||
options: QuickOpenController._RANGE_HIGHLIGHT_DECORATION
|
||||
@@ -120,7 +121,7 @@ export class QuickOpenController implements editorCommon.IEditorContribution, ID
|
||||
|
||||
public clearDecorations(): void {
|
||||
if (this.rangeHighlightDecorationId) {
|
||||
this.editor.changeDecorations((changeAccessor: editorCommon.IModelDecorationsChangeAccessor) => {
|
||||
this.editor.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => {
|
||||
changeAccessor.deltaDecorations([this.rangeHighlightDecorationId], []);
|
||||
this.rangeHighlightDecorationId = null;
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ import { registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editor
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
|
||||
interface ParseResult {
|
||||
position: Position;
|
||||
@@ -52,7 +53,7 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
position = new Position(numbers[0], numbers[1]);
|
||||
}
|
||||
|
||||
let model: editorCommon.IModel;
|
||||
let model: ITextModel;
|
||||
if (isCodeEditor(this.editor)) {
|
||||
model = this.editor.getModel();
|
||||
} else {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPosit
|
||||
import { attachQuickOpenStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { foreground } from 'vs/platform/theme/common/colorRegistry';
|
||||
|
||||
export interface IQuickOpenEditorWidgetOptions {
|
||||
inputAriaLabel: string;
|
||||
@@ -50,7 +51,9 @@ export class QuickOpenEditorWidget implements IOverlayWidget {
|
||||
keyboardSupport: true
|
||||
}
|
||||
);
|
||||
this.styler = attachQuickOpenStyler(this.quickOpenWidget, this.themeService);
|
||||
this.styler = attachQuickOpenStyler(this.quickOpenWidget, this.themeService, {
|
||||
pickerGroupForeground: foreground
|
||||
});
|
||||
|
||||
this.quickOpenWidget.create();
|
||||
this.codeEditor.addOverlayWidget(this);
|
||||
|
||||
@@ -17,7 +17,6 @@ import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayo
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { IKeybindingEvent, KeybindingSource, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfirmation, IMessageService, IConfirmationResult } from 'vs/platform/message/common/message';
|
||||
import { IWorkspaceContextService, IWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditor, IDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
@@ -38,6 +37,10 @@ import { ResolvedKeybinding, Keybinding, createKeybinding, SimpleKeybinding } fr
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { INotificationService, INotification, INotificationHandle, NoOpNotification } from 'vs/platform/notification/common/notification';
|
||||
import { IConfirmation, IConfirmationResult, IConfirmationService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IPosition, Position as Pos } from 'vs/editor/common/core/position';
|
||||
|
||||
export class SimpleEditor implements IEditor {
|
||||
|
||||
@@ -69,10 +72,10 @@ export class SimpleEditor implements IEditor {
|
||||
|
||||
export class SimpleModel implements ITextEditorModel {
|
||||
|
||||
private model: editorCommon.IModel;
|
||||
private model: ITextModel;
|
||||
private _onDispose: Emitter<void>;
|
||||
|
||||
constructor(model: editorCommon.IModel) {
|
||||
constructor(model: ITextModel) {
|
||||
this.model = model;
|
||||
this._onDispose = new Emitter<void>();
|
||||
}
|
||||
@@ -85,7 +88,7 @@ export class SimpleModel implements ITextEditorModel {
|
||||
return TPromise.as(this);
|
||||
}
|
||||
|
||||
public get textEditorModel(): editorCommon.IModel {
|
||||
public get textEditorModel(): ITextModel {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
@@ -163,7 +166,7 @@ export class SimpleEditorService implements IEditorService {
|
||||
return this.editor;
|
||||
}
|
||||
|
||||
private findModel(editor: ICodeEditor, data: IResourceInput): editorCommon.IModel {
|
||||
private findModel(editor: ICodeEditor, data: IResourceInput): ITextModel {
|
||||
let model = editor.getModel();
|
||||
if (model.uri.toString() !== data.resource.toString()) {
|
||||
return null;
|
||||
@@ -183,7 +186,7 @@ export class SimpleEditorModelResolverService implements ITextModelService {
|
||||
}
|
||||
|
||||
public createModelReference(resource: URI): TPromise<IReference<ITextEditorModel>> {
|
||||
let model: editorCommon.IModel;
|
||||
let model: ITextModel;
|
||||
|
||||
model = this.editor.withTypedEditor(
|
||||
(editor) => this.findModel(editor, resource),
|
||||
@@ -203,7 +206,7 @@ export class SimpleEditorModelResolverService implements ITextModelService {
|
||||
};
|
||||
}
|
||||
|
||||
private findModel(editor: ICodeEditor, resource: URI): editorCommon.IModel {
|
||||
private findModel(editor: ICodeEditor, resource: URI): ITextModel {
|
||||
let model = editor.getModel();
|
||||
if (model.uri.toString() !== resource.toString()) {
|
||||
return null;
|
||||
@@ -233,44 +236,61 @@ export class SimpleProgressService implements IProgressService {
|
||||
}
|
||||
}
|
||||
|
||||
export class SimpleMessageService implements IMessageService {
|
||||
export class SimpleConfirmationService implements IConfirmationService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
private static readonly Empty = function () { /* nothing */ };
|
||||
|
||||
public show(sev: Severity, message: any): () => void {
|
||||
|
||||
switch (sev) {
|
||||
case Severity.Error:
|
||||
console.error(message);
|
||||
break;
|
||||
case Severity.Warning:
|
||||
console.warn(message);
|
||||
break;
|
||||
default:
|
||||
console.log(message);
|
||||
break;
|
||||
}
|
||||
|
||||
return SimpleMessageService.Empty;
|
||||
}
|
||||
|
||||
public hideAll(): void {
|
||||
// No-op
|
||||
}
|
||||
|
||||
public confirm(confirmation: IConfirmation): boolean {
|
||||
public confirm(confirmation: IConfirmation): TPromise<boolean> {
|
||||
let messageText = confirmation.message;
|
||||
if (confirmation.detail) {
|
||||
messageText = messageText + '\n\n' + confirmation.detail;
|
||||
}
|
||||
|
||||
return window.confirm(messageText);
|
||||
return TPromise.wrap(window.confirm(messageText));
|
||||
}
|
||||
|
||||
public confirmWithCheckbox(confirmation: IConfirmation): TPromise<IConfirmationResult> {
|
||||
return TPromise.as({ confirmed: this.confirm(confirmation), checkboxChecked: false /* unsupported */ } as IConfirmationResult);
|
||||
return this.confirm(confirmation).then(confirmed => {
|
||||
return {
|
||||
confirmed,
|
||||
checkboxChecked: false // unsupported
|
||||
} as IConfirmationResult;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class SimpleNotificationService implements INotificationService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
private static readonly NO_OP: INotificationHandle = new NoOpNotification();
|
||||
|
||||
public info(message: string): INotificationHandle {
|
||||
return this.notify({ severity: Severity.Info, message });
|
||||
}
|
||||
|
||||
public warn(message: string): INotificationHandle {
|
||||
return this.notify({ severity: Severity.Warning, message });
|
||||
}
|
||||
|
||||
public error(error: string | Error): INotificationHandle {
|
||||
return this.notify({ severity: Severity.Error, message: error });
|
||||
}
|
||||
|
||||
public notify(notification: INotification): INotificationHandle {
|
||||
switch (notification.severity) {
|
||||
case Severity.Error:
|
||||
console.error(notification.message);
|
||||
break;
|
||||
case Severity.Warning:
|
||||
console.warn(notification.message);
|
||||
break;
|
||||
default:
|
||||
console.log(notification.message);
|
||||
break;
|
||||
}
|
||||
|
||||
return SimpleNotificationService.NO_OP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,10 +342,10 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
contextKeyService: IContextKeyService,
|
||||
commandService: ICommandService,
|
||||
telemetryService: ITelemetryService,
|
||||
messageService: IMessageService,
|
||||
notificationService: INotificationService,
|
||||
domNode: HTMLElement
|
||||
) {
|
||||
super(contextKeyService, commandService, telemetryService, messageService);
|
||||
super(contextKeyService, commandService, telemetryService, notificationService);
|
||||
|
||||
this._cachedResolver = null;
|
||||
this._dynamicKeybindings = [];
|
||||
@@ -506,10 +526,13 @@ export class SimpleResourceConfigurationService implements ITextResourceConfigur
|
||||
});
|
||||
}
|
||||
|
||||
public getValue<T>(): T {
|
||||
return this.configurationService.getValue<T>();
|
||||
getValue<T>(resource: URI, section?: string): T;
|
||||
getValue<T>(resource: URI, position?: IPosition, section?: string): T;
|
||||
getValue<T>(resource: any, arg2?: any, arg3?: any) {
|
||||
const position: IPosition = Pos.isIPosition(arg2) ? arg2 : null;
|
||||
const section: string = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0);
|
||||
return this.configurationService.getValue<T>(section);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class SimpleMenuService implements IMenuService {
|
||||
|
||||
@@ -12,7 +12,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IModel, IModelChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { StandaloneKeybindingService } from 'vs/editor/standalone/browser/simpleServices';
|
||||
@@ -26,9 +27,9 @@ import { MenuId, MenuRegistry, IMenuItem } from 'vs/platform/actions/common/acti
|
||||
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
|
||||
/**
|
||||
* Description of an action contribution
|
||||
@@ -82,7 +83,7 @@ export interface IEditorConstructionOptions extends IEditorOptions {
|
||||
/**
|
||||
* The initial model associated with this code editor.
|
||||
*/
|
||||
model?: IModel;
|
||||
model?: ITextModel;
|
||||
/**
|
||||
* The initial value of the auto created model in the editor.
|
||||
* To not create automatically a model, use `model: null`.
|
||||
@@ -300,7 +301,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
if (typeof options.theme === 'string') {
|
||||
themeService.setTheme(options.theme);
|
||||
}
|
||||
let model: IModel = options.model;
|
||||
let model: ITextModel = options.model;
|
||||
delete options.model;
|
||||
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService);
|
||||
|
||||
@@ -328,14 +329,14 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
_attachModel(model: IModel): void {
|
||||
_attachModel(model: ITextModel): void {
|
||||
super._attachModel(model);
|
||||
if (this._view) {
|
||||
this._contextViewService.setContainer(this._view.domNode.domNode);
|
||||
}
|
||||
}
|
||||
|
||||
_postDetachModelCleanup(detachedModel: IModel): void {
|
||||
_postDetachModelCleanup(detachedModel: ITextModel): void {
|
||||
super._postDetachModelCleanup(detachedModel);
|
||||
if (detachedModel && this._ownsModel) {
|
||||
detachedModel.dispose();
|
||||
@@ -359,14 +360,14 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
@IEditorWorkerService editorWorkerService: IEditorWorkerService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@IStandaloneThemeService themeService: IStandaloneThemeService,
|
||||
@IMessageService messageService: IMessageService
|
||||
@INotificationService notificationService: INotificationService
|
||||
) {
|
||||
options = options || {};
|
||||
if (typeof options.theme === 'string') {
|
||||
options.theme = themeService.setTheme(options.theme);
|
||||
}
|
||||
|
||||
super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, messageService);
|
||||
super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService);
|
||||
|
||||
this._contextViewService = <IEditorContextViewService>contextViewService;
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ import { Token } from 'vs/editor/common/core/token';
|
||||
import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { ITextModel, OverviewRulerLane, EndOfLinePreference, DefaultEndOfLine, EndOfLineSequence, TrackedRangeStickiness, TextModelResolvedOptions, FindMatch } from 'vs/editor/common/model';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
|
||||
function withAllStandaloneServices<T extends editorCommon.IEditor>(domElement: HTMLElement, override: IEditorOverrideServices, callback: (services: DynamicStandaloneServices) => T): T {
|
||||
let services = new DynamicStandaloneServices(domElement, override);
|
||||
@@ -122,7 +123,7 @@ export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorC
|
||||
services.get(IEditorWorkerService),
|
||||
services.get(ICodeEditorService),
|
||||
services.get(IStandaloneThemeService),
|
||||
services.get(IMessageService)
|
||||
services.get(INotificationService)
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -144,7 +145,7 @@ export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: ID
|
||||
return new DiffNavigator(diffEditor, opts);
|
||||
}
|
||||
|
||||
function doCreateModel(value: string, mode: TPromise<modes.IMode>, uri?: URI): editorCommon.IModel {
|
||||
function doCreateModel(value: string, mode: TPromise<modes.IMode>, uri?: URI): ITextModel {
|
||||
return StaticServices.modelService.get().createModel(value, mode, uri);
|
||||
}
|
||||
|
||||
@@ -152,7 +153,7 @@ function doCreateModel(value: string, mode: TPromise<modes.IMode>, uri?: URI): e
|
||||
* Create a new editor model.
|
||||
* You can specify the language that should be set for this model or let the language be inferred from the `uri`.
|
||||
*/
|
||||
export function createModel(value: string, language?: string, uri?: URI): editorCommon.IModel {
|
||||
export function createModel(value: string, language?: string, uri?: URI): ITextModel {
|
||||
value = value || '';
|
||||
|
||||
if (!language) {
|
||||
@@ -172,14 +173,14 @@ export function createModel(value: string, language?: string, uri?: URI): editor
|
||||
/**
|
||||
* Change the language for a model.
|
||||
*/
|
||||
export function setModelLanguage(model: editorCommon.IModel, language: string): void {
|
||||
export function setModelLanguage(model: ITextModel, language: string): void {
|
||||
StaticServices.modelService.get().setMode(model, StaticServices.modeService.get().getOrCreateMode(language));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the markers for a model.
|
||||
*/
|
||||
export function setModelMarkers(model: editorCommon.IModel, owner: string, markers: IMarkerData[]): void {
|
||||
export function setModelMarkers(model: ITextModel, owner: string, markers: IMarkerData[]): void {
|
||||
if (model) {
|
||||
StaticServices.markerService.get().changeOne(owner, model.uri, markers);
|
||||
}
|
||||
@@ -197,14 +198,14 @@ export function getModelMarkers(filter: { owner?: string, resource?: URI, take?:
|
||||
/**
|
||||
* Get the model that has `uri` if it exists.
|
||||
*/
|
||||
export function getModel(uri: URI): editorCommon.IModel {
|
||||
export function getModel(uri: URI): ITextModel {
|
||||
return StaticServices.modelService.get().getModel(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the created models.
|
||||
*/
|
||||
export function getModels(): editorCommon.IModel[] {
|
||||
export function getModels(): ITextModel[] {
|
||||
return StaticServices.modelService.get().getModels();
|
||||
}
|
||||
|
||||
@@ -212,7 +213,7 @@ export function getModels(): editorCommon.IModel[] {
|
||||
* Emitted when a model is created.
|
||||
* @event
|
||||
*/
|
||||
export function onDidCreateModel(listener: (model: editorCommon.IModel) => void): IDisposable {
|
||||
export function onDidCreateModel(listener: (model: ITextModel) => void): IDisposable {
|
||||
return StaticServices.modelService.get().onModelAdded(listener);
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ export function onDidCreateModel(listener: (model: editorCommon.IModel) => void)
|
||||
* Emitted right before a model is disposed.
|
||||
* @event
|
||||
*/
|
||||
export function onWillDisposeModel(listener: (model: editorCommon.IModel) => void): IDisposable {
|
||||
export function onWillDisposeModel(listener: (model: ITextModel) => void): IDisposable {
|
||||
return StaticServices.modelService.get().onModelRemoved(listener);
|
||||
}
|
||||
|
||||
@@ -228,7 +229,7 @@ export function onWillDisposeModel(listener: (model: editorCommon.IModel) => voi
|
||||
* Emitted when a different language is set to a model.
|
||||
* @event
|
||||
*/
|
||||
export function onDidChangeModelLanguage(listener: (e: { readonly model: editorCommon.IModel; readonly oldLanguage: string; }) => void): IDisposable {
|
||||
export function onDidChangeModelLanguage(listener: (e: { readonly model: ITextModel; readonly oldLanguage: string; }) => void): IDisposable {
|
||||
return StaticServices.modelService.get().onModelModeChanged((e) => {
|
||||
listener({
|
||||
model: e.model,
|
||||
@@ -262,7 +263,7 @@ export function colorize(text: string, languageId: string, options: IColorizerOp
|
||||
/**
|
||||
* Colorize a line in a model.
|
||||
*/
|
||||
export function colorizeModelLine(model: editorCommon.IModel, lineNumber: number, tabSize: number = 4): string {
|
||||
export function colorizeModelLine(model: ITextModel, lineNumber: number, tabSize: number = 4): string {
|
||||
return Colorizer.colorizeModelLine(model, lineNumber, tabSize);
|
||||
}
|
||||
|
||||
@@ -377,11 +378,11 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
|
||||
// enums
|
||||
ScrollbarVisibility: ScrollbarVisibility,
|
||||
WrappingIndent: editorOptions.WrappingIndent,
|
||||
OverviewRulerLane: editorCommon.OverviewRulerLane,
|
||||
EndOfLinePreference: editorCommon.EndOfLinePreference,
|
||||
DefaultEndOfLine: editorCommon.DefaultEndOfLine,
|
||||
EndOfLineSequence: editorCommon.EndOfLineSequence,
|
||||
TrackedRangeStickiness: editorCommon.TrackedRangeStickiness,
|
||||
OverviewRulerLane: OverviewRulerLane,
|
||||
EndOfLinePreference: EndOfLinePreference,
|
||||
DefaultEndOfLine: DefaultEndOfLine,
|
||||
EndOfLineSequence: EndOfLineSequence,
|
||||
TrackedRangeStickiness: TrackedRangeStickiness,
|
||||
CursorChangeReason: CursorChangeReason,
|
||||
MouseTargetType: MouseTargetType,
|
||||
TextEditorCursorStyle: editorOptions.TextEditorCursorStyle,
|
||||
@@ -396,8 +397,8 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
|
||||
InternalEditorOptions: <any>editorOptions.InternalEditorOptions,
|
||||
BareFontInfo: <any>BareFontInfo,
|
||||
FontInfo: <any>FontInfo,
|
||||
TextModelResolvedOptions: <any>editorCommon.TextModelResolvedOptions,
|
||||
FindMatch: <any>editorCommon.FindMatch,
|
||||
TextModelResolvedOptions: <any>TextModelResolvedOptions,
|
||||
FindMatch: <any>FindMatch,
|
||||
|
||||
// vars
|
||||
EditorType: editorCommon.EditorType
|
||||
|
||||
@@ -13,7 +13,6 @@ import { ILanguageExtensionPoint } from 'vs/editor/common/services/modeService';
|
||||
import { StaticServices } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { LanguageConfiguration, IndentAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
@@ -24,6 +23,7 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { Token, TokenizationResult, TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import * as model from 'vs/editor/common/model';
|
||||
|
||||
/**
|
||||
* Register information about a new language.
|
||||
@@ -263,7 +263,7 @@ export function registerSignatureHelpProvider(languageId: string, provider: mode
|
||||
*/
|
||||
export function registerHoverProvider(languageId: string, provider: modes.HoverProvider): IDisposable {
|
||||
return modes.HoverProviderRegistry.register(languageId, {
|
||||
provideHover: (model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Thenable<modes.Hover> => {
|
||||
provideHover: (model: model.ITextModel, position: Position, token: CancellationToken): Thenable<modes.Hover> => {
|
||||
let word = model.getWordAtPosition(position);
|
||||
|
||||
return toThenable<modes.Hover>(provider.provideHover(model, position, token)).then((value) => {
|
||||
@@ -329,11 +329,11 @@ export function registerCodeLensProvider(languageId: string, provider: modes.Cod
|
||||
*/
|
||||
export function registerCodeActionProvider(languageId: string, provider: CodeActionProvider): IDisposable {
|
||||
return modes.CodeActionProviderRegistry.register(languageId, {
|
||||
provideCodeActions: (model: editorCommon.IReadOnlyModel, range: Range, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]> => {
|
||||
provideCodeActions: (model: model.ITextModel, range: Range, context: modes.CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]> => {
|
||||
let markers = StaticServices.markerService.get().read({ resource: model.uri }).filter(m => {
|
||||
return Range.areIntersectingOrTouching(m, range);
|
||||
});
|
||||
return provider.provideCodeActions(model, range, { markers }, token);
|
||||
return provider.provideCodeActions(model, range, { markers, only: context.only }, token);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -373,10 +373,10 @@ export function registerCompletionItemProvider(languageId: string, provider: Com
|
||||
let adapter = new SuggestAdapter(provider);
|
||||
return modes.SuggestRegistry.register(languageId, {
|
||||
triggerCharacters: provider.triggerCharacters,
|
||||
provideCompletionItems: (model: editorCommon.IReadOnlyModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> => {
|
||||
provideCompletionItems: (model: model.ITextModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> => {
|
||||
return adapter.provideCompletionItems(model, position, context, token);
|
||||
},
|
||||
resolveCompletionItem: (model: editorCommon.IReadOnlyModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable<modes.ISuggestion> => {
|
||||
resolveCompletionItem: (model: model.ITextModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable<modes.ISuggestion> => {
|
||||
return adapter.resolveCompletionItem(model, position, suggestion, token);
|
||||
}
|
||||
});
|
||||
@@ -389,6 +389,14 @@ export function registerColorProvider(languageId: string, provider: modes.Docume
|
||||
return modes.ColorProviderRegistry.register(languageId, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a folding provider
|
||||
*/
|
||||
/*export function registerFoldingProvider(languageId: string, provider: modes.FoldingProvider): IDisposable {
|
||||
return modes.FoldingProviderRegistry.register(languageId, provider);
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* Contains additional diagnostic information about the context in which
|
||||
* a [code action](#CodeActionProvider.provideCodeActions) is run.
|
||||
@@ -401,6 +409,11 @@ export interface CodeActionContext {
|
||||
* @readonly
|
||||
*/
|
||||
readonly markers: IMarkerData[];
|
||||
|
||||
/**
|
||||
* Requested kind of actions to return.
|
||||
*/
|
||||
readonly only?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +424,7 @@ export interface CodeActionProvider {
|
||||
/**
|
||||
* Provide commands for the given document and range.
|
||||
*/
|
||||
provideCodeActions(model: editorCommon.IReadOnlyModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]>;
|
||||
provideCodeActions(model: model.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,7 +537,19 @@ export interface CompletionItem {
|
||||
* ~~The [range](#Range) of the edit must be single-line and on the same
|
||||
* line completions were [requested](#CompletionItemProvider.provideCompletionItems) at.~~
|
||||
*/
|
||||
textEdit?: editorCommon.ISingleEditOperation;
|
||||
textEdit?: model.ISingleEditOperation;
|
||||
/**
|
||||
* An optional array of additional text edits that are applied when
|
||||
* selecting this completion. Edits must not overlap with the main edit
|
||||
* nor with themselves.
|
||||
*/
|
||||
additionalTextEdits?: model.ISingleEditOperation[];
|
||||
/**
|
||||
* An optional set of characters that when pressed while this completion is active will accept it first and
|
||||
* then type that character. *Note* that all commit characters should have `length=1` and that superfluous
|
||||
* characters will be ignored.
|
||||
*/
|
||||
commitCharacters?: string[];
|
||||
}
|
||||
/**
|
||||
* Represents a collection of [completion items](#CompletionItem) to be presented
|
||||
@@ -576,7 +601,7 @@ export interface CompletionItemProvider {
|
||||
/**
|
||||
* Provide completion items for the given position and document.
|
||||
*/
|
||||
provideCompletionItems(document: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable<CompletionItem[]> | CompletionList | Thenable<CompletionList>;
|
||||
provideCompletionItems(document: model.ITextModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable<CompletionItem[]> | CompletionList | Thenable<CompletionList>;
|
||||
|
||||
/**
|
||||
* Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation)
|
||||
@@ -634,7 +659,9 @@ class SuggestAdapter {
|
||||
command: item.command,
|
||||
sortText: item.sortText,
|
||||
filterText: item.filterText,
|
||||
snippetType: 'internal'
|
||||
snippetType: 'internal',
|
||||
additionalTextEdits: item.additionalTextEdits,
|
||||
commitCharacters: item.commitCharacters
|
||||
};
|
||||
let editRange = item.textEdit ? item.textEdit.range : item.range;
|
||||
if (editRange) {
|
||||
@@ -665,7 +692,7 @@ class SuggestAdapter {
|
||||
return suggestion;
|
||||
}
|
||||
|
||||
provideCompletionItems(model: editorCommon.IReadOnlyModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> {
|
||||
provideCompletionItems(model: model.ITextModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> {
|
||||
const result = this._provider.provideCompletionItems(model, position, token, context);
|
||||
return toThenable<CompletionItem[] | CompletionList>(result).then(value => {
|
||||
const result: modes.ISuggestResult = {
|
||||
@@ -708,7 +735,7 @@ class SuggestAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
resolveCompletionItem(model: editorCommon.IReadOnlyModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable<modes.ISuggestion> {
|
||||
resolveCompletionItem(model: model.ITextModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable<modes.ISuggestion> {
|
||||
if (typeof this._provider.resolveCompletionItem !== 'function') {
|
||||
return TPromise.as(suggestion);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MarkerService } from 'vs/platform/markers/common/markerService';
|
||||
import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -32,14 +31,17 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { CodeEditorServiceImpl } from 'vs/editor/browser/services/codeEditorServiceImpl';
|
||||
import {
|
||||
SimpleConfigurationService, SimpleResourceConfigurationService, SimpleMenuService, SimpleMessageService,
|
||||
SimpleProgressService, StandaloneCommandService, StandaloneKeybindingService,
|
||||
StandaloneTelemetryService, SimpleWorkspaceContextService
|
||||
SimpleConfigurationService, SimpleResourceConfigurationService, SimpleMenuService,
|
||||
SimpleProgressService, StandaloneCommandService, StandaloneKeybindingService, SimpleNotificationService,
|
||||
StandaloneTelemetryService, SimpleWorkspaceContextService, SimpleConfirmationService
|
||||
} from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import { IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';
|
||||
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IConfirmationService } from 'vs/platform/dialogs/common/dialogs';
|
||||
|
||||
export interface IEditorContextViewService extends IContextViewService {
|
||||
dispose(): void;
|
||||
@@ -124,7 +126,9 @@ export module StaticServices {
|
||||
|
||||
export const telemetryService = define(ITelemetryService, () => new StandaloneTelemetryService());
|
||||
|
||||
export const messageService = define(IMessageService, () => new SimpleMessageService());
|
||||
export const confirmationService = define(IConfirmationService, () => new SimpleConfirmationService());
|
||||
|
||||
export const notificationService = define(INotificationService, () => new SimpleNotificationService());
|
||||
|
||||
export const markerService = define(IMarkerService, () => new MarkerService());
|
||||
|
||||
@@ -142,6 +146,8 @@ export module StaticServices {
|
||||
|
||||
export const storageService = define(IStorageService, () => NullStorageService);
|
||||
|
||||
export const logService = define(ILogService, () => new NullLogService());
|
||||
|
||||
}
|
||||
|
||||
export class DynamicStandaloneServices extends Disposable {
|
||||
@@ -157,7 +163,7 @@ export class DynamicStandaloneServices extends Disposable {
|
||||
this._instantiationService = _instantiationService;
|
||||
|
||||
const configurationService = this.get(IConfigurationService);
|
||||
const messageService = this.get(IMessageService);
|
||||
const notificationService = this.get(INotificationService);
|
||||
const telemetryService = this.get(ITelemetryService);
|
||||
|
||||
let ensure = <T>(serviceId: ServiceIdentifier<T>, factory: () => T): T => {
|
||||
@@ -176,11 +182,11 @@ export class DynamicStandaloneServices extends Disposable {
|
||||
|
||||
let commandService = ensure(ICommandService, () => new StandaloneCommandService(this._instantiationService));
|
||||
|
||||
ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, messageService, domElement)));
|
||||
ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
|
||||
|
||||
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, messageService)));
|
||||
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, new NullLogService())));
|
||||
|
||||
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, messageService, contextViewService)));
|
||||
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService)));
|
||||
|
||||
ensure(IMenuService, () => new SimpleMenuService(commandService));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user