Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="3 3 16 16" enable-background="new 3 3 16 16"><polygon fill="#e8e8e8" points="12.597,11.042 15.4,13.845 13.844,15.4 11.042,12.598 8.239,15.4 6.683,13.845 9.485,11.042 6.683,8.239 8.238,6.683 11.042,9.486 13.845,6.683 15.4,8.239"/></svg>

After

Width:  |  Height:  |  Size: 307 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="3 3 16 16" enable-background="new 3 3 16 16"><polygon fill="#424242" points="12.597,11.042 15.4,13.845 13.844,15.4 11.042,12.598 8.239,15.4 6.683,13.845 9.485,11.042 6.683,8.239 8.238,6.683 11.042,9.486 13.845,6.683 15.4,8.239"/></svg>

After

Width:  |  Height:  |  Size: 307 B

View File

@@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-editor .peekview-widget .head {
-webkit-box-sizing: border-box;
-o-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
display: flex;
}
.monaco-editor .peekview-widget .head .peekview-title {
display: inline-block;
font-size: 13px;
margin-left: 20px;
cursor: pointer;
}
.monaco-editor .peekview-widget .head .peekview-title .dirname:not(:empty) {
font-size: 0.9em;
margin-left: 0.5em;
}
.monaco-editor .peekview-widget .head .peekview-actions {
flex: 1;
text-align: right;
padding-right: 2px;
}
.monaco-editor .peekview-widget .head .peekview-actions > .monaco-action-bar {
display: inline-block;
}
.monaco-editor .peekview-widget .head .peekview-actions > .monaco-action-bar,
.monaco-editor .peekview-widget .head .peekview-actions > .monaco-action-bar > .actions-container {
height: 100%;
}
.monaco-editor .peekview-widget .head .peekview-actions > .monaco-action-bar .action-item {
margin-left: 4px;
}
.monaco-editor .peekview-widget .head .peekview-actions > .monaco-action-bar .action-label {
width: 16px;
height: 100%;
margin: 0;
line-height: inherit;
background-repeat: no-repeat;
background-position: center center;
}
.monaco-editor .peekview-widget .head .peekview-actions > .monaco-action-bar .action-label.octicon {
margin: 0;
}
.monaco-editor .peekview-widget .head .peekview-actions .action-label.icon.close-peekview-action {
background: url('close.svg') center center no-repeat;
}
.monaco-editor .peekview-widget > .body {
border-top: 1px solid;
position: relative;
}
/* Dark Theme */
/* High Contrast Theme */
.monaco-editor.hc-black .peekview-widget .head .peekview-actions .action-label.icon.close-peekview-action,
.monaco-editor.vs-dark .peekview-widget .head .peekview-actions .action-label.icon.close-peekview-action {
background: url('close-inverse.svg') center center no-repeat;
}

View File

