mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from master
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
* 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 * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -11,8 +10,13 @@ import { getLocation, visit, parse, ParseErrorCode } from 'jsonc-parser';
|
||||
import * as path from 'path';
|
||||
import { SettingsDocument } from './settingsDocumentHelper';
|
||||
|
||||
const decoration = vscode.window.createTextEditorDecorationType({
|
||||
color: '#9e9e9e'
|
||||
const fadedDecoration = vscode.window.createTextEditorDecorationType({
|
||||
light: {
|
||||
color: '#757575'
|
||||
},
|
||||
dark: {
|
||||
color: '#878787'
|
||||
}
|
||||
});
|
||||
|
||||
let pendingLaunchJsonDecoration: NodeJS.Timer;
|
||||
@@ -65,7 +69,7 @@ function autoFixSettingsJSON(willSaveEvent: vscode.TextDocumentWillSaveEvent): v
|
||||
lastEndOfSomething = offset + length;
|
||||
},
|
||||
|
||||
onLiteralValue(value: any, offset: number, length: number): void {
|
||||
onLiteralValue(_value: any, offset: number, length: number): void {
|
||||
lastEndOfSomething = offset + length;
|
||||
},
|
||||
|
||||
@@ -73,7 +77,7 @@ function autoFixSettingsJSON(willSaveEvent: vscode.TextDocumentWillSaveEvent): v
|
||||
lastEndOfSomething = offset + length;
|
||||
},
|
||||
|
||||
onError(error: ParseErrorCode, offset: number, length: number): void {
|
||||
onError(error: ParseErrorCode, _offset: number, _length: number): void {
|
||||
if (error === ParseErrorCode.CommaExpected && lastEndOfSomething > -1) {
|
||||
const fixPosition = document.positionAt(lastEndOfSomething);
|
||||
|
||||
@@ -95,13 +99,14 @@ function registerKeybindingsCompletions(): vscode.Disposable {
|
||||
|
||||
return vscode.languages.registerCompletionItemProvider({ pattern: '**/keybindings.json' }, {
|
||||
|
||||
provideCompletionItems(document, position, token) {
|
||||
provideCompletionItems(document, position, _token) {
|
||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
if (location.path[1] === 'command') {
|
||||
|
||||
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||
return commands.then(ids => ids.map(id => newSimpleCompletionItem(JSON.stringify(id), range)));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -116,7 +121,7 @@ function registerSettingsCompletions(): vscode.Disposable {
|
||||
|
||||
function registerVariableCompletions(pattern: string): vscode.Disposable {
|
||||
return vscode.languages.registerCompletionItemProvider({ language: 'jsonc', pattern }, {
|
||||
provideCompletionItems(document, position, token) {
|
||||
provideCompletionItems(document, position, _token) {
|
||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
if (!location.isAtPropertyKey && location.previousNode && location.previousNode.type === 'string') {
|
||||
const indexOf$ = document.lineAt(position.line).text.indexOf('$');
|
||||
@@ -148,7 +153,7 @@ function registerExtensionsCompletions(): vscode.Disposable[] {
|
||||
|
||||
function registerExtensionsCompletionsInExtensionsDocument(): vscode.Disposable {
|
||||
return vscode.languages.registerCompletionItemProvider({ pattern: '**/extensions.json' }, {
|
||||
provideCompletionItems(document, position, token) {
|
||||
provideCompletionItems(document, position, _token) {
|
||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||
if (location.path[0] === 'recommendations') {
|
||||
@@ -162,7 +167,7 @@ function registerExtensionsCompletionsInExtensionsDocument(): vscode.Disposable
|
||||
|
||||
function registerExtensionsCompletionsInWorkspaceConfigurationDocument(): vscode.Disposable {
|
||||
return vscode.languages.registerCompletionItemProvider({ pattern: '**/*.code-workspace' }, {
|
||||
provideCompletionItems(document, position, token) {
|
||||
provideCompletionItems(document, position, _token) {
|
||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||
if (location.path[0] === 'extensions' && location.path[1] === 'recommendations') {
|
||||
@@ -199,6 +204,7 @@ function provideInstalledExtensionProposals(extensionsContent: IExtensionsConten
|
||||
return [example];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function newSimpleCompletionItem(label: string, range: vscode.Range, description?: string, insertText?: string): vscode.CompletionItem {
|
||||
@@ -228,24 +234,24 @@ function updateLaunchJsonDecorations(editor: vscode.TextEditor | undefined): voi
|
||||
ranges.push(new vscode.Range(editor.document.positionAt(offset), editor.document.positionAt(offset + length)));
|
||||
}
|
||||
},
|
||||
onLiteralValue: (value, offset, length) => {
|
||||
onLiteralValue: (_value, offset, length) => {
|
||||
if (addPropertyAndValue) {
|
||||
ranges.push(new vscode.Range(editor.document.positionAt(offset), editor.document.positionAt(offset + length)));
|
||||
}
|
||||
},
|
||||
onArrayBegin: (offset: number, length: number) => {
|
||||
onArrayBegin: (_offset: number, _length: number) => {
|
||||
depthInArray++;
|
||||
},
|
||||
onArrayEnd: (offset: number, length: number) => {
|
||||
onArrayEnd: (_offset: number, _length: number) => {
|
||||
depthInArray--;
|
||||
}
|
||||
});
|
||||
|
||||
editor.setDecorations(decoration, ranges);
|
||||
editor.setDecorations(fadedDecoration, ranges);
|
||||
}
|
||||
|
||||
vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', language: 'jsonc' }, {
|
||||
provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
|
||||
provideDocumentSymbols(document: vscode.TextDocument, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
|
||||
const result: vscode.SymbolInformation[] = [];
|
||||
let name: string = '';
|
||||
let lastProperty = '';
|
||||
@@ -253,21 +259,21 @@ vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', lan
|
||||
let depthInObjects = 0;
|
||||
|
||||
visit(document.getText(), {
|
||||
onObjectProperty: (property, offset, length) => {
|
||||
onObjectProperty: (property, _offset, _length) => {
|
||||
lastProperty = property;
|
||||
},
|
||||
onLiteralValue: (value: any, offset: number, length: number) => {
|
||||
onLiteralValue: (value: any, _offset: number, _length: number) => {
|
||||
if (lastProperty === 'name') {
|
||||
name = value;
|
||||
}
|
||||
},
|
||||
onObjectBegin: (offset: number, length: number) => {
|
||||
onObjectBegin: (offset: number, _length: number) => {
|
||||
depthInObjects++;
|
||||
if (depthInObjects === 2) {
|
||||
startOffset = offset;
|
||||
}
|
||||
},
|
||||
onObjectEnd: (offset: number, length: number) => {
|
||||
onObjectEnd: (offset: number, _length: number) => {
|
||||
if (name && depthInObjects === 2) {
|
||||
result.push(new vscode.SymbolInformation(name, vscode.SymbolKind.Object, new vscode.Range(document.positionAt(startOffset), document.positionAt(offset))));
|
||||
}
|
||||
@@ -277,4 +283,4 @@ vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', lan
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
}, { label: 'Launch Targets' });
|
||||
|
||||
@@ -13,7 +13,7 @@ export class SettingsDocument {
|
||||
|
||||
constructor(private document: vscode.TextDocument) { }
|
||||
|
||||
public provideCompletionItems(position: vscode.Position, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
public provideCompletionItems(position: vscode.Position, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
const location = getLocation(this.document.getText(), this.document.offsetAt(position));
|
||||
const range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||
|
||||
@@ -40,7 +40,7 @@ export class SettingsDocument {
|
||||
return this.provideLanguageOverridesCompletionItems(location, position);
|
||||
}
|
||||
|
||||
private provideWindowTitleCompletionItems(location: Location, range: vscode.Range): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
private provideWindowTitleCompletionItems(_location: Location, range: vscode.Range): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
const completions: vscode.CompletionItem[] = [];
|
||||
|
||||
completions.push(this.newSimpleCompletionItem('${activeEditorShort}', range, localize('activeEditorShort', "the file name (e.g. myFile.txt)")));
|
||||
@@ -149,7 +149,7 @@ export class SettingsDocument {
|
||||
return Promise.resolve(completions);
|
||||
}
|
||||
|
||||
private provideLanguageCompletionItems(location: Location, range: vscode.Range, formatFunc: (string: string) => string = (l) => JSON.stringify(l)): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
private provideLanguageCompletionItems(_location: Location, range: vscode.Range, formatFunc: (string: string) => string = (l) => JSON.stringify(l)): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
return vscode.languages.getLanguages().then(languages => {
|
||||
const completionItems = [];
|
||||
const configuration = vscode.workspace.getConfiguration();
|
||||
|
||||
Reference in New Issue
Block a user