Merge from vscode cbeff45f80213db0ddda2183170281ed97ed3b12 (#8670)

* Merge from vscode cbeff45f80213db0ddda2183170281ed97ed3b12

* fix null strict checks
This commit is contained in:
Anthony Dresser
2019-12-13 00:50:37 -08:00
committed by GitHub
parent 67abc2f690
commit 642920504a
136 changed files with 2918 additions and 1729 deletions

View File

@@ -996,6 +996,7 @@ class EditorAccessibilitySupport extends BaseEditorOption<EditorOption.accessibi
/**
* The kind of animation in which the editor's cursor should be rendered.
* @internal
*/
export const enum TextEditorCursorBlinkingStyle {
/**
@@ -1040,6 +1041,7 @@ function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth'
/**
* The style in which the editor's cursor should be rendered.
* @internal
*/
export enum TextEditorCursorStyle {
/**
@@ -1165,6 +1167,9 @@ export interface IEditorFindOptions {
globalFindClipboard?: boolean;
}
/**
* @internal
*/
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions> {
@@ -1352,6 +1357,9 @@ export interface IGotoLocationOptions {
alternativeReferenceCommand?: string;
}
/**
* @internal
*/
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoToLocationOptions> {
@@ -1481,6 +1489,9 @@ export interface IEditorHoverOptions {
sticky?: boolean;
}
/**
* @internal
*/
export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>;
class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOptions> {
@@ -1857,6 +1868,9 @@ export interface IEditorLightbulbOptions {
enabled?: boolean;
}
/**
* @internal
*/
export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>;
class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, EditorLightbulbOptions> {
@@ -1948,6 +1962,9 @@ export interface IEditorMinimapOptions {
scale?: number;
}
/**
* @internal
*/
export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>;
class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimapOptions> {
@@ -2049,6 +2066,9 @@ export interface IEditorParameterHintOptions {
cycle?: boolean;
}
/**
* @internal
*/
export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>;
class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints, InternalParameterHintOptions> {
@@ -2115,6 +2135,9 @@ export interface IQuickSuggestionsOptions {
strings: boolean;
}
/**
* @internal
*/
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;
class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggestions, ValidQuickSuggestionsOptions> {
@@ -2191,6 +2214,9 @@ class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggesti
export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
/**
* @internal
*/
export const enum RenderLineNumbersType {
Off = 0,
On = 1,
@@ -2199,6 +2225,9 @@ export const enum RenderLineNumbersType {
Custom = 4
}
/**
* @internal
*/
export interface InternalEditorRenderLineNumbersOptions {
readonly renderType: RenderLineNumbersType;
readonly renderFn: ((lineNumber: number) => string) | null;
@@ -2354,6 +2383,9 @@ export interface IEditorScrollbarOptions {
horizontalSliderSize?: number;
}
/**
* @internal
*/
export interface InternalEditorScrollbarOptions {
readonly arrowSize: number;
readonly vertical: ScrollbarVisibility;
@@ -2568,6 +2600,9 @@ export interface ISuggestOptions {
showSnippets?: boolean;
}
/**
* @internal
*/
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSuggestOptions> {
@@ -2861,6 +2896,7 @@ class EditorTabFocusMode extends ComputedEditorOption<EditorOption.tabFocusMode,
/**
* Describes how to indent wrapped lines.
* @internal
*/
export const enum WrappingIndent {
/**
@@ -2894,6 +2930,9 @@ function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' |
//#region wrappingInfo
/**
* @internal
*/
export interface EditorWrappingInfo {
readonly isDominatedByLongLines: boolean;
readonly isWordWrapMinified: boolean;

View File

@@ -17,7 +17,7 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
import { EditorSimpleWorker } from 'vs/editor/common/services/editorSimpleWorker';
import { IDiffComputationResult, IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { regExpFlags } from 'vs/base/common/strings';
import { isNonEmptyArray } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
@@ -52,7 +52,7 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker
private readonly _logService: ILogService;
constructor(
@IModelService modelService: IModelService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IResourceConfigurationService configurationService: IResourceConfigurationService,
@ILogService logService: ILogService
) {
super();
@@ -129,14 +129,14 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker
class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
private readonly _workerManager: WorkerManager;
private readonly _configurationService: ITextResourceConfigurationService;
private readonly _configurationService: IResourceConfigurationService;
private readonly _modelService: IModelService;
readonly _debugDisplayName = 'wordbasedCompletions';
constructor(
workerManager: WorkerManager,
configurationService: ITextResourceConfigurationService,
configurationService: IResourceConfigurationService,
modelService: IModelService
) {
this._workerManager = workerManager;

View File

@@ -14,7 +14,7 @@ import { Range } from 'vs/editor/common/core/range';
import { DefaultEndOfLine, EndOfLinePreference, EndOfLineSequence, IIdentifiedSingleEditOperation, ITextBuffer, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from 'vs/editor/common/model';
import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel';
import { IModelLanguageChangedEvent, IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
import { LanguageIdentifier, SemanticTokensProviderRegistry, SemanticTokensProvider, SemanticTokensLegend, SemanticTokens, SemanticTokensEdits } from 'vs/editor/common/modes';
import { LanguageIdentifier, SemanticTokensProviderRegistry, SemanticTokensProvider, SemanticTokensLegend, SemanticTokens, SemanticTokensEdits, TokenMetadata } from 'vs/editor/common/modes';
import { PLAINTEXT_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/modesRegistry';
import { ILanguageSelection } from 'vs/editor/common/services/modeService';
import { IModelService } from 'vs/editor/common/services/modelService';
@@ -24,6 +24,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { SparseEncodedTokens, MultilineTokens2 } from 'vs/editor/common/model/tokensStore';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
function MODEL_ID(resource: URI): string {
return resource.toString();
@@ -120,7 +121,8 @@ export class ModelServiceImpl extends Disposable implements IModelService {
constructor(
@IConfigurationService configurationService: IConfigurationService,
@ITextResourcePropertiesService resourcePropertiesService: ITextResourcePropertiesService,
@IThemeService themeService: IThemeService
@IThemeService themeService: IThemeService,
@ILogService logService: ILogService
) {
super();
this._configurationService = configurationService;
@@ -131,7 +133,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
this._configurationServiceSubscription = this._configurationService.onDidChangeConfiguration(e => this._updateModelOptions());
this._updateModelOptions();
this._register(new SemanticColoringFeature(this, themeService));
this._register(new SemanticColoringFeature(this, themeService, logService));
}
private static _readModelOptions(config: IRawConfig, isForSimpleWidget: boolean): ITextModelCreationOptions {
@@ -443,10 +445,10 @@ class SemanticColoringFeature extends Disposable {
private _watchers: Record<string, ModelSemanticColoring>;
private _semanticStyling: SemanticStyling;
constructor(modelService: IModelService, themeService: IThemeService) {
constructor(modelService: IModelService, themeService: IThemeService, logService: ILogService) {
super();
this._watchers = Object.create(null);
this._semanticStyling = this._register(new SemanticStyling(themeService));
this._semanticStyling = this._register(new SemanticStyling(themeService, logService));
this._register(modelService.onModelAdded((model) => {
this._watchers[model.uri.toString()] = new ModelSemanticColoring(model, themeService, this._semanticStyling);
}));
@@ -462,7 +464,8 @@ class SemanticStyling extends Disposable {
private _caches: WeakMap<SemanticTokensProvider, SemanticColoringProviderStyling>;
constructor(
private readonly _themeService: IThemeService
private readonly _themeService: IThemeService,
private readonly _logService: ILogService
) {
super();
this._caches = new WeakMap<SemanticTokensProvider, SemanticColoringProviderStyling>();
@@ -476,7 +479,7 @@ class SemanticStyling extends Disposable {
public get(provider: SemanticTokensProvider): SemanticColoringProviderStyling {
if (!this._caches.has(provider)) {
this._caches.set(provider, new SemanticColoringProviderStyling(provider.getLegend(), this._themeService));
this._caches.set(provider, new SemanticColoringProviderStyling(provider.getLegend(), this._themeService, this._logService));
}
return this._caches.get(provider)!;
}
@@ -581,7 +584,8 @@ class SemanticColoringProviderStyling {
constructor(
private readonly _legend: SemanticTokensLegend,
private readonly _themeService: IThemeService
private readonly _themeService: IThemeService,
private readonly _logService: ILogService
) {
this._hashTable = new HashTable();
}
@@ -605,6 +609,9 @@ class SemanticColoringProviderStyling {
if (typeof metadata === 'undefined') {
metadata = Constants.NO_STYLING;
}
if (this._logService.getLevel() === LogLevel.Trace) {
this._logService.trace(`getTokenStyleMetadata(${tokenType}${tokenModifiers.length ? ', ' + tokenModifiers.join(' ') : ''}): foreground: ${TokenMetadata.getForeground(metadata)}, fontStyle ${TokenMetadata.getFontStyle(metadata).toString(2)}`);
}
this._hashTable.add(tokenTypeIndex, tokenModifierSet, metadata);
return metadata;

View File

@@ -6,19 +6,37 @@
import { Event } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { IPosition } from 'vs/editor/common/core/position';
import { IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const ITextResourceConfigurationService = createDecorator<ITextResourceConfigurationService>('textResourceConfigurationService');
export const IResourceConfigurationService = createDecorator<IResourceConfigurationService>('resourceConfigurationService');
export interface ITextResourceConfigurationService {
export interface IResourceConfigurationChangeEvent {
/**
* All affected keys. Also includes language overrides and keys changed under language overrides.
*/
readonly affectedKeys: string[];
/**
* Returns `true` if the given section has changed for the given resource.
*
* Example: To check if the configuration section has changed for a given resource use `e.affectsConfiguration(resource, section)`.
*
* @param resource Resource for which the configuration has to be checked.
* @param section Section of the configuration
*/
affectsConfiguration(resource: URI, section: string): boolean;
}
export interface IResourceConfigurationService {
_serviceBrand: undefined;
/**
* Event that fires when the configuration changes.
*/
onDidChangeConfiguration: Event<IConfigurationChangeEvent>;
onDidChangeConfiguration: Event<IResourceConfigurationChangeEvent>;
/**
* Fetches the value of the section for the given resource by applying language overrides.
@@ -32,6 +50,20 @@ export interface ITextResourceConfigurationService {
getValue<T>(resource: URI | undefined, section?: string): T;
getValue<T>(resource: URI | undefined, position?: IPosition, section?: string): T;
/**
* Update the configuration value for the given resource at the effective location.
*
* - If configurationTarget is not specified, target will be derived by checking where the configuration is defined.
* - If the language overrides for the give resource contains the configuration, then it is updated.
*
* @param resource Resource for which the configuration has to be updated
* @param key Configuration key
* @param value Configuration value
* @param configurationTarget Optional target into which the configuration has to be updated.
* If not specified, target will be derived by checking where the configuration is defined.
*/
updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void>;
}
export const ITextResourcePropertiesService = createDecorator<ITextResourcePropertiesService>('textResourcePropertiesService');
@@ -44,4 +76,4 @@ export interface ITextResourcePropertiesService {
* Returns the End of Line characters for the given resource
*/
getEOL(resource: URI | undefined, language?: string): string;
}
}

View File

@@ -9,15 +9,15 @@ import { URI } from 'vs/base/common/uri';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IResourceConfigurationService, IResourceConfigurationChangeEvent } from 'vs/editor/common/services/resourceConfiguration';
import { IConfigurationService, ConfigurationTarget, IConfigurationValue, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
export class TextResourceConfigurationService extends Disposable implements ITextResourceConfigurationService {
export class TextResourceConfigurationService extends Disposable implements IResourceConfigurationService {
public _serviceBrand: undefined;
private readonly _onDidChangeConfiguration: Emitter<IConfigurationChangeEvent> = this._register(new Emitter<IConfigurationChangeEvent>());
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
private readonly _onDidChangeConfiguration: Emitter<IResourceConfigurationChangeEvent> = this._register(new Emitter<IResourceConfigurationChangeEvent>());
public readonly onDidChangeConfiguration: Event<IResourceConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
@@ -25,7 +25,7 @@ export class TextResourceConfigurationService extends Disposable implements ITex
@IModeService private readonly modeService: IModeService,
) {
super();
this._register(this.configurationService.onDidChangeConfiguration(e => this._onDidChangeConfiguration.fire(e)));
this._register(this.configurationService.onDidChangeConfiguration(e => this._onDidChangeConfiguration.fire(this.toResourceConfigurationChangeEvent(e))));
}
getValue<T>(resource: URI, section?: string): T;
@@ -37,6 +37,67 @@ export class TextResourceConfigurationService extends Disposable implements ITex
return this._getValue(resource, null, typeof arg2 === 'string' ? arg2 : undefined);
}
updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void> {
const language = this.getLanguage(resource, null);
const configurationValue = this.configurationService.inspect(key, { resource, overrideIdentifier: language });
if (configurationTarget === undefined) {
configurationTarget = this.deriveConfigurationTarget(configurationValue, language);
}
switch (configurationTarget) {
case ConfigurationTarget.MEMORY:
return this._updateValue(key, value, configurationTarget, configurationValue.memoryTarget?.override, resource, language);
case ConfigurationTarget.WORKSPACE_FOLDER:
return this._updateValue(key, value, configurationTarget, configurationValue.workspaceFolderTarget?.override, resource, language);
case ConfigurationTarget.WORKSPACE:
return this._updateValue(key, value, configurationTarget, configurationValue.workspaceTarget?.override, resource, language);
case ConfigurationTarget.USER_REMOTE:
return this._updateValue(key, value, configurationTarget, configurationValue.userRemoteTarget?.override, resource, language);
default:
return this._updateValue(key, value, configurationTarget, configurationValue.userLocalTarget?.override, resource, language);
}
}
private _updateValue(key: string, value: any, configurationTarget: ConfigurationTarget, overriddenValue: any | undefined, resource: URI, language: string | null): Promise<void> {
if (language && overriddenValue !== undefined) {
return this.configurationService.updateValue(key, value, { resource, overrideIdentifier: language }, configurationTarget);
} else {
return this.configurationService.updateValue(key, value, { resource }, configurationTarget);
}
}
private deriveConfigurationTarget(configurationValue: IConfigurationValue<any>, language: string | null): ConfigurationTarget {
if (language) {
if (configurationValue.memoryTarget?.override !== undefined) {
return ConfigurationTarget.MEMORY;
}
if (configurationValue.workspaceFolderTarget?.override !== undefined) {
return ConfigurationTarget.WORKSPACE_FOLDER;
}
if (configurationValue.workspaceTarget?.override !== undefined) {
return ConfigurationTarget.WORKSPACE;
}
if (configurationValue.userRemoteTarget?.override !== undefined) {
return ConfigurationTarget.USER_REMOTE;
}
if (configurationValue.userLocalTarget?.override !== undefined) {
return ConfigurationTarget.USER_LOCAL;
}
}
if (configurationValue.memoryTarget?.value !== undefined) {
return ConfigurationTarget.MEMORY;
}
if (configurationValue.workspaceFolderTarget?.value !== undefined) {
return ConfigurationTarget.WORKSPACE_FOLDER;
}
if (configurationValue.workspaceTarget?.value !== undefined) {
return ConfigurationTarget.WORKSPACE;
}
if (configurationValue.userRemoteTarget?.value !== undefined) {
return ConfigurationTarget.USER_REMOTE;
}
return ConfigurationTarget.USER_LOCAL;
}
private _getValue<T>(resource: URI, position: IPosition | null, section: string | undefined): T {
const language = resource ? this.getLanguage(resource, position) : undefined;
if (typeof section === 'undefined') {
@@ -51,6 +112,15 @@ export class TextResourceConfigurationService extends Disposable implements ITex
return position ? this.modeService.getLanguageIdentifier(model.getLanguageIdAtPosition(position.lineNumber, position.column))!.language : model.getLanguageIdentifier().language;
}
return this.modeService.getModeIdByFilepathOrFirstLine(resource);
}
}
private toResourceConfigurationChangeEvent(configurationChangeEvent: IConfigurationChangeEvent): IResourceConfigurationChangeEvent {
return {
affectedKeys: configurationChangeEvent.affectedKeys,
affectsConfiguration: (resource: URI, configuration: string) => {
const overrideIdentifier = this.getLanguage(resource, null);
return configurationChangeEvent.affectsConfiguration(configuration, { resource, overrideIdentifier });
}
};
}
}

View File

@@ -333,111 +333,12 @@ export enum CursorChangeReason {
Redo = 6
}
export enum AccessibilitySupport {
/**
* This should be the browser case where it is not known if a screen reader is attached or no.
*/
Unknown = 0,
Disabled = 1,
Enabled = 2
}
/**
* The kind of animation in which the editor's cursor should be rendered.
*/
export enum TextEditorCursorBlinkingStyle {
/**
* Hidden
*/
Hidden = 0,
/**
* Blinking
*/
Blink = 1,
/**
* Blinking with smooth fading
*/
Smooth = 2,
/**
* Blinking with prolonged filled state and smooth fading
*/
Phase = 3,
/**
* Expand collapse animation on the y axis
*/
Expand = 4,
/**
* No-Blinking
*/
Solid = 5
}
/**
* The style in which the editor's cursor should be rendered.
*/
export enum TextEditorCursorStyle {
/**
* As a vertical line (sitting between two characters).
*/
Line = 1,
/**
* As a block (sitting on top of a character).
*/
Block = 2,
/**
* As a horizontal line (sitting under a character).
*/
Underline = 3,
/**
* As a thin vertical line (sitting between two characters).
*/
LineThin = 4,
/**
* As an outlined block (sitting on top of a character).
*/
BlockOutline = 5,
/**
* As a thin horizontal line (sitting under a character).
*/
UnderlineThin = 6
}
export enum RenderMinimap {
None = 0,
Text = 1,
Blocks = 2
}
export enum RenderLineNumbersType {
Off = 0,
On = 1,
Relative = 2,
Interval = 3,
Custom = 4
}
/**
* Describes how to indent wrapped lines.
*/
export enum WrappingIndent {
/**
* No indentation => wrapped lines begin at column 1.
*/
None = 0,
/**
* Same => wrapped lines get the same indentation as the parent.
*/
Same = 1,
/**
* Indent => wrapped lines get +1 indentation toward the parent.
*/
Indent = 2,
/**
* DeepIndent => wrapped lines get +2 indentation toward the parent.
*/
DeepIndent = 3
}
/**
* A positioning preference for rendering content widgets.
*/