@@ -37,21 +37,18 @@
}
.monaco-editor .reference-zone-widget .ref-tree .reference-file {
display: flex;
justify-content: space-between;
align-items: center;
display: inline-flex;
width: 100%;
height: 100%;
}
.monaco-editor .reference-zone-widget .monaco-count-badge {
margin-right: .5em;
height: 15px;
padding: 0 .5em .5em .5em
.monaco-editor .reference-zone-widget .ref-tree .reference-file .count {
margin-right: 12px;
margin-left: auto;
}
/* High Contrast Theming */
.monaco-editor.hc-black .reference-zone-widget .ref-tree .reference-file {
font-weight: bold;
display: flex;
justify-content: space-between;
}

View File

@@ -0,0 +1,196 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/peekViewWidget';
import * as nls from 'vs/nls';
import { Action } from 'vs/base/common/actions';
import * as strings from 'vs/base/common/strings';
import * as objects from 'vs/base/common/objects';
import { $ } from 'vs/base/browser/builder';
import Event, { Emitter } from 'vs/base/common/event';
import * as dom from 'vs/base/browser/dom';
import { ActionBar, IActionBarOptions } from 'vs/base/browser/ui/actionbar/actionbar';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IOptions, ZoneWidget, IStyles } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Color } from 'vs/base/common/color';
export namespace PeekContext {
export const inPeekEditor = new RawContextKey<boolean>('inReferenceSearchEditor', true);
export const notInPeekEditor: ContextKeyExpr = inPeekEditor.toNegated();
}
export function getOuterEditor(accessor: ServicesAccessor): ICommonCodeEditor {
let editor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
if (editor instanceof EmbeddedCodeEditorWidget) {
return editor.getParentEditor();
}
return editor;
}
export interface IPeekViewStyles extends IStyles {
headerBackgroundColor?: Color;
primaryHeadingColor?: Color;
secondaryHeadingColor?: Color;
}
export interface IPeekViewOptions extends IOptions, IPeekViewStyles {
}
const defaultOptions: IPeekViewOptions = {
headerBackgroundColor: Color.white,
primaryHeadingColor: Color.fromHex('#333333'),
secondaryHeadingColor: Color.fromHex('#6c6c6cb3')
};
export abstract class PeekViewWidget extends ZoneWidget {
public _serviceBrand: any;
private _onDidClose = new Emitter<PeekViewWidget>();
protected _headElement: HTMLDivElement;
protected _primaryHeading: HTMLElement;
protected _secondaryHeading: HTMLElement;
protected _metaHeading: HTMLElement;
protected _actionbarWidget: ActionBar;
protected _bodyElement: HTMLDivElement;
constructor(editor: ICodeEditor, options: IPeekViewOptions = {}) {
super(editor, options);
objects.mixin(this.options, defaultOptions, false);
}
public dispose(): void {
super.dispose();
this._onDidClose.fire(this);
}
public get onDidClose(): Event<PeekViewWidget> {
return this._onDidClose.event;
}
public style(styles: IPeekViewStyles): void {
let options = <IPeekViewOptions>this.options;
if (styles.headerBackgroundColor) {
options.headerBackgroundColor = styles.headerBackgroundColor;
}
if (styles.primaryHeadingColor) {
options.primaryHeadingColor = styles.primaryHeadingColor;
}
if (styles.secondaryHeadingColor) {
options.secondaryHeadingColor = styles.secondaryHeadingColor;
}
super.style(styles);
}
protected _applyStyles(): void {
super._applyStyles();
let options = <IPeekViewOptions>this.options;
if (this._headElement) {
this._headElement.style.backgroundColor = options.headerBackgroundColor.toString();
}
if (this._primaryHeading) {
this._primaryHeading.style.color = options.primaryHeadingColor.toString();
}
if (this._secondaryHeading) {
this._secondaryHeading.style.color = options.secondaryHeadingColor.toString();
}
if (this._bodyElement) {
this._bodyElement.style.borderColor = options.frameColor.toString();
}
}
protected _fillContainer(container: HTMLElement): void {
this.setCssClass('peekview-widget');
this._headElement = <HTMLDivElement>$('.head').getHTMLElement();
this._bodyElement = <HTMLDivElement>$('.body').getHTMLElement();
this._fillHead(this._headElement);
this._fillBody(this._bodyElement);
container.appendChild(this._headElement);
container.appendChild(this._bodyElement);
}
protected _fillHead(container: HTMLElement): void {
var titleElement = $('.peekview-title').
on(dom.EventType.CLICK, e => this._onTitleClick(<MouseEvent>e)).
appendTo(this._headElement).
getHTMLElement();
this._primaryHeading = $('span.filename').appendTo(titleElement).getHTMLElement();
this._secondaryHeading = $('span.dirname').appendTo(titleElement).getHTMLElement();
this._metaHeading = $('span.meta').appendTo(titleElement).getHTMLElement();
const actionsContainer = $('.peekview-actions').appendTo(this._headElement);
const actionBarOptions = this._getActionBarOptions();
this._actionbarWidget = new ActionBar(actionsContainer, actionBarOptions);
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), 'close-peekview-action', true, () => {
this.dispose();
return null;
}), { label: false, icon: true });
}
protected _getActionBarOptions(): IActionBarOptions {
return {};
}
protected _onTitleClick(event: MouseEvent): void {
// implement me
}
public setTitle(primaryHeading: string, secondaryHeading?: string): void {
$(this._primaryHeading).safeInnerHtml(primaryHeading);
this._primaryHeading.setAttribute('aria-label', primaryHeading);
if (secondaryHeading) {
$(this._secondaryHeading).safeInnerHtml(secondaryHeading);
} else {
dom.clearNode(this._secondaryHeading);
}
}
public setMetaTitle(value: string): void {
if (value) {
$(this._metaHeading).safeInnerHtml(value);
} else {
dom.clearNode(this._metaHeading);
}
}
protected abstract _fillBody(container: HTMLElement): void;
public _doLayout(heightInPixel: number, widthInPixel: number): void {
if (!this._isShowing && heightInPixel < 0) {
// Looks like the view zone got folded away!
this.dispose();
return;
}
var headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2),
bodyHeight = heightInPixel - (headHeight + 2 /* the border-top/bottom width*/);
this._doLayoutHead(headHeight, widthInPixel);
this._doLayoutBody(bodyHeight, widthInPixel);
}
protected _doLayoutHead(heightInPixel: number, widthInPixel: number): void {
this._headElement.style.height = strings.format('{0}px', heightInPixel);
this._headElement.style.lineHeight = this._headElement.style.height;
}
protected _doLayoutBody(heightInPixel: number, widthInPixel: number): void {
this._bodyElement.style.height = strings.format('{0}px', heightInPixel);
}
}

