mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -1,130 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export class EditorModeContext extends Disposable {
|
||||
|
||||
private _editor: ICommonCodeEditor;
|
||||
|
||||
private _langId: IContextKey<string>;
|
||||
private _hasCompletionItemProvider: IContextKey<boolean>;
|
||||
private _hasCodeActionsProvider: IContextKey<boolean>;
|
||||
private _hasCodeLensProvider: IContextKey<boolean>;
|
||||
private _hasDefinitionProvider: IContextKey<boolean>;
|
||||
private _hasImplementationProvider: IContextKey<boolean>;
|
||||
private _hasTypeDefinitionProvider: IContextKey<boolean>;
|
||||
private _hasHoverProvider: IContextKey<boolean>;
|
||||
private _hasDocumentHighlightProvider: IContextKey<boolean>;
|
||||
private _hasDocumentSymbolProvider: IContextKey<boolean>;
|
||||
private _hasReferenceProvider: IContextKey<boolean>;
|
||||
private _hasRenameProvider: IContextKey<boolean>;
|
||||
private _hasDocumentFormattingProvider: IContextKey<boolean>;
|
||||
private _hasDocumentSelectionFormattingProvider: IContextKey<boolean>;
|
||||
private _hasSignatureHelpProvider: IContextKey<boolean>;
|
||||
private _isInWalkThrough: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
editor: ICommonCodeEditor,
|
||||
contextKeyService: IContextKeyService
|
||||
) {
|
||||
super();
|
||||
this._editor = editor;
|
||||
|
||||
this._langId = EditorContextKeys.languageId.bindTo(contextKeyService);
|
||||
this._hasCompletionItemProvider = EditorContextKeys.hasCompletionItemProvider.bindTo(contextKeyService);
|
||||
this._hasCodeActionsProvider = EditorContextKeys.hasCodeActionsProvider.bindTo(contextKeyService);
|
||||
this._hasCodeLensProvider = EditorContextKeys.hasCodeLensProvider.bindTo(contextKeyService);
|
||||
this._hasDefinitionProvider = EditorContextKeys.hasDefinitionProvider.bindTo(contextKeyService);
|
||||
this._hasImplementationProvider = EditorContextKeys.hasImplementationProvider.bindTo(contextKeyService);
|
||||
this._hasTypeDefinitionProvider = EditorContextKeys.hasTypeDefinitionProvider.bindTo(contextKeyService);
|
||||
this._hasHoverProvider = EditorContextKeys.hasHoverProvider.bindTo(contextKeyService);
|
||||
this._hasDocumentHighlightProvider = EditorContextKeys.hasDocumentHighlightProvider.bindTo(contextKeyService);
|
||||
this._hasDocumentSymbolProvider = EditorContextKeys.hasDocumentSymbolProvider.bindTo(contextKeyService);
|
||||
this._hasReferenceProvider = EditorContextKeys.hasReferenceProvider.bindTo(contextKeyService);
|
||||
this._hasRenameProvider = EditorContextKeys.hasRenameProvider.bindTo(contextKeyService);
|
||||
this._hasDocumentFormattingProvider = EditorContextKeys.hasDocumentFormattingProvider.bindTo(contextKeyService);
|
||||
this._hasDocumentSelectionFormattingProvider = EditorContextKeys.hasDocumentSelectionFormattingProvider.bindTo(contextKeyService);
|
||||
this._hasSignatureHelpProvider = EditorContextKeys.hasSignatureHelpProvider.bindTo(contextKeyService);
|
||||
this._isInWalkThrough = EditorContextKeys.isInEmbeddedEditor.bindTo(contextKeyService);
|
||||
|
||||
const update = () => this._update();
|
||||
|
||||
// update when model/mode changes
|
||||
this._register(editor.onDidChangeModel(update));
|
||||
this._register(editor.onDidChangeModelLanguage(update));
|
||||
|
||||
// update when registries change
|
||||
this._register(modes.SuggestRegistry.onDidChange(update));
|
||||
this._register(modes.CodeActionProviderRegistry.onDidChange(update));
|
||||
this._register(modes.CodeLensProviderRegistry.onDidChange(update));
|
||||
this._register(modes.DefinitionProviderRegistry.onDidChange(update));
|
||||
this._register(modes.ImplementationProviderRegistry.onDidChange(update));
|
||||
this._register(modes.TypeDefinitionProviderRegistry.onDidChange(update));
|
||||
this._register(modes.HoverProviderRegistry.onDidChange(update));
|
||||
this._register(modes.DocumentHighlightProviderRegistry.onDidChange(update));
|
||||
this._register(modes.DocumentSymbolProviderRegistry.onDidChange(update));
|
||||
this._register(modes.ReferenceProviderRegistry.onDidChange(update));
|
||||
this._register(modes.RenameProviderRegistry.onDidChange(update));
|
||||
this._register(modes.DocumentFormattingEditProviderRegistry.onDidChange(update));
|
||||
this._register(modes.DocumentRangeFormattingEditProviderRegistry.onDidChange(update));
|
||||
this._register(modes.SignatureHelpProviderRegistry.onDidChange(update));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
reset() {
|
||||
this._langId.reset();
|
||||
this._hasCompletionItemProvider.reset();
|
||||
this._hasCodeActionsProvider.reset();
|
||||
this._hasCodeLensProvider.reset();
|
||||
this._hasDefinitionProvider.reset();
|
||||
this._hasImplementationProvider.reset();
|
||||
this._hasTypeDefinitionProvider.reset();
|
||||
this._hasHoverProvider.reset();
|
||||
this._hasDocumentHighlightProvider.reset();
|
||||
this._hasDocumentSymbolProvider.reset();
|
||||
this._hasReferenceProvider.reset();
|
||||
this._hasRenameProvider.reset();
|
||||
this._hasDocumentFormattingProvider.reset();
|
||||
this._hasDocumentSelectionFormattingProvider.reset();
|
||||
this._hasSignatureHelpProvider.reset();
|
||||
this._isInWalkThrough.reset();
|
||||
}
|
||||
|
||||
private _update() {
|
||||
const model = this._editor.getModel();
|
||||
if (!model) {
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
this._langId.set(model.getLanguageIdentifier().language);
|
||||
this._hasCompletionItemProvider.set(modes.SuggestRegistry.has(model));
|
||||
this._hasCodeActionsProvider.set(modes.CodeActionProviderRegistry.has(model));
|
||||
this._hasCodeLensProvider.set(modes.CodeLensProviderRegistry.has(model));
|
||||
this._hasDefinitionProvider.set(modes.DefinitionProviderRegistry.has(model));
|
||||
this._hasImplementationProvider.set(modes.ImplementationProviderRegistry.has(model));
|
||||
this._hasTypeDefinitionProvider.set(modes.TypeDefinitionProviderRegistry.has(model));
|
||||
this._hasHoverProvider.set(modes.HoverProviderRegistry.has(model));
|
||||
this._hasDocumentHighlightProvider.set(modes.DocumentHighlightProviderRegistry.has(model));
|
||||
this._hasDocumentSymbolProvider.set(modes.DocumentSymbolProviderRegistry.has(model));
|
||||
this._hasReferenceProvider.set(modes.ReferenceProviderRegistry.has(model));
|
||||
this._hasRenameProvider.set(modes.RenameProviderRegistry.has(model));
|
||||
this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model));
|
||||
this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model));
|
||||
this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model));
|
||||
this._isInWalkThrough.set(model.uri.scheme === Schemas.walkThroughSnippet);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import { DEFAULT_WORD_REGEXP, ensureValidWordDefinition } from 'vs/editor/common
|
||||
import { createScopedLineTokens } from 'vs/editor/common/modes/supports';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IndentAction, EnterAction, IAutoClosingPair, LanguageConfiguration, IndentationRule, FoldingRules } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { IndentAction, EnterAction, IAutoClosingPair, LanguageConfiguration, IndentationRule, FoldingRules, IAutoClosingPairConditional } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { LanguageIdentifier, LanguageId } from 'vs/editor/common/modes';
|
||||
|
||||
/**
|
||||
@@ -46,18 +46,23 @@ export interface IIndentConverter {
|
||||
export class RichEditSupport {
|
||||
|
||||
private readonly _conf: LanguageConfiguration;
|
||||
private readonly _languageIdentifier: LanguageIdentifier;
|
||||
private _brackets: RichEditBrackets;
|
||||
private _electricCharacter: BracketElectricCharacterSupport;
|
||||
|
||||
public readonly electricCharacter: BracketElectricCharacterSupport;
|
||||
public readonly comments: ICommentsConfiguration;
|
||||
public readonly characterPair: CharacterPairSupport;
|
||||
public readonly wordDefinition: RegExp;
|
||||
public readonly onEnter: OnEnterSupport;
|
||||
public readonly indentRulesSupport: IndentRulesSupport;
|
||||
public readonly brackets: RichEditBrackets;
|
||||
public readonly indentationRules: IndentationRule;
|
||||
public readonly foldingRules: FoldingRules;
|
||||
|
||||
constructor(languageIdentifier: LanguageIdentifier, previous: RichEditSupport, rawConf: LanguageConfiguration) {
|
||||
this._languageIdentifier = languageIdentifier;
|
||||
|
||||
this._brackets = null;
|
||||
this._electricCharacter = null;
|
||||
|
||||
let prev: LanguageConfiguration = null;
|
||||
if (previous) {
|
||||
@@ -66,16 +71,11 @@ export class RichEditSupport {
|
||||
|
||||
this._conf = RichEditSupport._mergeConf(prev, rawConf);
|
||||
|
||||
if (this._conf.brackets) {
|
||||
this.brackets = new RichEditBrackets(languageIdentifier, this._conf.brackets);
|
||||
}
|
||||
|
||||
this.onEnter = RichEditSupport._handleOnEnter(this._conf);
|
||||
|
||||
this.comments = RichEditSupport._handleComments(this._conf);
|
||||
|
||||
this.characterPair = new CharacterPairSupport(this._conf);
|
||||
this.electricCharacter = new BracketElectricCharacterSupport(this.brackets, this.characterPair.getAutoClosingPairs(), this._conf.__electricCharacterSupport);
|
||||
|
||||
this.wordDefinition = this._conf.wordPattern || DEFAULT_WORD_REGEXP;
|
||||
|
||||
@@ -87,6 +87,29 @@ export class RichEditSupport {
|
||||
this.foldingRules = this._conf.folding || {};
|
||||
}
|
||||
|
||||
public get brackets(): RichEditBrackets {
|
||||
if (!this._brackets && this._conf.brackets) {
|
||||
this._brackets = new RichEditBrackets(this._languageIdentifier, this._conf.brackets);
|
||||
}
|
||||
return this._brackets;
|
||||
}
|
||||
|
||||
public get electricCharacter(): BracketElectricCharacterSupport {
|
||||
if (!this._electricCharacter) {
|
||||
let autoClosingPairs: IAutoClosingPairConditional[] = [];
|
||||
if (this._conf.autoClosingPairs) {
|
||||
autoClosingPairs = this._conf.autoClosingPairs;
|
||||
} else if (this._conf.brackets) {
|
||||
autoClosingPairs = this._conf.brackets.map(b => {
|
||||
return { open: b[0], close: b[1] };
|
||||
});
|
||||
}
|
||||
|
||||
this._electricCharacter = new BracketElectricCharacterSupport(this.brackets, autoClosingPairs, this._conf.__electricCharacterSupport);
|
||||
}
|
||||
return this._electricCharacter;
|
||||
}
|
||||
|
||||
private static _mergeConf(prev: LanguageConfiguration, current: LanguageConfiguration): LanguageConfiguration {
|
||||
return {
|
||||
comments: (prev ? current.comments || prev.comments : current.comments),
|
||||
@@ -112,7 +135,6 @@ export class RichEditSupport {
|
||||
}
|
||||
if (conf.indentationRules) {
|
||||
empty = false;
|
||||
onEnter.indentationRules = conf.indentationRules;
|
||||
}
|
||||
if (conf.onEnterRules) {
|
||||
empty = false;
|
||||
|
||||
@@ -16,10 +16,6 @@ export interface LanguageFilter {
|
||||
|
||||
export type LanguageSelector = string | LanguageFilter | (string | LanguageFilter)[];
|
||||
|
||||
export default function matches(selection: LanguageSelector, uri: URI, language: string): boolean {
|
||||
return score(selection, uri, language) > 0;
|
||||
}
|
||||
|
||||
export function score(selector: LanguageSelector, candidateUri: URI, candidateLanguage: string): number {
|
||||
|
||||
if (Array.isArray(selector)) {
|
||||
|
||||
@@ -71,10 +71,6 @@ export class ScopedLineTokens {
|
||||
return this._actual.findTokenIndexAtOffset(offset + this.firstCharOffset) - this._firstTokenIndex;
|
||||
}
|
||||
|
||||
public getTokenStartOffset(tokenIndex: number): number {
|
||||
return this._actual.getTokenStartOffset(tokenIndex + this._firstTokenIndex) - this.firstCharOffset;
|
||||
}
|
||||
|
||||
public getStandardTokenType(tokenIndex: number): modes.StandardTokenType {
|
||||
return this._actual.getStandardTokenType(tokenIndex + this._firstTokenIndex);
|
||||
}
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IndentationRule, IndentAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { IndentationRule } from 'vs/editor/common/modes/languageConfiguration';
|
||||
|
||||
export const enum IndentConsts {
|
||||
INCREASE_MASK = 0b00000001,
|
||||
DECREASE_MASK = 0b00000010,
|
||||
INDENT_NEXTLINE_MASK = 0b00000100,
|
||||
UNINDENT_MASK = 0b00001000,
|
||||
};
|
||||
}
|
||||
|
||||
export class IndentRulesSupport {
|
||||
|
||||
@@ -22,30 +21,6 @@ export class IndentRulesSupport {
|
||||
this._indentationRules = indentationRules;
|
||||
}
|
||||
|
||||
public onType(text: string): IndentAction {
|
||||
if (this._indentationRules) {
|
||||
if (this._indentationRules.unIndentedLinePattern && this._indentationRules.unIndentedLinePattern.test(text)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this._indentationRules.decreaseIndentPattern && this._indentationRules.decreaseIndentPattern.test(text)) {
|
||||
return IndentAction.Outdent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public containNonWhitespace(text: string): boolean {
|
||||
// the text doesn't contain any non-whitespace character.
|
||||
let nonWhitespaceIdx = strings.lastNonWhitespaceIndex(text);
|
||||
|
||||
if (nonWhitespaceIdx >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public shouldIncrease(text: string): boolean {
|
||||
if (this._indentationRules) {
|
||||
if (this._indentationRules.increaseIndentPattern && this._indentationRules.increaseIndentPattern.test(text)) {
|
||||
@@ -99,4 +74,3 @@ export class IndentRulesSupport {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IRange } from 'vs/editor/common/core/range';
|
||||
|
||||
export class BasicInplaceReplace {
|
||||
|
||||
public static INSTANCE = new BasicInplaceReplace();
|
||||
public static readonly INSTANCE = new BasicInplaceReplace();
|
||||
|
||||
public navigateValueSet(range1: IRange, text1: string, range2: IRange, text2: string, up: boolean): IInplaceReplaceSupportResult {
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { CharacterPair, IndentationRule, IndentAction, EnterAction, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { CharacterPair, IndentAction, EnterAction, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration';
|
||||
|
||||
export interface IOnEnterSupportOptions {
|
||||
brackets?: CharacterPair[];
|
||||
indentationRules?: IndentationRule;
|
||||
regExpRules?: OnEnterRule[];
|
||||
}
|
||||
|
||||
@@ -24,7 +23,6 @@ interface IProcessedBracketPair {
|
||||
export class OnEnterSupport {
|
||||
|
||||
private readonly _brackets: IProcessedBracketPair[];
|
||||
private readonly _indentationRules: IndentationRule;
|
||||
private readonly _regExpRules: OnEnterRule[];
|
||||
|
||||
constructor(opts?: IOnEnterSupportOptions) {
|
||||
@@ -44,7 +42,6 @@ export class OnEnterSupport {
|
||||
};
|
||||
});
|
||||
this._regExpRules = opts.regExpRules || [];
|
||||
this._indentationRules = opts.indentationRules;
|
||||
}
|
||||
|
||||
public onEnter(oneLineAboveText: string, beforeEnterText: string, afterEnterText: string): EnterAction {
|
||||
@@ -113,4 +110,3 @@ export class OnEnterSupport {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,14 +280,6 @@ export class ThemeTrieElementRule {
|
||||
return new ThemeTrieElementRule(this._fontStyle, this._foreground, this._background);
|
||||
}
|
||||
|
||||
public static cloneArr(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[] {
|
||||
let r: ThemeTrieElementRule[] = [];
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
r[i] = arr[i].clone();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public acceptOverwrite(fontStyle: FontStyle, foreground: ColorId, background: ColorId): void {
|
||||
if (fontStyle !== FontStyle.NotSet) {
|
||||
this._fontStyle = fontStyle;
|
||||
|
||||
@@ -60,10 +60,6 @@ export class TokenizationRegistryImpl implements ITokenizationRegistry {
|
||||
return this._colorMap;
|
||||
}
|
||||
|
||||
public getDefaultForeground(): Color {
|
||||
return this._colorMap[ColorId.DefaultForeground];
|
||||
}
|
||||
|
||||
public getDefaultBackground(): Color {
|
||||
return this._colorMap[ColorId.DefaultBackground];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user