-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #3122: Add snippet support to tasks.json
- Loading branch information
Showing
9 changed files
with
218 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "tasks", | ||
"description": "Extension to add support for tasks.json files", | ||
"displayName": "Tasks.json support for VSCode", | ||
"version": "0.10.1", | ||
"author": "Microsoft Corporation", | ||
"license": "MIT", | ||
"publisher": "vscode", | ||
"engines": { | ||
"vscode": "*" | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../gulpfile.plugins.js compile-plugin:tasks ./src/tsconfig.json" | ||
}, | ||
"activationEvents": [ | ||
"onLanguage:json" | ||
], | ||
"main": "./out/tasksMain", | ||
"contributes": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import * as path from 'path'; | ||
|
||
import { languages, workspace, ExtensionContext, TextDocument, Position, CancellationToken, CompletionItem, CompletionItemKind, DocumentFilter } from 'vscode'; | ||
|
||
export function activate(context: ExtensionContext): void { | ||
// We can't use a pattern here since it disables the normal json code complete | ||
// which we don't want. Do the filtering in the actual suggest | ||
let selector: DocumentFilter = { language: 'json' }; | ||
let taskFileName = workspace.rootPath ? path.join(workspace.rootPath, '.vscode/tasks.json') : null; | ||
let items = taskFileName ? createCompletionItems() : []; | ||
|
||
languages.registerCompletionItemProvider(selector, { | ||
provideCompletionItems: (document: TextDocument, position: Position, token: CancellationToken): CompletionItem[] => { | ||
if (document.fileName === taskFileName) { | ||
return items; | ||
} else { | ||
return []; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
function createCompletionItems(): CompletionItem[] { | ||
let result: CompletionItem[] = []; | ||
let item: CompletionItem; | ||
|
||
item = new CompletionItem('tsc'); | ||
item.kind = CompletionItemKind.Snippet; | ||
item.detail = 'Use the tsc compiler on a specific file.'; | ||
item.filterText = 'ts-tsc'; | ||
item.insertText = [ | ||
'"version": "0.1.0",', | ||
'"command": "tsc",', | ||
'"isShellCommand": true,', | ||
'"showOutput": "silent",', | ||
'"args": ["HelloWorld.ts"],', | ||
'"problemMatcher": "$tsc"' | ||
].join('\n'); | ||
result.push(item); | ||
|
||
item = new CompletionItem('tsc - tsconfig.json'); | ||
item.kind = CompletionItemKind.Snippet; | ||
item.detail = 'Use the tsc compiler with a tsconfig.json file.'; | ||
item.filterText = 'ts-tsc - tsconfig.json'; | ||
item.insertText = [ | ||
'"version": "0.1.0",', | ||
'"command": "tsc",', | ||
'"isShellCommand": true,', | ||
'"showOutput": "silent",', | ||
'"args": ["-p", "."],', | ||
'"problemMatcher": "$tsc"' | ||
].join('\n'); | ||
result.push(item); | ||
|
||
item = new CompletionItem('tsc - watch'); | ||
item.kind = CompletionItemKind.Snippet; | ||
item.detail = 'Use the tsc compiler in watch mode.'; | ||
item.filterText = 'ts-tsc - watch'; | ||
item.insertText = [ | ||
'"version": "0.1.0",', | ||
'"command": "tsc",', | ||
'"isShellCommand": true,', | ||
'"showOutput": "silent",', | ||
'"args": ["-w", "-p", "."],', | ||
'"problemMatcher": "$tsc-watch"' | ||
].join('\n'); | ||
result.push(item); | ||
|
||
item = new CompletionItem('msbuild'); | ||
item.kind = CompletionItemKind.Snippet; | ||
item.detail = 'Use msbuild to compile your project.'; | ||
item.filterText = 'ts-msbuild'; | ||
item.insertText = [ | ||
'"version": "0.1.0",', | ||
'"command": "msbuild",', | ||
'"args": [', | ||
'\t// Ask msbuild to generate full paths for file names.', | ||
'\t"/property:GenerateFullPaths=true"', | ||
'],', | ||
'"taskSelector": "/t:",', | ||
'"showOutput": "silent",', | ||
'"tasks": [', | ||
'\t{', | ||
'\t\t"taskName": "build",', | ||
'\t\t// Show the output window only if unrecognized errors occur.', | ||
'\t\t"showOutput": "silent",', | ||
'\t\t// Use the standard MS compiler pattern to detect errors, warnings and infos', | ||
'\t\t"problemMatcher": "$msCompile"', | ||
'\t}', | ||
']' | ||
].join('\n'); | ||
result.push(item); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"noLib": true, | ||
"sourceMap": true, | ||
"outDir": "../out" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; | ||
declare function clearTimeout(timeoutId: NodeJS.Timer): void; | ||
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; | ||
declare function clearInterval(intervalId: NodeJS.Timer): void; | ||
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; | ||
declare function clearImmediate(immediateId: any): void; | ||
|
||
interface Console { | ||
assert(test?: boolean, message?: string, ...optionalParams: any[]): void; | ||
dir(value?: any, ...optionalParams: any[]): void; | ||
error(message?: any, ...optionalParams: any[]): void; | ||
info(message?: any, ...optionalParams: any[]): void; | ||
log(message?: any, ...optionalParams: any[]): void; | ||
time(timerName?: string): void; | ||
timeEnd(timerName?: string): void; | ||
trace(message?: any, ...optionalParams: any[]): void; | ||
warn(message?: any, ...optionalParams: any[]): void; | ||
} | ||
|
||
declare var Console: { | ||
prototype: Console; | ||
new(): Console; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
/// <reference path='../../../../src/vs/vscode.d.ts'/> | ||
/// <reference path='../../../../src/typings/mocha.d.ts'/> | ||
/// <reference path='../../../../extensions/node.d.ts'/> | ||
/// <reference path='../../../../extensions/lib.core.d.ts'/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.