View File

@@ -9,7 +9,6 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorService } from 'vs/platform/editor/common/editor';
import { optional } from 'vs/platform/instantiation/common/instantiation';
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
@@ -18,12 +17,13 @@ import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { editorAction, ServicesAccessor, EditorAction, CommonEditorRegistry, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { Location, ReferenceProviderRegistry } from 'vs/editor/common/modes';
import { IPeekViewService, PeekContext, getOuterEditor } from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget';
import { PeekContext, getOuterEditor } from './peekViewWidget';
import { ReferencesController, RequestOptions, ctxReferenceSearchVisible } from './referencesController';
import { ReferencesModel } from './referencesModel';
import { asWinJsPromise } from 'vs/base/common/async';
import { onUnexpectedExternalError } from 'vs/base/common/errors';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
const defaultReferenceSearchOptions: RequestOptions = {
getMetaTitle(model) {
@@ -38,10 +38,9 @@ export class ReferenceController implements editorCommon.IEditorContribution {
constructor(
editor: editorCommon.ICommonCodeEditor,
@IContextKeyService contextKeyService: IContextKeyService,
@optional(IPeekViewService) peekViewService: IPeekViewService
@IContextKeyService contextKeyService: IContextKeyService
) {
if (peekViewService) {
if (editor instanceof EmbeddedCodeEditorWidget) {
PeekContext.inPeekEditor.bindTo(contextKeyService);
}
}
@@ -144,9 +143,13 @@ let showReferencesCommand: ICommandHandler = (accessor: ServicesAccessor, resour
// register commands
CommandsRegistry.registerCommand('editor.action.findReferences', findReferencesCommand);
CommandsRegistry.registerCommand({
id: 'editor.action.findReferences',
handler: findReferencesCommand
});
CommandsRegistry.registerCommand('editor.action.showReferences', {
CommandsRegistry.registerCommand({
id: 'editor.action.showReferences',
handler: showReferencesCommand,
description: {
description: 'Show references at a position in a file',

View File

@@ -21,7 +21,6 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions';
import { IPeekViewService } from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget';
import { ReferencesModel, OneReference } from './referencesModel';
import { ReferenceWidget, LayoutData } from './referencesWidget';
import { Range } from 'vs/editor/common/core/range';
@@ -67,7 +66,6 @@ export class ReferencesController implements editorCommon.IEditorContribution {
@IStorageService private _storageService: IStorageService,
@IThemeService private _themeService: IThemeService,
@IConfigurationService private _configurationService: IConfigurationService,
@optional(IPeekViewService) private _peekViewService: IPeekViewService,
@optional(IEnvironmentService) private _environmentService: IEnvironmentService
) {
this._editor = editor;
@@ -125,7 +123,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
switch (kind) {
case 'open':
if (event.source === 'editor'
&& this._configurationService.lookup('editor.stablePeek').value) {
&& this._configurationService.getValue('editor.stablePeek')) {
// when stable peek is configured we don't close
// the peek window on selecting the editor
@@ -163,6 +161,12 @@ export class ReferencesController implements editorCommon.IEditorContribution {
const startTime = Date.now();
this._disposables.push({
dispose: () => {
/* __GDPR__
"zoneWidgetShown" : {
"mode" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"elapsedTime": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this._telemetryService.publicLog('zoneWidgetShown', {
mode: 'reference search',
elapsedTime: Date.now() - startTime
@@ -193,6 +197,12 @@ export class ReferencesController implements editorCommon.IEditorContribution {
const onDone = stopwatch(fromPromise(promise));
const mode = this._editor.getModel().getLanguageIdentifier().language;
/* __GDPR__
"findReferences" : {
"durarion" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"mode": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
onDone(duration => this._telemetryService.publicLog('findReferences', {
duration,
mode

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./referencesWidget';
import 'vs/css!./media/referencesWidget';
import * as nls from 'vs/nls';
import { onUnexpectedError } from 'vs/base/common/errors';
import { getPathLabel } from 'vs/base/common/labels';
@@ -26,20 +26,18 @@ import * as tree from 'vs/base/parts/tree/browser/tree';
import { DefaultController } from 'vs/base/parts/tree/browser/treeDefaults';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { Range, IRange } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { Model } from 'vs/editor/common/model/model';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { PeekViewWidget, IPeekViewService } from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget';
import { PeekViewWidget } from './peekViewWidget';
import { FileReferences, OneReference, ReferencesModel } from './referencesModel';
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
import { registerColor, activeContrastBorder, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant, ITheme, IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler, attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { IModelDecorationsChangedEvent } from 'vs/editor/common/model/textModelEvents';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
@@ -82,7 +80,7 @@ class DecorationsManager implements IDisposable {
}
private _addDecorations(reference: FileReferences): void {
this._callOnModelChange.push(this._editor.getModel().onDidChangeDecorations((event) => this._onDecorationChanged(event)));
this._callOnModelChange.push(this._editor.getModel().onDidChangeDecorations((event) => this._onDecorationChanged()));
this._editor.changeDecorations(accessor => {
@@ -108,21 +106,20 @@ class DecorationsManager implements IDisposable {
});
}
private _onDecorationChanged(event: IModelDecorationsChangedEvent): void {
const changedDecorations = event.changedDecorations,
toRemove: string[] = [];
private _onDecorationChanged(): void {
const toRemove: string[] = [];
for (let i = 0, len = changedDecorations.length; i < len; i++) {
let reference = this._decorations.get(changedDecorations[i]);
if (!reference) {
continue;
this._decorations.forEach((reference, decorationId) => {
const newRange = this._editor.getModel().getDecorationRange(decorationId);
if (!newRange) {
return;
}
const newRange = this._editor.getModel().getDecorationRange(changedDecorations[i]);
let ignore = false;
if (Range.equalsRange(newRange, reference.range)) {
continue;
return;
} else if (Range.spansMultipleLines(newRange)) {
ignore = true;
@@ -138,11 +135,11 @@ class DecorationsManager implements IDisposable {
if (ignore) {
this._decorationIgnoreSet.add(reference.id);
toRemove.push(changedDecorations[i]);
toRemove.push(decorationId);
} else {
reference.range = newRange;
}
}
});
this._editor.changeDecorations((accessor) => {
for (let i = 0, len = toRemove.length; i < len; i++) {
@@ -358,11 +355,15 @@ class FileReferencesTemplate {
const parent = document.createElement('div');
dom.addClass(parent, 'reference-file');
container.appendChild(parent);
this.file = new FileLabel(parent, URI.parse('no:file'), this._contextService, this._environmentService);
this.badge = new CountBadge(parent);
this.badge = new CountBadge($('.count').appendTo(parent).getHTMLElement());
const styler = attachBadgeStyler(this.badge, themeService);
this.dispose = () => styler.dispose();
this.dispose = () => {
this.file.dispose();
styler.dispose();
};
}
set(element: FileReferences) {
@@ -584,8 +585,6 @@ export class ReferenceWidget extends PeekViewWidget {
this._applyTheme(_themeService.getTheme());
this._callOnDispose.push(_themeService.onThemeChange(this._applyTheme.bind(this)));
this._instantiationService = this._instantiationService.createChild(new ServiceCollection([IPeekViewService, this]));
this.create();
}