提交 bd90379f 编写于 作者: J Joao Moreno

Merge remote-tracking branch 'origin/master' into ipc

package foo;
import org.junit.Test;
import org.junit.runners.*;
/*
* Multi line comment
......
[
{
"c": "package",
"t": "java.keyword.meta.other.package",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.keyword rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.keyword rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.keyword rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.keyword rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.keyword rgb(86, 156, 214)"
}
},
{
"c": " ",
"t": "java.meta.package",
"r": {
"dark_plus": ".vs-dark .token rgb(212, 212, 212)",
"light_plus": ".vs .token rgb(0, 0, 0)",
"dark_vs": ".vs-dark .token rgb(212, 212, 212)",
"light_vs": ".vs .token rgb(0, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
{
"c": "foo",
"t": "java.meta.modifier.package.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.package.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.package.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.package.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.package.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.package.java rgb(212, 212, 212)"
}
},
{
"c": ";",
"t": "java.meta.package.punctuation.terminator",
"r": {
"dark_plus": ".vs-dark .token rgb(212, 212, 212)",
"light_plus": ".vs .token rgb(0, 0, 0)",
"dark_vs": ".vs-dark .token rgb(212, 212, 212)",
"light_vs": ".vs .token rgb(0, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
{
"c": "import",
"t": "import.java.keyword.meta.other",
......@@ -25,55 +69,165 @@
"c": "org",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier rgb(86, 156, 214)"
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": ".",
"t": "import.java.meta.modifier.punctuation.separator.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier rgb(86, 156, 214)"
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": "junit",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier rgb(86, 156, 214)"
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": ".",
"t": "import.java.meta.modifier.punctuation.separator.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier rgb(86, 156, 214)"
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": "Test",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier rgb(86, 156, 214)"
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": ";",
"t": "import.java.meta.punctuation.terminator",
"r": {
"dark_plus": ".vs-dark .token rgb(212, 212, 212)",
"light_plus": ".vs .token rgb(0, 0, 0)",
"dark_vs": ".vs-dark .token rgb(212, 212, 212)",
"light_vs": ".vs .token rgb(0, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
{
"c": "import",
"t": "import.java.keyword.meta.other",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.keyword rgb(86, 156, 214)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.keyword rgb(0, 0, 255)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.keyword rgb(86, 156, 214)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.keyword rgb(0, 0, 255)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.keyword rgb(86, 156, 214)"
}
},
{
"c": " ",
"t": "import.java.meta",
"r": {
"dark_plus": ".vs-dark .token rgb(212, 212, 212)",
"light_plus": ".vs .token rgb(0, 0, 0)",
"dark_vs": ".vs-dark .token rgb(212, 212, 212)",
"light_vs": ".vs .token rgb(0, 0, 0)",
"hc_black": ".hc-black .token rgb(255, 255, 255)"
}
},
{
"c": "org",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": ".",
"t": "import.java.meta.modifier.punctuation.separator.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": "junit",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": ".",
"t": "import.java.meta.modifier.punctuation.separator.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": "runners",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": ".",
"t": "import.java.meta.modifier.punctuation.separator.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
"c": "*",
"t": "import.java.meta.modifier.storage",
"r": {
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"dark_vs": ".vs-dark.vscode-theme-defaults-themes-dark_vs-json .token.storage.modifier.import.java rgb(212, 212, 212)",
"light_vs": ".vs.vscode-theme-defaults-themes-light_vs-json .token.storage.modifier.import.java rgb(0, 0, 0)",
"hc_black": ".hc-black.vscode-theme-defaults-themes-hc_black-json .token.storage.modifier.import.java rgb(212, 212, 212)"
}
},
{
......
......@@ -111,12 +111,14 @@ export class BowerJSONContribution implements IJSONContribution {
}
public collectValueSuggestions(resource: string, location: Location, collector: ISuggestionsCollector): Thenable<any> {
// not implemented. Could be do done calling the bower command. Waiting for web API: https://github.com/bower/registry/issues/26
let proposal = new CompletionItem(localize('json.bower.latest.version', 'latest'));
proposal.insertText = '"{{latest}}"';
proposal.kind = CompletionItemKind.Value;
proposal.documentation = 'The latest version of the package';
collector.add(proposal);
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) {
// not implemented. Could be do done calling the bower command. Waiting for web API: https://github.com/bower/registry/issues/26
let proposal = new CompletionItem(localize('json.bower.latest.version', 'latest'));
proposal.insertText = '"{{latest}}"';
proposal.kind = CompletionItemKind.Value;
proposal.documentation = 'The latest version of the package';
collector.add(proposal);
}
return Promise.resolve(null);
}
......
from banana import *
class Monkey:
# Bananas the monkey can eat.
capacity = 10
......@@ -10,4 +9,58 @@ class Monkey:
def feeding_frenzy(self):
eat(9.25)
return "Yum yum"
\ No newline at end of file
return "Yum yum"
if 1900 < year < 2100 and 1 <= month <= 12 \
and 1 <= day <= 31 and 0 <= hour < 24 \
and 0 <= minute < 60 and 0 <= second < 60: # Looks like a valid date
return 1
def firstn(g, n):
for i in range(n):
yield g.next()
reduce(lambda x,y: x+y, [47,11,42,13])
woerter = {"house" : "Haus", "cat":"Katze", "black":"schwarz"}
mydictionary = {
'foo': 23, #comment
'bar': "hello" #sqadsad
}
def steuern(einkommen):
"""Berechnung der zu zahlenden Steuern fuer ein zu versteuerndes Einkommen von x"""
if einkommen <= 8004:
steuer = 0
elif einkommen <= 13469:
y = (einkommen -8004.0)/10000.0
steuer = (912.17 * y + 1400)*y
else:
steuer = einkommen * 0.44 - 15694
return steuer
def beliebig(x, y, *mehr):
print "x=", x, ", x=", y
print "mehr: ", mehr
class Memoize:
def __init__(self, fn):
self.fn = fn
self.memo = {}
def __call__(self, *args):
if args not in self.memo:
self.memo[args] = self.fn(*args)
return self.memo[args]
res = re.search(r"([0-9-]*)\s*([A-Za-z]+),\s+(.*)", i)
while True:
try:
n = raw_input("Number: ")
n = int(n)
break
except ValueError:
print("Not a number")
async with EXPR as VAR:
BLOCK
\ No newline at end of file
......@@ -278,6 +278,13 @@
"settings": {
"foreground": "#b5cea8"
}
},
{
"name": "coloring of the Java import and package identifiers",
"scope": ["storage.modifier.import.java", "storage.modifier.package.java"],
"settings": {
"foreground": "#d4d4d4"
}
}
]
}
\ No newline at end of file
......@@ -253,6 +253,13 @@
"settings": {
"foreground": "#b5cea8"
}
},
{
"name": "coloring of the Java import and package identifiers",
"scope": ["storage.modifier.import.java", "storage.modifier.package.java"],
"settings": {
"foreground": "#d4d4d4"
}
}
]
}
\ No newline at end of file
......@@ -267,6 +267,13 @@
"settings": {
"foreground": "#09885a"
}
},
{
"name": "coloring of the Java import and package identifiers",
"scope": ["storage.modifier.import.java", "storage.modifier.package.java"],
"settings": {
"foreground": "#000000"
}
}
]
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import strings = require('vs/base/common/strings');
import paths = require('vs/base/common/paths');
const CACHE: { [glob: string]: RegExp } = Object.create(null);
const MAX_CACHED = 10000;
export interface IExpression {
[pattern: string]: boolean | SiblingClause | any;
......@@ -233,8 +234,10 @@ function globToRegExp(pattern: string): RegExp {
// Convert to regexp and be ready for errors
let result = toRegExp(regEx);
// Make sure to cache
CACHE[pattern] = result;
// Make sure to cache (bounded)
if (Object.getOwnPropertyNames(CACHE).length < MAX_CACHED) {
CACHE[pattern] = result;
}
return result;
}
......@@ -247,9 +250,27 @@ function toRegExp(regEx: string): RegExp {
}
}
function testWithCache(glob: string, pattern: RegExp, cache: { [glob: string]: boolean }): boolean {
let res = cache[glob];
if (typeof res !== 'boolean') {
res = pattern.test(glob);
// Make sure to cache (bounded)
if (Object.getOwnPropertyNames(cache).length < MAX_CACHED) {
cache[glob] = res;
}
}
return res;
}
// regexes to check for trival glob patterns that just check for String#endsWith
const trivia1 = /^\*\*\/\*\.\w+$/;
const trivia2 = /^{\*\*\/\*\.\w+(,\*\*\/\*\.\w+)*}$/;
const trivia1 = /^\*\*\/\*\.[\w\.-]+$/; // **/*.something
const trivia2 = /^\*\*\/[\w\.-]+$/; // **/something
const trivia3 = /^{\*\*\/\*\.[\w\.-]+(,\*\*\/\*\.[\w\.-]+)*}$/; // {**/*.something,**/*.else}
const T1_CACHE: { [glob: string]: boolean } = Object.create(null);
const T2_CACHE: { [glob: string]: boolean } = Object.create(null);
const T3_CACHE: { [glob: string]: boolean } = Object.create(null);
/**
* Simplified glob matching. Supports a subset of glob patterns:
......@@ -269,16 +290,25 @@ export function match(arg1: string | IExpression, path: string, siblings?: strin
// Glob with String
if (typeof arg1 === 'string') {
if (trivia1.test(arg1)) {
// common pattern: **/*.txt just need endsWith check
// common pattern: **/*.txt just need endsWith check
if (testWithCache(arg1, trivia1, T1_CACHE)) {
return strings.endsWith(path, arg1.substr(4)); // '**/*'.length === 4
}
// common pattern: **/some.txt just need basename check
if (testWithCache(arg1, trivia2, T2_CACHE)) {
const base = arg1.substr(3); // '**/'.length === 3
} else if (trivia2.test(arg1)) {
// repetition of common patterns (see above) {**/*.txt,**/*.png}
return path === base || strings.endsWith(path, `/${base}`) || strings.endsWith(path, `\\${base}`);
}
// repetition of common patterns (see above) {**/*.txt,**/*.png}
if (testWithCache(arg1, trivia3, T3_CACHE)) {
return arg1.slice(1, -1).split(',').some(pattern => match(pattern, path));
}
var regExp = globToRegExp(arg1);
const regExp = globToRegExp(arg1);
return regExp && regExp.test(path);
}
......
......@@ -6,6 +6,7 @@
import {createDecorator, ServiceIdentifier} from 'vs/platform/instantiation/common/instantiation';
import {IEventEmitter} from 'vs/base/common/eventEmitter';
import Event from 'vs/base/common/event';
import {TPromise} from 'vs/base/common/winjs.base';
export const IConfigurationService = createDecorator<IConfigurationService>('configurationService');
......@@ -18,6 +19,12 @@ export interface IConfigurationService extends IEventEmitter {
*/
getConfiguration<T>(section?: string): T;
/**
* Similar to #getConfiguration() but ensures that the latest configuration
* from disk is fetched.
*/
loadConfiguration<T>(section?: string): TPromise<T>;
/**
* Returns iff the workspace has configuration or not.
*/
......
......@@ -90,7 +90,7 @@ export abstract class ConfigurationService extends EventEmitter implements IConf
}
public initialize(): TPromise<void> {
return this.loadConfiguration().then(() => null);
return this.doLoadConfiguration().then(() => null);
}
protected abstract resolveContents(resource: uri[]): TPromise<IContent[]>;
......@@ -117,15 +117,17 @@ export abstract class ConfigurationService extends EventEmitter implements IConf
return result;
}
private loadConfiguration(section?: string): TPromise<any> {
return this.doLoadConfiguration().then((res: ILoadConfigResult) => {
this.cachedConfig = res;
public loadConfiguration(section?: string): TPromise<any> {
return this.getConfiguration(section);
});
// Reset caches to ensure we are hitting the disk
this.bulkFetchFromWorkspacePromise = null;
this.workspaceFilePathToConfiguration = Object.create(null);
// Load configuration
return this.doLoadConfiguration(section);
}
private doLoadConfiguration(): TPromise<ILoadConfigResult> {
private doLoadConfiguration(section?: string): TPromise<any> {
// Load globals
const globals = this.loadGlobalConfiguration();
......@@ -148,6 +150,10 @@ export abstract class ConfigurationService extends EventEmitter implements IConf
consolidated: consolidated,
globals: globals
};
}).then((res: ILoadConfigResult) => {
this.cachedConfig = res;
return this.getConfiguration(section);
});
}
......@@ -192,7 +198,7 @@ export abstract class ConfigurationService extends EventEmitter implements IConf
protected handleConfigurationChange(): void {
if (!this.reloadConfigurationScheduler) {
this.reloadConfigurationScheduler = new RunOnceScheduler(() => {
this.loadConfiguration().then((config) => this.emit(ConfigurationServiceEventTypes.UPDATED, { config: config })).done(null, errors.onUnexpectedError);
this.doLoadConfiguration().then((config) => this.emit(ConfigurationServiceEventTypes.UPDATED, { config: config })).done(null, errors.onUnexpectedError);
}, ConfigurationService.RELOAD_CONFIGURATION_DELAY);
}
......
......@@ -23,6 +23,7 @@ import {ExtHostMessageService} from 'vs/workbench/api/node/extHostMessageService
import {ExtHostEditors} from 'vs/workbench/api/node/extHostEditors';
import {ExtHostLanguages} from 'vs/workbench/api/node/extHostLanguages';
import {ExtHostLanguageFeatures} from 'vs/workbench/api/node/extHostLanguageFeatures';
import * as ExtHostTypeConverters from 'vs/workbench/api/node/extHostTypeConverters';
import {registerApiCommands} from 'vs/workbench/api/node/extHostApiCommands';
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
import Modes = require('vs/editor/common/modes');
......@@ -148,6 +149,10 @@ export class ExtHostAPIImplementation {
const extHostStatusBar = new ExtHostStatusBar(this._threadService);
const extHostOutputService = new ExtHostOutputService(this._threadService);
// the converter might create delegate commands to avoid sending args
// around all the time
ExtHostTypeConverters.Command.initialize(extHostCommands);
// env namespace
let telemetryInfo: ITelemetryInfo;
this.env = Object.freeze({
......
......@@ -87,7 +87,7 @@ class CodeLensAdapter implements modes.ICodeLensSupport {
data.symbols.push(<modes.ICodeLensSymbol>{
id: String(i),
range: TypeConverters.fromRange(lens.range),
command: TypeConverters.Command.from(lens.command, { commands: this._commands, disposables: data.disposables })
command: TypeConverters.Command.from(lens.command, data.disposables)
});
});
......@@ -144,7 +144,7 @@ class CodeLensAdapter implements modes.ICodeLensSupport {
};
}
symbol.command = TypeConverters.Command.from(command, { commands: this._commands, disposables: cachedData.disposables });
symbol.command = TypeConverters.Command.from(command, cachedData.disposables);
return symbol;
});
});
......@@ -315,7 +315,6 @@ class QuickFixAdapter implements modes.IQuickFixSupport {
});
this._cachedCommands = dispose(this._cachedCommands);
const ctx = { commands: this._commands, disposables: this._cachedCommands };
return asWinJsPromise(token => this._provider.provideCodeActions(doc, ran, { diagnostics: allDiagnostics }, token)).then(commands => {
if (!Array.isArray(commands)) {
......@@ -323,7 +322,7 @@ class QuickFixAdapter implements modes.IQuickFixSupport {
}
return commands.map((command, i) => {
return <modes.IQuickFix> {
command: TypeConverters.Command.from(command, ctx),
command: TypeConverters.Command.from(command, this._cachedCommands),
score: i
};
});
......
......@@ -494,10 +494,23 @@ export namespace SignatureHelp {
export namespace Command {
const _delegateId = '_internal_delegate_command';
const _cache: { [id: string]: vscode.Command } = Object.create(null);
let _idPool = 1;
export function from(command: vscode.Command, context: { commands: ExtHostCommands; disposables: IDisposable[]; }): modes.ICommand {
export function initialize(commands: ExtHostCommands) {
return commands.registerCommand(_delegateId, (args: [string]) => {
const [id] = args;
const command = _cache[id];
if (!command) {
// handle already disposed delegations graceful
return;
}
return commands.executeCommand(command.command, ...command.arguments);
});
}
export function from(command: vscode.Command, disposables: IDisposable[]): modes.ICommand {
if (!command) {
return;
......@@ -510,22 +523,29 @@ export namespace Command {
if (!isFalsyOrEmpty(command.arguments)) {
// keep command around
const id = `${command.command}-no-args-wrapper-${_idPool++}`;
result.id = id;
// redirect to delegate command and store actual command
const id = `delegate/${_idPool++}/for/${command.command}`;
result.id = _delegateId;
result.arguments = [id];
_cache[id] = command;
const disposable1 = context.commands.registerCommand(id, () => context.commands.executeCommand(command.command, ..._cache[id].arguments));
const disposable2 = { dispose() { delete _cache[id]; } };
context.disposables.push(disposable1, disposable2);
disposables.push({
dispose() {
delete _cache[id];
}
});
}
return result;
}
export function to(command: modes.ICommand): vscode.Command {
let result = _cache[command.id];
let result: vscode.Command;
if (command.id === _delegateId) {
let [key] = command.arguments;
result = _cache[key];
}
if (!result) {
result = {
command: command.id,
......
......@@ -338,8 +338,12 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
for (let pattern of ReplExpressionsRenderer.FILE_LOCATION_PATTERNS) {
pattern.lastIndex = 0; // the holy grail of software development
var match = pattern.exec(text);
var resource = match && URI.file(match[1]);
const match = pattern.exec(text);
let resource = null;
try {
resource = match && URI.file(match[1]);
} catch (e) { }
if (resource) {
linkContainer = document.createElement('span');
......
......@@ -42,6 +42,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletSer
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { ITextFileService } from 'vs/workbench/parts/files/common/files';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWindowService, IBroadcast } from 'vs/workbench/services/window/electron-browser/windowService';
......@@ -89,7 +90,8 @@ export class DebugService implements debug.IDebugService {
@IInstantiationService private instantiationService:IInstantiationService,
@IExtensionService private extensionService: IExtensionService,
@IMarkerService private markerService: IMarkerService,
@ITaskService private taskService: ITaskService
@ITaskService private taskService: ITaskService,
@IConfigurationService private configurationService: IConfigurationService
) {
this.toDispose = [];
this.toDisposeOnSessionEnd = [];
......@@ -253,6 +255,7 @@ export class DebugService implements debug.IDebugService {
// focus first stack frame from top that has source location
const stackFrameToFocus = arrays.first(callStack, sf => sf.source && sf.source.available, callStack[0]);
this.setFocusedStackFrameAndEvaluate(stackFrameToFocus).done(null, errors.onUnexpectedError);
this.windowService.getWindow().focus();
aria.alert(nls.localize('debuggingPaused', "Debugging paused, reason {0}, {1} {2}", event.body.reason, stackFrameToFocus.source ? stackFrameToFocus.source.name : '', stackFrameToFocus.lineNumber));
return this.openOrRevealSource(stackFrameToFocus.source, stackFrameToFocus.lineNumber, false, false);
......@@ -280,7 +283,7 @@ export class DebugService implements debug.IDebugService {
this.toDisposeOnSessionEnd.push(this.session.onDidTerminateDebugee(event => {
aria.status(nls.localize('debuggingStopped', "Debugging stopped."));
if (this.session && this.session.getId() === (<any>event).sessionId) {
if (this.session && this.session.getId() === event.body.sessionId) {
if (event.body && typeof event.body.restart === 'boolean' && event.body.restart) {
this.restartSession().done(null, err => this.messageService.show(severity.Error, err.message));
} else {
......@@ -318,7 +321,7 @@ export class DebugService implements debug.IDebugService {
if (this.session.configuration.type === 'extensionHost' && this._state === debug.State.RunningNoDebug) {
ipc.send('vscode:closeExtensionHostWindow', this.contextService.getWorkspace().resource.fsPath);
}
if (this.session && this.session.getId() === (<any>event.body).sessionId) {
if (this.session && this.session.getId() === event.body.sessionId) {
this.onSessionEnd();
}
}));
......@@ -398,7 +401,6 @@ export class DebugService implements debug.IDebugService {
public setFocusedStackFrameAndEvaluate(focusedStackFrame: debug.IStackFrame): TPromise<void> {
this.viewModel.setFocusedStackFrame(focusedStackFrame);
this.windowService.getWindow().focus();
if (focusedStackFrame) {
return this.model.evaluateWatchExpressions(this.session, focusedStackFrame);
} else {
......@@ -489,7 +491,8 @@ export class DebugService implements debug.IDebugService {
public createSession(noDebug: boolean, changeViewState = !this.partService.isSideBarHidden()): TPromise<any> {
this.removeReplExpressions();
return this.textFileService.saveAll()
return this.textFileService.saveAll() // make sure all dirty files are saved
.then(() => this.configurationService.loadConfiguration() // make sure configuration is up to date
.then(() => this.extensionService.onReady()
.then(() => this.configurationManager.setConfiguration((this.configurationManager.configurationName))
.then(() => {
......@@ -535,7 +538,7 @@ export class DebugService implements debug.IDebugService {
actions: [CloseAction, this.taskService.configureAction()]
});
});
})));
}))));
}
private doCreateSession(configuration: debug.IConfig, changeViewState: boolean): TPromise<any> {
......
......@@ -22,6 +22,20 @@ import { IMessageService, CloseAction } from 'vs/platform/message/common/message
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { shell } from 'electron';
export interface SessionExitedEvent extends DebugProtocol.ExitedEvent {
body: {
exitCode: number,
sessionId: string
};
}
export interface SessionTerminatedEvent extends DebugProtocol.TerminatedEvent {
body: {
restart?: boolean,
sessionId: string
};
}
export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSession {
public restarted: boolean;
......@@ -40,8 +54,8 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
private _onDidInitialize: Emitter<DebugProtocol.InitializedEvent>;
private _onDidStop: Emitter<DebugProtocol.StoppedEvent>;
private _onDidTerminateDebugee: Emitter<DebugProtocol.TerminatedEvent>;
private _onDidExitAdapter: Emitter<DebugProtocol.ExitedEvent>;
private _onDidTerminateDebugee: Emitter<SessionTerminatedEvent>;
private _onDidExitAdapter: Emitter<SessionExitedEvent>;
private _onDidContinue: Emitter<void>;
private _onDidThread: Emitter<DebugProtocol.ThreadEvent>;
private _onDidOutput: Emitter<DebugProtocol.OutputEvent>;
......@@ -63,8 +77,8 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this._onDidInitialize = new Emitter<DebugProtocol.InitializedEvent>();
this._onDidStop = new Emitter<DebugProtocol.StoppedEvent>();
this._onDidTerminateDebugee = new Emitter<DebugProtocol.TerminatedEvent>();
this._onDidExitAdapter = new Emitter<DebugProtocol.ExitedEvent>();
this._onDidTerminateDebugee = new Emitter<SessionTerminatedEvent>();
this._onDidExitAdapter = new Emitter<SessionExitedEvent>();
this._onDidContinue = new Emitter<void>();
this._onDidThread = new Emitter<DebugProtocol.ThreadEvent>();
this._onDidOutput = new Emitter<DebugProtocol.OutputEvent>();
......@@ -80,11 +94,11 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
return this._onDidStop.event;
}
public get onDidTerminateDebugee(): Event<DebugProtocol.TerminatedEvent> {
public get onDidTerminateDebugee(): Event<SessionTerminatedEvent> {
return this._onDidTerminateDebugee.event;
}
public get onDidExitAdapter(): Event<DebugProtocol.ExitedEvent> {
public get onDidExitAdapter(): Event<SessionExitedEvent> {
return this._onDidExitAdapter.event;
}
......@@ -177,10 +191,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this._onDidBreakpoint.fire(<DebugProtocol.BreakpointEvent>event);
} else if (event.event === 'terminated') {
this.flowEventsCount++;
this._onDidTerminateDebugee.fire(event);
this._onDidTerminateDebugee.fire(<SessionTerminatedEvent>event);
} else if (event.event === 'exit') {
this.flowEventsCount++;
this._onDidExitAdapter.fire(<DebugProtocol.ExitedEvent>event);
this._onDidExitAdapter.fire(<SessionExitedEvent>event);
} else if (event.event === 'continued') {
this.flowEventsCount++;
this._onDidContinue.fire();
......
......@@ -10,7 +10,7 @@ import {Action, IAction} from 'vs/base/common/actions';
import {ActionItem, BaseActionItem, Separator} from 'vs/base/browser/ui/actionbar/actionbar';
import {Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarContributor} from 'vs/workbench/browser/actionBarRegistry';
import {IEditorInputActionContext, IEditorInputAction, EditorInputActionContributor} from 'vs/workbench/browser/parts/editor/baseEditor';
import {AddToWorkingFiles, FocusWorkingFiles, FocusFilesExplorer, OpenPreviousWorkingFile, OpenNextWorkingFile, CloseAllFilesAction, CloseFileAction, CloseOtherFilesAction, GlobalCompareResourcesAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, keybindingForAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, OpenToSideAction, ShowActiveFileInExplorer} from 'vs/workbench/parts/files/browser/fileActions';
import {AddToWorkingFiles, FocusWorkingFiles, FocusFilesExplorer, OpenPreviousWorkingFile, OpenNextWorkingFile, CloseAllFilesAction, CloseFileAction, CloseOtherFilesAction, GlobalCompareResourcesAction, GlobalNewFileAction, GlobalNewFolderAction, RevertFileAction, SaveFilesAction, SaveAllAction, SaveFileAction, keybindingForAction, MoveFileToTrashAction, TriggerRenameFileAction, PasteFileAction, CopyFileAction, SelectResourceForCompareAction, CompareResourcesAction, NewFolderAction, NewFileAction, OpenToSideAction, ShowActiveFileInExplorer} from 'vs/workbench/parts/files/browser/fileActions';
import {RevertLocalChangesAction, AcceptLocalChangesAction, ConflictResolutionDiffEditorInput} from 'vs/workbench/parts/files/browser/saveErrorHandler';
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry';
......@@ -166,6 +166,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFileAction, SaveFi
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveAllAction, SaveAllAction.ID, SaveAllAction.LABEL), category, ['save', 'all', 'files']);
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveFilesAction, SaveFilesAction.ID, null /* only for programmatic trigger */));
registry.registerWorkbenchAction(new SyncActionDescriptor(RevertFileAction, RevertFileAction.ID, RevertFileAction.LABEL), category, ['revert', 'file']);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFileAction, GlobalNewFileAction.ID, GlobalNewFileAction.LABEL), category, ['new', 'file']);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFolderAction, GlobalNewFolderAction.ID, GlobalNewFolderAction.LABEL), category, ['new', 'folder']);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalCompareResourcesAction, GlobalCompareResourcesAction.ID, GlobalCompareResourcesAction.LABEL), category, ['compare', 'files']);
registry.registerWorkbenchAction(new SyncActionDescriptor(CloseFileAction, CloseFileAction.ID, CloseFileAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_W) }), category, ['close', 'file']);
......
......@@ -523,7 +523,8 @@ export abstract class BaseGlobalNewAction extends Action {
id: string,
label: string,
@IViewletService private viewletService: IViewletService,
@IInstantiationService private instantiationService: IInstantiationService
@IInstantiationService private instantiationService: IInstantiationService,
@IMessageService private messageService: IMessageService
) {
super(id, label);
}
......@@ -536,6 +537,11 @@ export abstract class BaseGlobalNewAction extends Action {
let explorer = <ExplorerViewlet>viewlet;
let explorerView = explorer.getExplorerView();
// Not having a folder opened
if (!explorerView) {
return this.messageService.show(Severity.Info, nls.localize('openFolderFirst', "Open a folder first to create files or folders within."));
}
if (!explorerView.isExpanded()) {
explorerView.expand();
}
......@@ -560,9 +566,9 @@ export abstract class BaseGlobalNewAction extends Action {
}
/* Create new file from anywhere: Open untitled */
export class GlobalNewFileAction extends Action {
export class GlobalNewUntitledFileAction extends Action {
public static ID = 'workbench.action.files.newUntitledFile';
public static LABEL = nls.localize('newFile', "New File");
public static LABEL = nls.localize('newUntitledFile', "New Untitled File");
constructor(
id: string,
......@@ -585,6 +591,16 @@ export class GlobalNewFileAction extends Action {
}
}
/* Create new file from anywhere */
export class GlobalNewFileAction extends BaseGlobalNewAction {
public static ID = 'workbench.action.files.newFile';
public static LABEL = nls.localize('newFile', "New File");
protected getAction(): IConstructorSignature2<ITree, IFileStat, Action> {
return NewFileAction;
}
}
/* Create new folder from anywhere */
export class GlobalNewFolderAction extends BaseGlobalNewAction {
public static ID = 'workbench.action.files.newFolder';
......@@ -2337,7 +2353,7 @@ export class ShowActiveFileInExplorer extends Action {
export function keybindingForAction(id: string): Keybinding {
switch (id) {
case GlobalNewFileAction.ID:
case GlobalNewUntitledFileAction.ID:
return new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_N);
case TriggerRenameFileAction.ID:
return new Keybinding(isMacintosh ? KeyCode.Enter : KeyCode.F2);
......
......@@ -14,7 +14,7 @@ import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import env = require('vs/base/common/platform');
import {ITextFileService, asFileResource} from 'vs/workbench/parts/files/common/files';
import {IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions} from 'vs/workbench/common/contributions';
import {GlobalNewFileAction, SaveFileAsAction} from 'vs/workbench/parts/files/browser/fileActions';
import {GlobalNewUntitledFileAction, SaveFileAsAction} from 'vs/workbench/parts/files/browser/fileActions';
import {FileTracker} from 'vs/workbench/parts/files/electron-browser/electronFileTracker';
import {TextFileService} from 'vs/workbench/parts/files/electron-browser/textFileServices';
import {OpenFolderAction, OPEN_FOLDER_ID, OPEN_FOLDER_LABEL, OpenFileAction, OPEN_FILE_ID, OPEN_FILE_LABEL, OpenFileFolderAction, OPEN_FILE_FOLDER_ID, OPEN_FILE_FOLDER_LABEL, ShowOpenedFileInNewWindow, GlobalRevealInOSAction, GlobalCopyPathAction, CopyPathAction, RevealInOSAction} from 'vs/workbench/parts/files/electron-browser/electronFileActions';
......@@ -57,7 +57,7 @@ const category = nls.localize('filesCategory', "Files");
let workbenchActionsRegistry = <IWorkbenchActionRegistry>Registry.as(ActionExtensions.WorkbenchActions);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(SaveFileAsAction, SaveFileAsAction.ID, SaveFileAsAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S }), category, ['save', 'as']);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewFileAction, GlobalNewFileAction.ID, GlobalNewFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_N }), category, ['new', 'file']);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewUntitledFileAction, GlobalNewUntitledFileAction.ID, GlobalNewUntitledFileAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_N }), category, ['new', 'untitled', 'file']);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(GlobalCopyPathAction, GlobalCopyPathAction.ID, GlobalCopyPathAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_P) }), category, ['copy', 'path']);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(GlobalRevealInOSAction, GlobalRevealInOSAction.ID, GlobalRevealInOSAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_R) }), category, ['reveal', 'file']);
......
......@@ -753,44 +753,46 @@ class TaskService extends EventEmitter implements ITaskService {
}
private executeTarget(fn: (taskSystem: ITaskSystem) => ITaskRunResult): TPromise<ITaskSummary> {
return this.textFileService.saveAll().then((value) => {
return this.taskSystemPromise.
then((taskSystem) => {
return taskSystem.isActive().then((active) => {
if (!active) {
return fn(taskSystem);
} else {
throw new TaskError(Severity.Warning, nls.localize('TaskSystem.active', 'There is an active running task right now. Terminate it first before executing another task.'), TaskErrors.RunningTask);
}
});
}).
then((runResult: ITaskRunResult) => {
if (runResult.restartOnFileChanges) {
let pattern = runResult.restartOnFileChanges;
this.fileChangesListener = this.eventService.addListener(FileEventType.FILE_CHANGES, (event: FileChangesEvent) => {
let needsRestart = event.changes.some((change) => {
return (change.type === FileChangeType.ADDED || change.type === FileChangeType.DELETED) && !!match(pattern, change.resource.fsPath);
});
if (needsRestart) {
this.terminate().done(() => {
// We need to give the child process a change to stop.
setTimeout(() => {
this.executeTarget(fn);
}, 2000);
});
return this.textFileService.saveAll().then((value) => { // make sure all dirty files are saved
return this.configurationService.loadConfiguration().then(() => { // make sure configuration is up to date
return this.taskSystemPromise.
then((taskSystem) => {
return taskSystem.isActive().then((active) => {
if (!active) {
return fn(taskSystem);
} else {
throw new TaskError(Severity.Warning, nls.localize('TaskSystem.active', 'There is an active running task right now. Terminate it first before executing another task.'), TaskErrors.RunningTask);
}
});
}
return runResult.promise.then((value) => {
if (this.clearTaskSystemPromise) {
this._taskSystemPromise = null;
this.clearTaskSystemPromise = false;
}).
then((runResult: ITaskRunResult) => {
if (runResult.restartOnFileChanges) {
let pattern = runResult.restartOnFileChanges;
this.fileChangesListener = this.eventService.addListener(FileEventType.FILE_CHANGES, (event: FileChangesEvent) => {
let needsRestart = event.changes.some((change) => {
return (change.type === FileChangeType.ADDED || change.type === FileChangeType.DELETED) && !!match(pattern, change.resource.fsPath);
});
if (needsRestart) {
this.terminate().done(() => {
// We need to give the child process a change to stop.
setTimeout(() => {
this.executeTarget(fn);
}, 2000);
});
}
});
}
return value;
return runResult.promise.then((value) => {
if (this.clearTaskSystemPromise) {
this._taskSystemPromise = null;
this.clearTaskSystemPromise = false;
}
return value;
});
}, (err: any) => {
this.handleError(err);
});
}, (err: any) => {
this.handleError(err);
});
});
});
}
......
......@@ -453,6 +453,10 @@ export const TestFileService = {
export class TestConfigurationService extends EventEmitter.EventEmitter implements IConfigurationService {
public serviceId = IConfigurationService;
public loadConfiguration<T>(section?: string): TPromise<T> {
return TPromise.as(this.getConfiguration());
}
public getConfiguration(): any {
return {};
}
......
......@@ -25,6 +25,7 @@ import {ExtHostLanguageFeatures, MainThreadLanguageFeatures} from 'vs/workbench/
import {registerApiCommands} from 'vs/workbench/api/node/extHostApiCommands';
import {ExtHostCommands, MainThreadCommands} from 'vs/workbench/api/node/extHostCommands';
import {ExtHostModelService} from 'vs/workbench/api/node/extHostDocuments';
import * as ExtHostTypeConverters from 'vs/workbench/api/node/extHostTypeConverters';
const defaultSelector = { scheme: 'far' };
const model: EditorCommon.IModel = new EditorModel(
......@@ -95,6 +96,8 @@ suite('ExtHostLanguageFeatureCommands', function() {
threadService.getRemotable(MainThreadCommands);
commands = threadService.getRemotable(ExtHostCommands);
ExtHostTypeConverters.Command.initialize(commands);
registerApiCommands(threadService);
mainThread = threadService.getRemotable(MainThreadLanguageFeatures);
extHost = threadService.getRemotable(ExtHostLanguageFeatures);
......@@ -314,28 +317,27 @@ suite('ExtHostLanguageFeatureCommands', function() {
// --- quickfix
test('QuickFix, back and forth', function(done) {
test('QuickFix, back and forth', function() {
disposables.push(extHost.registerCodeActionProvider(defaultSelector, <vscode.CodeActionProvider>{
provideCodeActions(): any {
return [{ command: 'testing', title: 'Title', arguments: [1, 2, true] }];
}
}));
threadService.sync().then(() => {
commands.executeCommand<vscode.Command[]>('vscode.executeCodeActionProvider', model.getAssociatedResource(), new types.Range(0, 0, 1, 1)).then(value => {
return threadService.sync().then(() => {
return commands.executeCommand<vscode.Command[]>('vscode.executeCodeActionProvider', model.getAssociatedResource(), new types.Range(0, 0, 1, 1)).then(value => {
assert.equal(value.length, 1);
let [first] = value;
assert.equal(first.title, 'Title');
assert.equal(first.command, 'testing');
assert.deepEqual(first.arguments, [1, 2, true]);
done();
}, done);
});
});
});
// --- code lens
test('CodeLens, back and forth', function(done) {
test('CodeLens, back and forth', function() {
const complexArg = {
foo() { },
......@@ -349,8 +351,8 @@ suite('ExtHostLanguageFeatureCommands', function() {
}
}));
threadService.sync().then(() => {
commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.getAssociatedResource()).then(value => {
return threadService.sync().then(() => {
return commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.getAssociatedResource()).then(value => {
assert.equal(value.length, 1);
let [first] = value;
......@@ -359,8 +361,7 @@ suite('ExtHostLanguageFeatureCommands', function() {
assert.equal(first.command.arguments[0], 1);
assert.equal(first.command.arguments[1], true);
assert.equal(first.command.arguments[2], complexArg);
done();
}, done);
});
});
});
});
......@@ -638,7 +638,7 @@ suite('ExtHostLanguageFeatures', function() {
});
});
test('Quick Fix, invoke command+args', function(done) {
test('Quick Fix, invoke command+args', function() {
let actualArgs: any;
let commands = threadService.getRemotable(ExtHostCommands);
disposables.push(commands.registerCommand('test1', function(...args: any[]) {
......@@ -651,8 +651,8 @@ suite('ExtHostLanguageFeatures', function() {
}
}));
threadService.sync().then(() => {
getQuickFixes(model, model.getFullModelRange()).then(value => {
return threadService.sync().then(() => {
return getQuickFixes(model, model.getFullModelRange()).then(value => {
assert.equal(value.length, 1);
let [entry] = value;
......@@ -664,7 +664,6 @@ suite('ExtHostLanguageFeatures', function() {
assert.equal(actualArgs[1], 1);
assert.deepEqual(actualArgs[2], { bar: 'boo', foo: 'far' });
assert.equal(actualArgs[3], null);
done();
});
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册