提交 7b12aeb4 编写于 作者: J Johannes Rieken

config-editing, api-test use strictNull-checks, #6907

上级 07464cb1
...@@ -44,12 +44,22 @@ function registerKeybindingsCompletions(): vscode.Disposable { ...@@ -44,12 +44,22 @@ function registerKeybindingsCompletions(): vscode.Disposable {
}); });
} }
function updateLaunchJsonDecorations(editor: vscode.TextEditor) { function newCompletionItem(text: string, range: vscode.Range) {
const item = new vscode.CompletionItem(JSON.stringify(text));
item.kind = vscode.CompletionItemKind.Value;
item.textEdit = {
range,
newText: item.label
};
return item;
}
function updateLaunchJsonDecorations(editor: vscode.TextEditor | undefined) {
if (!editor || path.basename(editor.document.fileName) !== 'launch.json') { if (!editor || path.basename(editor.document.fileName) !== 'launch.json') {
return; return;
} }
const ranges = []; const ranges: vscode.Range[] = [];
let addPropertyAndValue = false; let addPropertyAndValue = false;
visit(editor.document.getText(), { visit(editor.document.getText(), {
onObjectProperty: (property, offset, length) => { onObjectProperty: (property, offset, length) => {
...@@ -68,13 +78,3 @@ function updateLaunchJsonDecorations(editor: vscode.TextEditor) { ...@@ -68,13 +78,3 @@ function updateLaunchJsonDecorations(editor: vscode.TextEditor) {
editor.setDecorations(decoration, ranges); editor.setDecorations(decoration, ranges);
} }
function newCompletionItem(text: string, range: vscode.Range, documentation?: string) {
const item = new vscode.CompletionItem(JSON.stringify(text));
item.kind = vscode.CompletionItemKind.Value;
item.documentation = documentation;
item.textEdit = {
range,
newText: item.label
};
return item;
}
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
"noLib": true, "noLib": true,
"target": "es5", "target": "es5",
"module": "commonjs", "module": "commonjs",
"outDir": "./out" "outDir": "./out",
"strictNullChecks": true
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]
} }
\ No newline at end of file
...@@ -83,7 +83,7 @@ namespace ast { ...@@ -83,7 +83,7 @@ namespace ast {
let end = Number.MAX_VALUE; let end = Number.MAX_VALUE;
for (let name of dottedName.split('.')) { for (let name of dottedName.split('.')) {
let idx: number; let idx: number = -1;
while ((idx = identifiers.indexOf(name, idx + 1)) >= 0) { while ((idx = identifiers.indexOf(name, idx + 1)) >= 0) {
let myStart = spans[2 * idx]; let myStart = spans[2 * idx];
let myEnd = spans[2 * idx + 1]; let myEnd = spans[2 * idx + 1];
......
...@@ -62,7 +62,7 @@ export function cleanUp(): Thenable<any> { ...@@ -62,7 +62,7 @@ export function cleanUp(): Thenable<any> {
} }
}); });
vscode.commands.executeCommand('workbench.action.closeAllEditors').then(null, reject); vscode.commands.executeCommand('workbench.action.closeAllEditors').then(undefined, reject);
}).then(() => { }).then(() => {
assert.equal(vscode.window.visibleTextEditors.length, 0); assert.equal(vscode.window.visibleTextEditors.length, 0);
...@@ -76,4 +76,4 @@ export function cleanUp(): Thenable<any> { ...@@ -76,4 +76,4 @@ export function cleanUp(): Thenable<any> {
// assert.equal(vscode.workspace.textDocuments.length, 0); // assert.equal(vscode.workspace.textDocuments.length, 0);
}); });
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ suite('window namespace tests', () => { ...@@ -19,7 +19,7 @@ suite('window namespace tests', () => {
return window.showTextDocument(doc).then((editor) => { return window.showTextDocument(doc).then((editor) => {
const active = window.activeTextEditor; const active = window.activeTextEditor;
assert.ok(active); assert.ok(active);
assert.ok(pathEquals(active.document.uri.fsPath, doc.uri.fsPath)); assert.ok(pathEquals(active!.document.uri.fsPath, doc.uri.fsPath));
}); });
}); });
}); });
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
'use strict'; 'use strict';
import * as assert from 'assert'; import * as assert from 'assert';
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit } from 'vscode'; import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable } from 'vscode';
import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils'; import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils';
import { join, basename } from 'path'; import { join, basename } from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
...@@ -48,11 +48,13 @@ suite('workspace-namespace', () => { ...@@ -48,11 +48,13 @@ suite('workspace-namespace', () => {
test('textDocuments', () => { test('textDocuments', () => {
assert.ok(Array.isArray(workspace.textDocuments)); assert.ok(Array.isArray(workspace.textDocuments));
assert.throws(() => workspace.textDocuments = null); assert.throws(() => (<any>workspace).textDocuments = null);
}); });
test('rootPath', () => { test('rootPath', () => {
assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace'))); if (workspace.rootPath) {
assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace')));
}
assert.throws(() => workspace.rootPath = 'farboo'); assert.throws(() => workspace.rootPath = 'farboo');
}); });
...@@ -64,23 +66,22 @@ suite('workspace-namespace', () => { ...@@ -64,23 +66,22 @@ suite('workspace-namespace', () => {
}); });
}); });
test('openTextDocument, illegal path', done => { test('openTextDocument, illegal path', () => {
workspace.openTextDocument('funkydonky.txt').then(doc => { return workspace.openTextDocument('funkydonky.txt').then(doc => {
done(new Error('missing error')); throw new Error('missing error');
}, err => { }, err => {
done(); // good!
}); });
}); });
test('openTextDocument, untitled is dirty', function (done) { test('openTextDocument, untitled is dirty', function () {
if (process.platform === 'win32') { if (process.platform === 'win32') {
return done(); // TODO@Joh this test fails on windows return; // TODO@Joh this test fails on windows
} }
workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath, './newfile.txt'))).then(doc => { return workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath, './newfile.txt'))).then(doc => {
assert.equal(doc.uri.scheme, 'untitled'); assert.equal(doc.uri.scheme, 'untitled');
assert.ok(doc.isDirty); assert.ok(doc.isDirty);
done();
}); });
}); });
...@@ -137,7 +138,7 @@ suite('workspace-namespace', () => { ...@@ -137,7 +138,7 @@ suite('workspace-namespace', () => {
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => { test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
return createRandomFile().then(file => { return createRandomFile().then(file => {
let disposables = []; let disposables: Disposable[] = [];
let onDidOpenTextDocument = false; let onDidOpenTextDocument = false;
disposables.push(workspace.onDidOpenTextDocument(e => { disposables.push(workspace.onDidOpenTextDocument(e => {
...@@ -370,7 +371,7 @@ suite('workspace-namespace', () => { ...@@ -370,7 +371,7 @@ suite('workspace-namespace', () => {
}); });
test('findFiles', () => { test('findFiles', () => {
return workspace.findFiles('*.js', null).then((res) => { return workspace.findFiles('*.js').then((res) => {
assert.equal(res.length, 1); assert.equal(res.length, 1);
assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js'); assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js');
}); });
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
"target": "ES5", "target": "ES5",
"outDir": "out", "outDir": "out",
"noLib": true, "noLib": true,
"sourceMap": true "sourceMap": true,
"strictNullChecks": true
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]
} }
\ No newline at end of file
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
declare function run(): void; declare function run(): void;
declare function suite(name: string, fn: (err?) => void); declare function suite(name: string, fn: (err?) => void);
declare function test(name: string, fn: (done?: (err?) => void) => void); declare function test(name: string, fn: () => void);
declare function test(name: string, fn: (done: (err?) => void) => void);
declare function suiteSetup(fn: (done?: (err?) => void) => void); declare function suiteSetup(fn: (done?: (err?) => void) => void);
declare function suiteTeardown(fn: (done?: (err?) => void) => void); declare function suiteTeardown(fn: (done?: (err?) => void) => void);
declare function setup(fn: (done?: (err?) => void) => void); declare function setup(fn: (done?: (err?) => void) => void);
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
declare function run(): void; declare function run(): void;
declare function suite(name: string, fn: (err?) => void); declare function suite(name: string, fn: (err?) => void);
declare function test(name: string, fn: (done?: (err?) => void) => void); declare function test(name: string, fn: () => void);
declare function test(name: string, fn: (done: (err?) => void) => void);
declare function suiteSetup(fn: (done?: (err?) => void) => void); declare function suiteSetup(fn: (done?: (err?) => void) => void);
declare function suiteTeardown(fn: (done?: (err?) => void) => void); declare function suiteTeardown(fn: (done?: (err?) => void) => void);
declare function setup(fn: (done?: (err?) => void) => void); declare function setup(fn: (done?: (err?) => void) => void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册