提交 1ddb5cc1 编写于 作者: J Joao Moreno

Merge remote-tracking branch 'origin/master'

......@@ -4,13 +4,15 @@
*--------------------------------------------------------------------------------------------*/
const cp = require('child_process');
const path = require('path');
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
function npmInstall(location) {
const result = cp.spawnSync(npm, ['install'], {
cwd: location ,
stdio: 'inherit'
});
function npmInstall(location, opts) {
opts = opts || {};
opts.cwd = location;
opts.stdio = 'inherit';
const result = cp.spawnSync(npm, ['install'], opts);
if (result.error || result.status !== 0) {
process.exit(1);
......@@ -43,4 +45,17 @@ const extensions = [
extensions.forEach(extension => npmInstall(`extensions/${extension}`));
function npmInstallBuildDependencies() {
// make sure we install gulp watch for the system installed
// node, since that is the driver of gulp
const env = Object.assign({}, process.env);
delete env['npm_config_disturl'];
delete env['npm_config_target'];
delete env['npm_config_runtime'];
npmInstall(path.join(path.dirname(__dirname), 'lib', 'watch'), { env });
}
npmInstall(`build`); // node modules required for build
npmInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron
\ No newline at end of file
......@@ -3,9 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const cp = require('child_process');
if (process.env['npm_config_disturl'] !== 'https://atom.io/download/electron') {
console.error("You can't use plain npm to install Code's dependencies.");
console.error(
......@@ -16,17 +13,3 @@ if (process.env['npm_config_disturl'] !== 'https://atom.io/download/electron') {
process.exit(1);
}
\ No newline at end of file
// make sure we install gulp watch for the system installed
// node, since that is the driver of gulp
const env = Object.assign({}, process.env);
delete env['npm_config_disturl'];
delete env['npm_config_target'];
delete env['npm_config_runtime'];
cp.spawnSync('npm', ['install'], {
cwd: path.join(path.dirname(__dirname), 'lib', 'watch'),
stdio: 'inherit',
env
});
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export const data: string[];
\ No newline at end of file
......@@ -6,8 +6,8 @@
// import * as assert from 'assert';
import * as filters from 'vs/base/common/filters';
import { data } from './filters.perf.data';
const data = <string[]>require.__$__nodeRequire(require.toUrl('./filters.perf.data.json'));
const patterns = ['cci', 'ida', 'pos', 'CCI', 'enbled', 'callback', 'gGame', 'cons'];
const _enablePerf = false;
......
......@@ -37,6 +37,7 @@ import { Color } from 'vs/base/common/color';
import { OverviewRulerZone } from 'vs/editor/common/view/overviewZoneManager';
import { IEditorWhitespace } from 'vs/editor/common/viewLayout/whitespaceComputer';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
import { DiffReview } from "vs/editor/browser/widget/diffReview";
interface IEditorDiffDecorations {
decorations: editorCommon.IModelDeltaDecoration[];
......@@ -150,6 +151,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
private _width: number;
private _height: number;
private _reviewHeight: number;
private readonly _measureDomElementToken: number;
private originalEditor: CodeEditor;
......@@ -185,6 +187,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
private _codeEditorService: ICodeEditorService;
private _themeService: IThemeService;
private _reviewPane: DiffReview;
constructor(
domElement: HTMLElement,
options: editorOptions.IDiffEditorOptions,
......@@ -245,7 +249,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._overviewDomElement = document.createElement('div');
this._overviewDomElement.className = 'diffOverview';
this._overviewDomElement.style.position = 'absolute';
this._overviewDomElement.style.height = '100%';
this._overviewDomElement.appendChild(this._overviewViewportDomElement.domNode);
......@@ -257,6 +260,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._createLeftHandSide();
this._createRightHandSide();
this._reviewPane = new DiffReview(this);
this._containerDomElement.appendChild(this._reviewPane.domNode.domNode);
this._containerDomElement.appendChild(this._reviewPane.shadow.domNode);
this._beginUpdateDecorationsTimeout = -1;
this._currentlyChangingViewZones = false;
this._diffComputationToken = 0;
......@@ -269,6 +276,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._width = 0;
this._height = 0;
this._reviewHeight = 0;
this._lineChanges = null;
......@@ -750,6 +758,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
if (dimensions.width <= 0) {
this._width = 0;
this._height = 0;
this._reviewHeight = 0;
return;
}
......@@ -760,6 +769,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._width = dimensions.width;
this._height = dimensions.height;
this._reviewHeight = this._reviewPane.isVisible() ? Math.floor(0.5 * this._height) : 0;
this._doLayout();
}
......@@ -772,13 +782,13 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
top: 0,
width: DiffEditorWidget.ONE_OVERVIEW_WIDTH,
right: freeSpace + DiffEditorWidget.ONE_OVERVIEW_WIDTH,
height: this._height
height: (this._height - this._reviewHeight)
});
this._modifiedOverviewRuler.setLayout({
top: 0,
right: 0,
width: DiffEditorWidget.ONE_OVERVIEW_WIDTH,
height: this._height
height: (this._height - this._reviewHeight)
});
}
}
......@@ -905,18 +915,21 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._modifiedDomNode.style.left = splitPoint + 'px';
this._overviewDomElement.style.top = '0px';
this._overviewDomElement.style.height = (this._height - this._reviewHeight) + 'px';
this._overviewDomElement.style.width = DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH + 'px';
this._overviewDomElement.style.left = (this._width - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH) + 'px';
this._overviewViewportDomElement.setWidth(DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH);
this._overviewViewportDomElement.setHeight(30);
this.originalEditor.layout({ width: splitPoint, height: this._height });
this.modifiedEditor.layout({ width: this._width - splitPoint - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH, height: this._height });
this.originalEditor.layout({ width: splitPoint, height: (this._height - this._reviewHeight) });
this.modifiedEditor.layout({ width: this._width - splitPoint - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH, height: (this._height - this._reviewHeight) });
if (this._originalOverviewRuler || this._modifiedOverviewRuler) {
this._layoutOverviewRulers();
}
this._reviewPane.layout(this._height - this._reviewHeight, this._width, this._reviewHeight);
this._layoutOverviewViewport();
}
......@@ -960,7 +973,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
},
getHeight: () => {
return this._height;
return (this._height - this._reviewHeight);
},
getContainerDomNode: () => {
......@@ -1973,11 +1986,13 @@ registerThemingParticipant((theme, collector) => {
let added = theme.getColor(diffInserted);
if (added) {
collector.addRule(`.monaco-editor .line-insert, .monaco-editor .char-insert { background-color: ${added}; }`);
collector.addRule(`.monaco-diff-editor .line-insert, .monaco-diff-editor .char-insert { background-color: ${added}; }`);
collector.addRule(`.monaco-editor .inline-added-margin-view-zone { background-color: ${added}; }`);
}
let removed = theme.getColor(diffRemoved);
if (removed) {
collector.addRule(`.monaco-editor .line-delete, .monaco-editor .char-delete { background-color: ${removed}; }`);
collector.addRule(`.monaco-diff-editor .line-delete, .monaco-diff-editor .char-delete { background-color: ${removed}; }`);
collector.addRule(`.monaco-editor .inline-deleted-margin-view-zone { background-color: ${removed}; }`);
}
let addedOutline = theme.getColor(diffInsertedOutline);
......
/*---------------------------------------------------------------------------------------------
* 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 'vs/css!./media/diffReview';
import { Disposable } from 'vs/base/common/lifecycle';
import * as dom from 'vs/base/browser/dom';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
import { Configuration } from 'vs/editor/browser/config/configuration';
import { Position } from 'vs/editor/common/core/position';
import { ColorId, MetadataConsts, FontStyle } from 'vs/editor/common/modes';
import * as editorOptions from 'vs/editor/common/config/editorOptions';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
import { DiffEditorWidget } from "vs/editor/browser/widget/diffEditorWidget";
import { DomScrollableElement } from "vs/base/browser/ui/scrollbar/scrollableElement";
import { editorLineNumbers } from "vs/editor/common/view/editorColorRegistry";
const DIFF_LINES_PADDING = 3;
const enum DiffEntryType {
Equal = 0,
Insert = 1,
Delete = 2
}
class DiffEntry {
readonly originalLineStart: number;
readonly originalLineEnd: number;
readonly modifiedLineStart: number;
readonly modifiedLineEnd: number;
constructor(originalLineStart: number, originalLineEnd: number, modifiedLineStart: number, modifiedLineEnd: number) {
this.originalLineStart = originalLineStart;
this.originalLineEnd = originalLineEnd;
this.modifiedLineStart = modifiedLineStart;
this.modifiedLineEnd = modifiedLineEnd;
}
public getType(): DiffEntryType {
if (this.originalLineStart === 0) {
return DiffEntryType.Insert;
}
if (this.modifiedLineStart === 0) {
return DiffEntryType.Delete;
}
return DiffEntryType.Equal;
}
}
class Diff {
readonly entries: DiffEntry[];
constructor(entries: DiffEntry[]) {
this.entries = entries;
}
}
export class DiffReview extends Disposable {
private readonly _diffEditor: DiffEditorWidget;
private readonly _isVisible: boolean;
public readonly shadow: FastDomNode<HTMLElement>;
public readonly domNode: FastDomNode<HTMLElement>;
private readonly _content: FastDomNode<HTMLElement>;
private readonly scrollbar: DomScrollableElement;
private _diffs: Diff[];
constructor(diffEditor: DiffEditorWidget) {
super();
this._diffEditor = diffEditor;
this._isVisible = false;
this.shadow = createFastDomNode(document.createElement('div'));
this.shadow.setClassName('diff-review-shadow');
this.domNode = createFastDomNode(document.createElement('div'));
this.domNode.setClassName('diff-review monaco-editor-background');
this._content = createFastDomNode(document.createElement('div'));
this.scrollbar = this._register(new DomScrollableElement(this._content.domNode, {}));
this.domNode.domNode.appendChild(this.scrollbar.getDomNode());
diffEditor.onDidUpdateDiff(() => {
if (!this._isVisible) {
return;
}
this._diffs = this._compute();
this._render();
});
this._diffs = [];
}
public isVisible(): boolean {
return this._isVisible;
}
public layout(top: number, width: number, height: number): void {
this.shadow.setTop(top - 6);
this.shadow.setWidth(width);
this.shadow.setHeight(this._isVisible ? 6 : 0);
this.domNode.setTop(top);
this.domNode.setWidth(width);
this.domNode.setHeight(height);
this._content.setHeight(height);
this._content.setWidth(width);
}
private _compute(): Diff[] {
const lineChanges = this._diffEditor.getLineChanges();
if (!lineChanges || lineChanges.length === 0) {
return [];
}
const originalModel = this._diffEditor.getOriginalEditor().getModel();
const modifiedModel = this._diffEditor.getModifiedEditor().getModel();
if (!originalModel || !modifiedModel) {
return [];
}
return DiffReview._mergeAdjacent(lineChanges, originalModel.getLineCount(), modifiedModel.getLineCount());
}
private static _mergeAdjacent(lineChanges: editorCommon.ILineChange[], originalLineCount: number, modifiedLineCount: number): Diff[] {
if (!lineChanges || lineChanges.length === 0) {
return [];
}
let diffs: Diff[] = [], diffsLength = 0;
for (let i = 0, len = lineChanges.length; i < len; i++) {
const lineChange = lineChanges[i];
const originalStart = lineChange.originalStartLineNumber;
const originalEnd = lineChange.originalEndLineNumber;
const modifiedStart = lineChange.modifiedStartLineNumber;
const modifiedEnd = lineChange.modifiedEndLineNumber;
let r: DiffEntry[] = [], rLength = 0;
// Emit before anchors
{
const originalEqualAbove = (originalEnd === 0 ? originalStart : originalStart - 1);
const modifiedEqualAbove = (modifiedEnd === 0 ? modifiedStart : modifiedStart - 1);
// Make sure we don't step into the previous diff
let minOriginal = 1;
let minModified = 1;
if (i > 0) {
const prevLineChange = lineChanges[i - 1];
if (prevLineChange.originalEndLineNumber === 0) {
minOriginal = prevLineChange.originalStartLineNumber + 1;
} else {
minOriginal = prevLineChange.originalEndLineNumber + 1;
}
if (prevLineChange.modifiedEndLineNumber === 0) {
minModified = prevLineChange.modifiedStartLineNumber + 1;
} else {
minModified = prevLineChange.modifiedEndLineNumber + 1;
}
}
let fromOriginal = originalEqualAbove - DIFF_LINES_PADDING + 1;
let fromModified = modifiedEqualAbove - DIFF_LINES_PADDING + 1;
if (fromOriginal < minOriginal) {
const delta = minOriginal - fromOriginal;
fromOriginal = fromOriginal + delta;
fromModified = fromModified + delta;
}
if (fromModified < minModified) {
const delta = minModified - fromModified;
fromOriginal = fromOriginal + delta;
fromModified = fromModified + delta;
}
r[rLength++] = new DiffEntry(
fromOriginal, originalEqualAbove,
fromModified, modifiedEqualAbove
);
}
// Emit deleted lines
{
if (originalEnd !== 0) {
r[rLength++] = new DiffEntry(originalStart, originalEnd, 0, 0);
}
}
// Emit inserted lines
{
if (modifiedEnd !== 0) {
r[rLength++] = new DiffEntry(0, 0, modifiedStart, modifiedEnd);
}
}
// Emit after anchors
{
const originalEqualBelow = (originalEnd === 0 ? originalStart + 1 : originalEnd + 1);
const modifiedEqualBelow = (modifiedEnd === 0 ? modifiedStart + 1 : modifiedEnd + 1);
// Make sure we don't step into the next diff
let maxOriginal = originalLineCount;
let maxModified = modifiedLineCount;
if (i + 1 < len) {
const nextLineChange = lineChanges[i + 1];
if (nextLineChange.originalEndLineNumber === 0) {
maxOriginal = nextLineChange.originalStartLineNumber;
} else {
maxOriginal = nextLineChange.originalStartLineNumber - 1;
}
if (nextLineChange.modifiedEndLineNumber === 0) {
maxModified = nextLineChange.modifiedStartLineNumber;
} else {
maxModified = nextLineChange.modifiedStartLineNumber - 1;
}
}
let toOriginal = originalEqualBelow + DIFF_LINES_PADDING - 1;
let toModified = modifiedEqualBelow + DIFF_LINES_PADDING - 1;
if (toOriginal > maxOriginal) {
const delta = maxOriginal - toOriginal;
toOriginal = toOriginal + delta;
toModified = toModified + delta;
}
if (toModified > maxModified) {
const delta = maxModified - toModified;
toOriginal = toOriginal + delta;
toModified = toModified + delta;
}
r[rLength++] = new DiffEntry(
originalEqualBelow, toOriginal,
modifiedEqualBelow, toModified,
);
}
diffs[diffsLength++] = new Diff(r);
}
// Merge adjacent diffs
let curr: DiffEntry[] = diffs[0].entries;
let r: Diff[] = [], rLength = 0;
for (let i = 1, len = diffs.length; i < len; i++) {
const thisDiff = diffs[i].entries;
const currLast = curr[curr.length - 1];
const thisFirst = thisDiff[0];
if (
currLast.getType() === DiffEntryType.Equal
&& thisFirst.getType() === DiffEntryType.Equal
&& thisFirst.originalLineStart <= currLast.originalLineEnd
) {
// We are dealing with equal lines that overlap
curr[curr.length - 1] = new DiffEntry(
currLast.originalLineStart, thisFirst.originalLineEnd,
currLast.modifiedLineStart, thisFirst.modifiedLineEnd
);
curr = curr.concat(thisDiff.slice(1));
continue;
}
r[rLength++] = new Diff(curr);
curr = thisDiff;
}
r[rLength++] = new Diff(curr);
return r;
}
private _render(): void {
const pos = this._diffEditor.getPosition();
if (!pos) {
return;
}
this._doRender2(this._findDiffIndex(pos));
return;
}
private _findDiffIndex(pos: Position): number {
const lineNumber = pos.lineNumber;
for (let i = 0, len = this._diffs.length; i < len; i++) {
const diff = this._diffs[i].entries;
const lastModifiedLine = diff[diff.length - 1].modifiedLineEnd;
if (lineNumber <= lastModifiedLine) {
return i;
}
}
return 0;
}
private _doRender2(index: number): void {
const lines = this._diffs[index].entries;
const originalModel = this._diffEditor.getOriginalEditor().getModel();
const modifiedModel = this._diffEditor.getModifiedEditor().getModel();
this._doRender3(lines, originalModel, modifiedModel);
}
private _doRender3(diffs: DiffEntry[], originalModel: editorCommon.IModel, modifiedModel: editorCommon.IModel): void {
const originalOpts = this._diffEditor.getOriginalEditor().getConfiguration();
const modifiedOpts = this._diffEditor.getModifiedEditor().getConfiguration();
const originalModelOpts = originalModel.getOptions();
const modifiedModelOpts = modifiedModel.getOptions();
let table = document.createElement('table');
Configuration.applyFontInfoSlow(table, modifiedOpts.fontInfo);
let tbody = document.createElement('tbody');
table.appendChild(tbody);
let minOriginalLine = 0;
let maxOriginalLine = 0;
let minModifiedLine = 0;
let maxModifiedLine = 0;
for (let i = 0, len = diffs.length; i < len; i++) {
const diffEntry = diffs[i];
const originalLineStart = diffEntry.originalLineStart;
const originalLineEnd = diffEntry.originalLineEnd;
const modifiedLineStart = diffEntry.modifiedLineStart;
const modifiedLineEnd = diffEntry.modifiedLineEnd;
if (originalLineStart !== 0 && ((minOriginalLine === 0 || originalLineStart < minOriginalLine))) {
minOriginalLine = originalLineStart;
}
if (originalLineEnd !== 0 && ((maxOriginalLine === 0 || originalLineEnd > maxOriginalLine))) {
maxOriginalLine = originalLineEnd;
}
if (modifiedLineStart !== 0 && ((minModifiedLine === 0 || modifiedLineStart < minModifiedLine))) {
minModifiedLine = modifiedLineStart;
}
if (modifiedLineEnd !== 0 && ((maxModifiedLine === 0 || modifiedLineEnd > maxModifiedLine))) {
maxModifiedLine = modifiedLineEnd;
}
}
let headRow = document.createElement('tr');
let header = document.createElement('th');
header.colSpan = 3;
// @@ -504,7 +517,7 @@
header.appendChild(document.createTextNode(`@@ -${minOriginalLine},${maxOriginalLine - minOriginalLine + 1}, +${minModifiedLine},${maxModifiedLine - minModifiedLine + 1} @@`));
headRow.appendChild(header);
tbody.appendChild(headRow);
for (let i = 0, len = diffs.length; i < len; i++) {
const diffEntry = diffs[i];
DiffReview._renderSection(tbody, diffEntry, originalOpts, originalModel, originalModelOpts, modifiedOpts, modifiedModel, modifiedModelOpts);
}
dom.clearNode(this._content.domNode);
this._content.domNode.appendChild(table);
this.scrollbar.scanDomNode();
}
private static _renderSection(
dest: HTMLElement, diffEntry: DiffEntry,
originalOpts: editorOptions.InternalEditorOptions, originalModel: editorCommon.IModel, originalModelOpts: editorCommon.TextModelResolvedOptions,
modifiedOpts: editorOptions.InternalEditorOptions, modifiedModel: editorCommon.IModel, modifiedModelOpts: editorCommon.TextModelResolvedOptions
): void {
let rowClassName: string = '';
let lineNumbersExtraClassName: string = '';
let spacerClassName: string = 'diff-review-spacer';
switch (diffEntry.getType()) {
case DiffEntryType.Insert:
rowClassName = 'line-insert';
lineNumbersExtraClassName = ' char-insert';
spacerClassName = 'diff-review-spacer insert-sign';
break;
case DiffEntryType.Delete:
rowClassName = 'line-delete';
lineNumbersExtraClassName = ' char-delete';
spacerClassName = 'diff-review-spacer delete-sign';
}
const originalLineStart = diffEntry.originalLineStart;
const originalLineEnd = diffEntry.originalLineEnd;
const modifiedLineStart = diffEntry.modifiedLineStart;
const modifiedLineEnd = diffEntry.modifiedLineEnd;
const cnt = Math.max(
modifiedLineEnd - modifiedLineStart,
originalLineEnd - originalLineStart
);
for (let i = 0; i <= cnt; i++) {
const originalLine = (originalLineStart === 0 ? 0 : originalLineStart + i);
const modifiedLine = (modifiedLineStart === 0 ? 0 : modifiedLineStart + i);
const tr = document.createElement('tr');
tr.className = rowClassName;
const tdOriginalLineNumber = document.createElement('td');
tdOriginalLineNumber.style.width = (originalOpts.layoutInfo.lineNumbersWidth + 'px');
tdOriginalLineNumber.style.minWidth = (originalOpts.layoutInfo.lineNumbersWidth + 'px');
tdOriginalLineNumber.className = 'diff-review-line-number' + lineNumbersExtraClassName;
if (originalLine !== 0) {
tdOriginalLineNumber.appendChild(document.createTextNode(String(originalLine)));
}
tr.appendChild(tdOriginalLineNumber);
const tdModifiedLineNumber = document.createElement('td');
tdModifiedLineNumber.style.width = (10 + modifiedOpts.layoutInfo.lineNumbersWidth + 'px');
tdModifiedLineNumber.style.minWidth = (modifiedOpts.layoutInfo.lineNumbersWidth + 'px');
tdModifiedLineNumber.style.paddingRight = '10px';
tdModifiedLineNumber.className = 'diff-review-line-number' + lineNumbersExtraClassName;
if (modifiedLine !== 0) {
tdModifiedLineNumber.appendChild(document.createTextNode(String(modifiedLine)));
}
tr.appendChild(tdModifiedLineNumber);
const tdContent = document.createElement('td');
tdContent.className = 'diff-review-content';
const spacer = document.createElement('span');
spacer.className = spacerClassName;
spacer.innerHTML = '&nbsp;&nbsp;';
tdContent.appendChild(spacer);
if (modifiedLine !== 0) {
tdContent.insertAdjacentHTML('beforeEnd',
this._renderLine(modifiedModel, modifiedOpts, modifiedModelOpts.tabSize, modifiedLine)
);
} else {
tdContent.insertAdjacentHTML('beforeEnd',
this._renderLine(originalModel, originalOpts, originalModelOpts.tabSize, originalLine)
);
}
tr.appendChild(tdContent);
dest.appendChild(tr);
}
}
private static _renderLine(model: editorCommon.IModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number): string {
const lineContent = model.getLineContent(lineNumber);
const defaultMetadata = (
(FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET)
| (ColorId.DefaultForeground << MetadataConsts.FOREGROUND_OFFSET)
| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)
) >>> 0;
const r = renderViewLine(new RenderLineInput(
(config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations),
lineContent,
model.mightContainRTL(),
0,
[new ViewLineToken(lineContent.length, defaultMetadata)],
[],
tabSize,
config.fontInfo.spaceWidth,
config.viewInfo.stopRenderingLineAfter,
config.viewInfo.renderWhitespace,
config.viewInfo.renderControlCharacters,
config.viewInfo.fontLigatures
));
return r.html;
}
}
// theming
registerThemingParticipant((theme, collector) => {
let lineNumbers = theme.getColor(editorLineNumbers);
if (lineNumbers) {
collector.addRule(`.monaco-diff-editor .diff-review-line-number { color: ${lineNumbers}; }`);
}
const shadow = theme.getColor(scrollbarShadow);
if (shadow) {
collector.addRule(`.monaco-diff-editor .diff-review-shadow { box-shadow: ${shadow} 0 -6px 6px -6px inset; }`);
}
});
......@@ -33,20 +33,42 @@
/* ---------- Diff ---------- */
.monaco-editor .insert-sign, .monaco-editor .delete-sign {
.monaco-editor .insert-sign,
.monaco-diff-editor .insert-sign,
.monaco-editor .delete-sign,
.monaco-diff-editor .delete-sign {
background-size: 60%;
opacity: 0.7;
background-repeat: no-repeat;
background-position: 50% 50%;
}
.monaco-editor.hc-black .insert-sign, .monaco-editor.hc-black .delete-sign {
.monaco-editor.hc-black .insert-sign,
.monaco-diff-editor.hc-black .insert-sign,
.monaco-editor.hc-black .delete-sign,
.monaco-diff-editor.hc-black .delete-sign {
opacity: 1;
}
.monaco-editor .insert-sign { background-image: url('addition.svg'); }
.monaco-editor .delete-sign { background-image: url('deletion.svg'); }
.monaco-editor .insert-sign,
.monaco-diff-editor .insert-sign {
background-image: url('addition.svg');
}
.monaco-editor .delete-sign,
.monaco-diff-editor .delete-sign {
background-image: url('deletion.svg');
}
.monaco-editor.vs-dark .insert-sign, .monaco-editor.hc-black .insert-sign { background-image: url('addition-inverse.svg'); }
.monaco-editor.vs-dark .delete-sign, .monaco-editor.hc-black .delete-sign { background-image: url('deletion-inverse.svg'); }
.monaco-editor.vs-dark .insert-sign,
.monaco-diff-editor.vs-dark .insert-sign,
.monaco-editor.hc-black .insert-sign,
.monaco-diff-editor.hc-black .insert-sign {
background-image: url('addition-inverse.svg');
}
.monaco-editor.vs-dark .delete-sign,
.monaco-diff-editor.vs-dark .delete-sign,
.monaco-editor.hc-black .delete-sign,
.monaco-diff-editor.hc-black .delete-sign {
background-image: url('deletion-inverse.svg');
}
.monaco-editor .inline-deleted-margin-view-zone {
text-align: right;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-diff-editor .diff-review-line-number {
text-align: right;
}
.monaco-diff-editor .diff-review {
position: absolute;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
.monaco-diff-editor .diff-review table,
.monaco-diff-editor .diff-review td,
.monaco-diff-editor .diff-review th,
.monaco-diff-editor .diff-review tr {
padding: 0;
margin: 0;
border: 0;
border-spacing: 0;
}
.monaco-diff-editor .diff-review th {
text-align: left;
}
.monaco-diff-editor .diff-review table {
min-width: 100%;
}
.monaco-diff-editor .diff-review-shadow {
position: absolute;
}
.monaco-diff-editor .diff-review-content {
white-space: pre;
/* word-break: break-all */
}
.monaco-diff-editor .diff-review-spacer {
display: inline-block;
width: 10px;
}
......@@ -238,7 +238,7 @@ export class ModelServiceImpl implements IModelService {
}
let newDefaultEOL = DEFAULT_EOL;
const eol = config.files && config.files.eol;
const eol = config.files && config.files.eol; // TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29119)
if (eol === '\r\n') {
newDefaultEOL = editorCommon.DefaultEndOfLine.CRLF;
} else if (eol === '\n') {
......
......@@ -5,6 +5,7 @@
'use strict';
import * as assert from 'assert';
import * as sinon from 'sinon';
import { IExtensionManagementService, IExtensionEnablementService, DidUninstallExtensionEvent } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionEnablementService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
......@@ -14,26 +15,23 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
// TODO@Sandeep layer breaker: cannot depend on node modules from /common/ and sinon is a node module
// tslint:disable-next-line:import-patterns
import * as sinon from 'sinon';
// TODO@Sandeep layer breaker: cannot depend on /workbench/ from /platform/
// tslint:disable-next-line:import-patterns
import { TestContextService } from 'vs/workbench/test/workbenchTestServices';
function storageService(instantiationService: TestInstantiationService): IStorageService {
let service = instantiationService.get(IStorageService);
if (!service) {
let workspaceContextService = instantiationService.get(IWorkspaceContextService);
if (!workspaceContextService) {
workspaceContextService = instantiationService.stub(IWorkspaceContextService, new TestContextService());
workspaceContextService = instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{
hasWorkspace: () => {
return true;
},
});
}
service = instantiationService.stub(IStorageService, instantiationService.createInstance(StorageService, new InMemoryLocalStorage(), new InMemoryLocalStorage()));
}
return service;
}
export class TestExtensionEnablementService extends ExtensionEnablementService {
constructor(instantiationService: TestInstantiationService) {
super(storageService(instantiationService), instantiationService.get(IWorkspaceContextService),
......
......@@ -5,16 +5,13 @@
'use strict';
import * as sinon from 'sinon';
import { TPromise } from 'vs/base/common/winjs.base';
import * as types from 'vs/base/common/types';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
// TODO@Sandeep layer breaker: cannot depend on node modules from /common/ and sinon is a node module
// tslint:disable-next-line:import-patterns
import * as sinon from 'sinon';
interface IServiceMock<T> {
id: ServiceIdentifier<T>;
service: any;
......
......@@ -8,9 +8,9 @@
import * as assert from 'assert';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { StorageScope } from 'vs/platform/storage/common/storage';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
import { TestContextService } from 'vs/workbench/test/workbenchTestServices';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
suite('Workbench StorageSevice', () => {
let contextService: IWorkspaceContextService;
......@@ -18,7 +18,14 @@ suite('Workbench StorageSevice', () => {
setup(() => {
instantiationService = new TestInstantiationService();
contextService = instantiationService.stub(IWorkspaceContextService, new TestContextService());
contextService = instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{
hasWorkspace: () => {
return true;
},
getWorkspace2: () => {
return <IWorkspace>TestWorkspace;
}
});
});
test('Swap Data with undefined default value', () => {
......
......@@ -7,8 +7,12 @@ import URI from 'vs/base/common/uri';
import { Workspace } from "vs/platform/workspace/common/workspace";
const wsUri = URI.file('C:\\testWorkspace');
export const TestWorkspace = new Workspace(
wsUri.toString(),
wsUri.fsPath,
[wsUri]
);
export const TestWorkspace = testWorkspace(wsUri);
export function testWorkspace(resource: URI): Workspace {
return new Workspace(
resource.toString(),
resource.fsPath,
[resource]
);
}
\ No newline at end of file
......@@ -576,8 +576,7 @@ export class Workbench implements IPartService {
serviceCollection.set(IKeybindingEditingService, this.instantiationService.createInstance(KeybindingsEditingService));
// Configuration Resolver
const workspace = this.contextService.getWorkspace();
serviceCollection.set(IConfigurationResolverService, new SyncDescriptor(ConfigurationResolverService, workspace ? workspace.resource : null, process.env));
serviceCollection.set(IConfigurationResolverService, new SyncDescriptor(ConfigurationResolverService, process.env));
// Quick open service (quick open controller)
this.quickOpen = this.instantiationService.createInstance(QuickOpenController);
......
......@@ -48,7 +48,7 @@ export class LinkDetector {
let resource: uri = null;
try {
resource = (match && !strings.startsWith(match[0], 'http'))
&& (match[2] || strings.startsWith(match[1], '/') ? uri.file(match[1]) : this.contextService.toResource(match[1]));
&& (match[2] || strings.startsWith(match[1], '/') ? uri.file(match[1]) : this.contextService.toResource(match[1])); // TODO@Michel TODO@Isidor (https://github.com/Microsoft/vscode/issues/29190)
} catch (e) { }
if (!resource) {
......
......@@ -23,14 +23,14 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
import * as debug from 'vs/workbench/parts/debug/common/debug';
import { IRawAdapter, ICompound, IDebugConfiguration, DEBUG_SCHEME, IConfig, IEnvConfig, IGlobalConfig, IConfigurationManager } from 'vs/workbench/parts/debug/common/debug';
import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
// debuggers extension point
export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<debug.IRawAdapter[]>('debuggers', [], {
export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<IRawAdapter[]>('debuggers', [], {
description: nls.localize('vscode.extension.contributes.debuggers', 'Contributes debug adapters.'),
type: 'array',
defaultSnippets: [{ body: [{ type: '', extensions: [] }] }],
......@@ -148,7 +148,7 @@ const breakpointsExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtens
// debug general schema
export const schemaId = 'vscode://schemas/launch';
const defaultCompound: debug.ICompound = { name: 'Compound', configurations: [] };
const defaultCompound: ICompound = { name: 'Compound', configurations: [] };
const schema: IJSONSchema = {
id: schemaId,
type: 'object',
......@@ -202,7 +202,7 @@ const schema: IJSONSchema = {
const jsonRegistry = <IJSONContributionRegistry>Registry.as(JSONExtensions.JSONContribution);
jsonRegistry.registerSchema(schemaId, schema);
export class ConfigurationManager implements debug.IConfigurationManager {
export class ConfigurationManager implements IConfigurationManager {
private adapters: Adapter[];
private breakpointModeIdsSet: Set<string>;
......@@ -271,12 +271,12 @@ export class ConfigurationManager implements debug.IConfigurationManager {
return this.adapters.filter(adapter => strings.equalsIgnoreCase(adapter.type, type)).pop();
}
public getCompound(name: string): debug.ICompound {
public getCompound(name: string): ICompound {
if (!this.contextService.hasWorkspace()) {
return null;
}
const config = this.configurationService.getConfiguration<debug.IGlobalConfig>('launch');
const config = this.configurationService.getConfiguration<IGlobalConfig>('launch', { resource: this.contextService.getWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245)
if (!config || !config.compounds) {
return null;
}
......@@ -285,7 +285,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
}
public getConfigurationNames(): string[] {
const config = this.configurationService.getConfiguration<debug.IGlobalConfig>('launch');
const config = this.configurationService.getConfiguration<IGlobalConfig>('launch', { resource: this.contextService.getWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245)
if (!config || !config.configurations) {
return [];
} else {
......@@ -301,12 +301,12 @@ export class ConfigurationManager implements debug.IConfigurationManager {
}
}
public getConfiguration(name: string): debug.IConfig {
public getConfiguration(name: string): IConfig {
if (!this.contextService.hasWorkspace()) {
return null;
}
const config = this.configurationService.getConfiguration<debug.IGlobalConfig>('launch');
const config = this.configurationService.getConfiguration<IGlobalConfig>('launch', { resource: this.contextService.getWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245)
if (!config || !config.configurations) {
return null;
}
......@@ -314,14 +314,14 @@ export class ConfigurationManager implements debug.IConfigurationManager {
return config.configurations.filter(config => config && config.name === name).shift();
}
public resloveConfiguration(config: debug.IConfig): TPromise<debug.IConfig> {
public resloveConfiguration(config: IConfig): TPromise<IConfig> {
if (!this.contextService.hasWorkspace()) {
return TPromise.as(config);
}
const result = objects.deepClone(config) as debug.IConfig;
const result = objects.deepClone(config) as IConfig;
// Set operating system specific properties #1873
const setOSProperties = (flag: boolean, osConfig: debug.IEnvConfig) => {
const setOSProperties = (flag: boolean, osConfig: IEnvConfig) => {
if (flag && osConfig) {
Object.keys(osConfig).forEach(key => {
result[key] = osConfig[key];
......@@ -342,7 +342,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
}
public get configFileUri(): uri {
return uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '/.vscode/launch.json'));
return uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '/.vscode/launch.json')); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245)
}
public openConfigFile(sideBySide: boolean, type?: string): TPromise<IEditor> {
......@@ -422,10 +422,10 @@ export class ConfigurationManager implements debug.IConfigurationManager {
}
public canSetBreakpointsIn(model: IModel): boolean {
if (model.uri.scheme !== Schemas.file && model.uri.scheme !== debug.DEBUG_SCHEME) {
if (model.uri.scheme !== Schemas.file && model.uri.scheme !== DEBUG_SCHEME) {
return false;
}
if (this.configurationService.getConfiguration<debug.IDebugConfiguration>('debug').allowBreakpointsEverywhere) {
if (this.configurationService.getConfiguration<IDebugConfiguration>('debug').allowBreakpointsEverywhere) {
return true;
}
......
......@@ -822,7 +822,7 @@ export class DebugService implements debug.IDebugService {
watchExpressionsCount: this.model.getWatchExpressions().length,
extensionName: `${adapter.extensionDescription.publisher}.${adapter.extensionDescription.name}`,
isBuiltin: adapter.extensionDescription.isBuiltin,
launchJsonExists: !!this.configurationService.getConfiguration<debug.IGlobalConfig>('launch')
launchJsonExists: this.contextService.hasWorkspace() && !!this.configurationService.getConfiguration<debug.IGlobalConfig>('launch', { resource: this.contextService.getWorkspace().resource }) // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245)
});
}).then(() => process, (error: any) => {
if (error instanceof Error && error.message === 'Canceled') {
......
......@@ -292,7 +292,7 @@ export abstract class EmmetEditorAction extends EditorAction {
const modeService = accessor.get(IModeService);
const messageService = accessor.get(IMessageService);
const contextService = accessor.get(IWorkspaceContextService);
const workspaceRoot = contextService.hasWorkspace() ? contextService.getWorkspace().resource.fsPath : '';
const workspaceRoot = contextService.hasWorkspace() ? contextService.getWorkspace().resource.fsPath : ''; // TODO@Ramya (https://github.com/Microsoft/vscode/issues/29244)
const telemetryService = accessor.get(ITelemetryService);
const commandService = accessor.get(ICommandService);
......
......@@ -1224,7 +1224,7 @@ export class ConfigureWorkspaceRecommendedExtensionsAction extends Action {
}
private getOrCreateExtensionsFile(): TPromise<{ created: boolean, extensionsFileResource: URI }> {
const extensionsFileResource = URI.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '.vscode', 'extensions.json'));
const extensionsFileResource = URI.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '.vscode', 'extensions.json')); // TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29242)
return this.fileService.resolveContent(extensionsFileResource).then(content => {
return { created: false, extensionsFileResource };
......
......@@ -68,7 +68,7 @@ export class ExtensionTipsService implements IExtensionTipsService {
if (!this.contextService.hasWorkspace()) {
return TPromise.as([]);
}
return this.fileService.resolveContent(this.contextService.toResource(paths.join('.vscode', 'extensions.json'))).then(content => {
return this.fileService.resolveContent(this.contextService.toResource(paths.join('.vscode', 'extensions.json'))).then(content => { //TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29242)
const extensionsContent = <IExtensionsContent>json.parse(content.value, []);
if (extensionsContent.recommendations) {
const regEx = new RegExp(EXTENSION_IDENTIFIER_PATTERN);
......
......@@ -261,7 +261,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return URI.file(this.environmentService.appSettingsPath);
case ConfigurationTarget.WORKSPACE:
if (this.contextService.hasWorkspace()) {
return this.contextService.toResource('.vscode/settings.json');
return this.contextService.toResource('.vscode/settings.json'); // TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29456)
}
}
return null;
......
......@@ -245,9 +245,14 @@ definitions.commandConfiguration.properties.isShellCommand = Objects.deepClone(s
definitions.options.properties.shell = {
$ref: '#/definitions/shellConfiguration'
};
definitions.taskRunnerConfiguration.properties.isShellCommand = Objects.deepClone(shellCommand);
definitions.taskRunnerConfiguration.properties.type = Objects.deepClone(taskType);
definitions.taskRunnerConfiguration.properties.version = Objects.deepClone(version);
let osSpecificTaskRunnerConfiguration = Objects.deepClone(definitions.taskRunnerConfiguration);
delete osSpecificTaskRunnerConfiguration.properties.tasks;
osSpecificTaskRunnerConfiguration.additionalProperties = false;
definitions.osSpecificTaskRunnerConfiguration = osSpecificTaskRunnerConfiguration;
const schema: IJSONSchema = {
oneOf: [
......@@ -259,15 +264,15 @@ const schema: IJSONSchema = {
properties: {
version: Objects.deepClone(version),
windows: {
'$ref': '#/definitions/taskRunnerConfiguration',
'$ref': '#/definitions/osSpecificTaskRunnerConfiguration',
'description': nls.localize('JsonSchema.windows', 'Windows specific command configuration')
},
osx: {
'$ref': '#/definitions/taskRunnerConfiguration',
'$ref': '#/definitions/osSpecificTaskRunnerConfiguration',
'description': nls.localize('JsonSchema.mac', 'Mac specific command configuration')
},
linux: {
'$ref': '#/definitions/taskRunnerConfiguration',
'$ref': '#/definitions/osSpecificTaskRunnerConfiguration',
'description': nls.localize('JsonSchema.linux', 'Linux specific command configuration')
}
}
......
......@@ -115,7 +115,7 @@ abstract class OpenTaskConfigurationAction extends Action {
}
let sideBySide = !!(event && (event.ctrlKey || event.metaKey));
let configFileCreated = false;
return this.fileService.resolveFile(this.contextService.toResource('.vscode/tasks.json')).then((success) => {
return this.fileService.resolveFile(this.contextService.toResource('.vscode/tasks.json')).then((success) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return success;
}, (err: any) => {
;
......@@ -166,7 +166,7 @@ abstract class OpenTaskConfigurationAction extends Action {
content = content.replace(/(\n)(\t+)/g, (_, s1, s2) => s1 + strings.repeat(' ', s2.length * editorConfig.editor.tabSize));
}
configFileCreated = true;
return this.fileService.createFile(this.contextService.toResource('.vscode/tasks.json'), content);
return this.fileService.createFile(this.contextService.toResource('.vscode/tasks.json'), content); // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
});
/* 2.0 version
let content = selection.content;
......@@ -871,7 +871,7 @@ class TaskService extends EventEmitter implements ITaskService {
if (editorConfig.editor.insertSpaces) {
content = content.replace(/(\n)(\t+)/g, (_, s1, s2) => s1 + strings.repeat(' ', s2.length * editorConfig.editor.tabSize));
}
promise = this.fileService.createFile(this.contextService.toResource('.vscode/tasks.json'), content).then(() => { });
promise = this.fileService.createFile(this.contextService.toResource('.vscode/tasks.json'), content).then(() => { }); // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
} else {
let value: IConfigurationValue = { key: undefined, value: undefined };
if (Array.isArray(fileConfig.tasks)) {
......@@ -885,7 +885,7 @@ class TaskService extends EventEmitter implements ITaskService {
};
return promise.then(() => {
if (openConfig) {
let resource = this.contextService.toResource('.vscode/tasks.json');
let resource = this.contextService.toResource('.vscode/tasks.json'); // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
this.editorService.openEditor({
resource: resource,
options: {
......@@ -1277,7 +1277,7 @@ class TaskService extends EventEmitter implements ITaskService {
}
private getConfiguration(): { config: TaskConfig.ExternalTaskRunnerConfiguration; hasParseErrors: boolean } {
let result = this.configurationService.getConfiguration<TaskConfig.ExternalTaskRunnerConfiguration>('tasks');
let result = this.contextService.hasWorkspace() ? this.configurationService.getConfiguration<TaskConfig.ExternalTaskRunnerConfiguration>('tasks', { resource: this.contextService.getWorkspace().resource }) : undefined;
if (!result) {
return { config: undefined, hasParseErrors: false };
}
......
......@@ -226,7 +226,7 @@ export class ProcessRunnerDetector {
}
private tryDetectGulp(list: boolean): TPromise<DetectorResult> {
return this.fileService.resolveFile(this.contextService.toResource('gulpfile.js')).then((stat) => {
return this.fileService.resolveFile(this.contextService.toResource('gulpfile.js')).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
let config = ProcessRunnerDetector.detectorConfig('gulp');
let process = new LineProcess('gulp', [config.arg, '--no-color'], true, { cwd: this._cwd });
return this.runDetection(process, 'gulp', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
......@@ -236,7 +236,7 @@ export class ProcessRunnerDetector {
}
private tryDetectGrunt(list: boolean): TPromise<DetectorResult> {
return this.fileService.resolveFile(this.contextService.toResource('Gruntfile.js')).then((stat) => {
return this.fileService.resolveFile(this.contextService.toResource('Gruntfile.js')).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
let config = ProcessRunnerDetector.detectorConfig('grunt');
let process = new LineProcess('grunt', [config.arg, '--no-color'], true, { cwd: this._cwd });
return this.runDetection(process, 'grunt', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
......@@ -251,10 +251,10 @@ export class ProcessRunnerDetector {
let process = new LineProcess('jake', [config.arg], true, { cwd: this._cwd });
return this.runDetection(process, 'jake', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
};
return this.fileService.resolveFile(this.contextService.toResource('Jakefile')).then((stat) => {
return this.fileService.resolveFile(this.contextService.toResource('Jakefile')).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return run();
}, (err: any) => {
return this.fileService.resolveFile(this.contextService.toResource('Jakefile.js')).then((stat) => {
return this.fileService.resolveFile(this.contextService.toResource('Jakefile.js')).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return run();
}, (err: any): TaskConfig.ExternalTaskRunnerConfiguration => {
return null;
......
......@@ -1649,12 +1649,27 @@ class ConfigurationParser {
}
context.namedProblemMatchers = ProblemMatcherConverter.namedFrom(fileConfig.declares, context);
let globalTasks: Tasks.CustomTask[];
let externalGlobalTasks: (ConfiguringTask | CustomTask)[];
if (fileConfig.windows && Platform.platform === Platform.Platform.Windows) {
globalTasks = TaskParser.from(fileConfig.windows.tasks, globals, context).custom;
externalGlobalTasks = fileConfig.windows.tasks;
} else if (fileConfig.osx && Platform.platform === Platform.Platform.Mac) {
globalTasks = TaskParser.from(fileConfig.osx.tasks, globals, context).custom;
externalGlobalTasks = fileConfig.osx.tasks;
} else if (fileConfig.linux && Platform.platform === Platform.Platform.Linux) {
globalTasks = TaskParser.from(fileConfig.linux.tasks, globals, context).custom;
externalGlobalTasks = fileConfig.linux.tasks;
}
if (context.schemaVersion === Tasks.JsonSchemaVersion.V2_0_0 && globalTasks && globalTasks.length > 0 && externalGlobalTasks && externalGlobalTasks.length > 0) {
let taskContent: string[] = [];
for (let task of externalGlobalTasks) {
taskContent.push(JSON.stringify(task, null, 4));
}
context.problemReporter.error(
nls.localize(
'TaskParse.noOsSpecificGlobalTasks',
'Task version 2.0.0 doesn\'t support gloabl OS specific tasks. Convert them to a task with a OS specific command. Affected tasks are:\n{0}', taskContent.join('\n'))
);
}
let result: TaskParseResult = { custom: undefined, configured: undefined };
......
......@@ -209,7 +209,7 @@ export class TerminalLinkHandler {
// Abort if no workspace is open
return null;
}
link = path.join(this._contextService.getWorkspace().resource.fsPath, link);
link = path.join(this._contextService.getWorkspace().resource.fsPath, link); // TODO@Daniel (https://github.com/Microsoft/vscode/issues/29006)
}
}
// Resolve workspace path . | .. | <relative_path> -> <path>/. | <path>/.. | <path>/<relative_path>
......@@ -218,7 +218,7 @@ export class TerminalLinkHandler {
// Abort if no workspace is open
return null;
}
link = path.join(this._contextService.getWorkspace().resource.fsPath, link);
link = path.join(this._contextService.getWorkspace().resource.fsPath, link); // TODO@Daniel (https://github.com/Microsoft/vscode/issues/29006)
}
return link;
}
......
......@@ -266,7 +266,7 @@ export class ConfigurationEditingService implements IConfigurationEditingService
const standaloneConfigurationKeys = Object.keys(WORKSPACE_STANDALONE_CONFIGURATIONS);
for (let i = 0; i < standaloneConfigurationKeys.length; i++) {
const key = standaloneConfigurationKeys[i];
const resource = this.contextService.toResource(WORKSPACE_STANDALONE_CONFIGURATIONS[key]);
const resource = this.contextService.toResource(WORKSPACE_STANDALONE_CONFIGURATIONS[key]); // TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29456)
// Check for prefix
if (config.key === key) {
......
......@@ -5,7 +5,6 @@
import * as paths from 'vs/base/common/paths';
import * as types from 'vs/base/common/types';
import uri from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { sequence } from 'vs/base/common/async';
import { IStringDictionary } from 'vs/base/common/collections';
......@@ -16,6 +15,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { toResource } from 'vs/workbench/common/editor';
import { IWorkspaceContextService } from "vs/platform/workspace/common/workspace";
export class ConfigurationResolverService implements IConfigurationResolverService {
_serviceBrand: any;
......@@ -23,14 +23,14 @@ export class ConfigurationResolverService implements IConfigurationResolverServi
private _execPath: string;
constructor(
workspaceRoot: uri,
envVariables: { [key: string]: string },
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEnvironmentService environmentService: IEnvironmentService,
@IConfigurationService private configurationService: IConfigurationService,
@ICommandService private commandService: ICommandService
@ICommandService private commandService: ICommandService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
this._workspaceRoot = paths.normalize(workspaceRoot ? workspaceRoot.fsPath : '', true);
this._workspaceRoot = paths.normalize(contextService.hasWorkspace() ? contextService.getWorkspace().resource.fsPath : '', true); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29246)
this._execPath = environmentService.execPath;
Object.keys(envVariables).forEach(key => {
this[`env:${key}`] = envVariables[key];
......
......@@ -11,8 +11,9 @@ import { IConfigurationService, getConfigurationValue, IConfigurationOverrides,
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/node/configurationResolverService';
import { TestEnvironmentService, TestEditorService, } from 'vs/workbench/test/workbenchTestServices';
import { TestEnvironmentService, TestEditorService, TestContextService } from 'vs/workbench/test/workbenchTestServices';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { testWorkspace } from "vs/platform/workspace/test/common/testWorkspace";
suite('Configuration Resolver Service', () => {
let configurationResolverService: IConfigurationResolverService;
......@@ -20,10 +21,11 @@ suite('Configuration Resolver Service', () => {
let mockCommandService: MockCommandService;
let editorService: TestEditorService;
setup(() => {
mockCommandService = new MockCommandService();
editorService = new TestEditorService();
configurationResolverService = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, editorService, TestEnvironmentService, new TestConfigurationService(), mockCommandService);
configurationResolverService = new ConfigurationResolverService(envVariables, editorService, TestEnvironmentService, new TestConfigurationService(), mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
});
teardown(() => {
......@@ -84,7 +86,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} xyz'), 'abc foo xyz');
});
......@@ -101,7 +103,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz');
});
......@@ -118,7 +120,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
if (platform.isWindows) {
assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo \\VSCode\\workspaceLocation bar bar xyz');
} else {
......@@ -139,7 +141,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
if (platform.isWindows) {
assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo \\VSCode\\workspaceLocation bar bar xyz');
} else {
......@@ -160,7 +162,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
if (platform.isWindows) {
assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${workspaceRoot} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz');
} else {
......@@ -181,7 +183,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
if (platform.isWindows) {
assert.strictEqual(service.resolve('${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2');
} else {
......@@ -215,7 +217,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:editor.lineNumbers} ${config:editor.insertSpaces} xyz'), 'abc foo 123 false xyz');
});
......@@ -227,7 +229,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:editor[\'abc\'.substr(0)]} xyz'), 'abc xyz');
});
......@@ -237,7 +239,7 @@ suite('Configuration Resolver Service', () => {
editor: {}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:editor.abc} xyz'), 'abc xyz');
assert.strictEqual(service.resolve('abc ${config:editor.abc.def} xyz'), 'abc xyz');
assert.strictEqual(service.resolve('abc ${config:panel} xyz'), 'abc xyz');
......@@ -250,7 +252,7 @@ suite('Configuration Resolver Service', () => {
editor: {}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:editor.__proto__} xyz'), 'abc xyz');
assert.strictEqual(service.resolve('abc ${config:editor.toString} xyz'), 'abc xyz');
});
......@@ -263,7 +265,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService);
let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation'))));
assert.strictEqual(service.resolve('abc ${config:} xyz'), 'abc ${config:} xyz');
assert.strictEqual(service.resolve('abc ${config:editor..fontFamily} xyz'), 'abc xyz');
assert.strictEqual(service.resolve('abc ${config:editor.none.none2} xyz'), 'abc xyz');
......
......@@ -21,11 +21,12 @@ var app = express();
app.use('/out', express.static(path.join(root, 'out')));
app.use('/test', express.static(path.join(root, 'test')));
app.use('/node_modules', express.static(path.join(root, 'node_modules')));
app.get('/', function (req, res) {
glob('**/test/**/*.js', {
glob('**/vs/{base,platform,editor}/**/test/{common,browser}/**/*.test.js', {
cwd: path.join(root, 'out'),
ignore: ['**/test/{node,electron*}/**/*.js']
// ignore: ['**/test/{node,electron*}/**/*.js']
}, function (err, files) {
if (err) { return res.sendStatus(500); }
......
......@@ -18,7 +18,8 @@
require.config({
baseUrl: '/out',
paths: {
assert: '/test/assert.js'
assert: '/test/assert.js',
sinon: '/node_modules/sinon/pkg/sinon-1.17.7.js'
}
});
......
......@@ -79,8 +79,7 @@ function fail(errorMessage): void {
function runTests(): void {
console.log('Running tests...');
const spawn = require('child_process').spawn;
var proc = spawn(process.execPath, [
var proc = child_process.spawn(process.execPath, [
'out/mocha-runner.js'
]);
proc.stdout.on('data', data => {
......@@ -101,23 +100,35 @@ function runTests(): void {
function cleanOrClone(repo: string, dir: string): Promise<any> {
console.log('Cleaning or cloning test project repository...');
return new Promise((res, rej) => {
return new Promise(async (res, rej) => {
if (!folderExists(dir)) {
git.clone(repo, dir, () => {
console.log('Test repository successfully cloned.');
await gitClone(repo, dir);
res();
});
} else {
git.cwd(dir);
git.fetch(err => {
git.fetch(async err => {
if (err) {
rej(err);
}
resetAndClean();
await gitResetAndClean();
res();
});
}
});
}
function gitClone(repo: string, dir: string): Promise<any> {
return new Promise((res, rej) => {
git.clone(repo, dir, () => {
console.log('Test repository successfully cloned.');
res();
});
});
}
var resetAndClean = () => {
function gitResetAndClean(): Promise<any> {
return new Promise((res, rej) => {
git.reset(['FETCH_HEAD', '--hard'], err => {
if (err) {
rej(err);
......@@ -131,11 +142,10 @@ function cleanOrClone(repo: string, dir: string): Promise<any> {
res();
});
});
};
});
}
function execute(cmd, dir): Promise<any> {
function execute(cmd: string, dir: string): Promise<any> {
return new Promise((res, rej) => {
console.log(`Running ${cmd}...`);
child_process.exec(cmd, { cwd: dir, stdio: [0, 1, 2] }, (error, stdout, stderr) => {
......
......@@ -120,7 +120,7 @@ export class SpectronApplication {
let result;
try {
result = await func.call(this.client, args);
result = await func.call(this.client, args, false);
} catch (e) { }
if (result && result !== '') {
......
......@@ -116,6 +116,7 @@
"target": "**/vs/platform/*/test/common/**",
"restrictions": [
"assert",
"sinon",
"vs/nls",
"**/vs/base/common/**",
"**/vs/platform/*/common/**",
......@@ -136,6 +137,7 @@
"target": "**/vs/platform/*/test/browser/**",
"restrictions": [
"assert",
"sinon",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/platform/*/{common,browser}/**",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册