Merge branch 'master' into joh/registerTextDocumentProvider

This commit is contained in:
Johannes Rieken 2016-01-07 17:16:00 +01:00
commit 5923afa982
10 changed files with 93 additions and 85 deletions

View file

@ -14,6 +14,8 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise<CompletionItem[]> {
let result: CompletionItem[] = [];
var range = document.getWordRangeAtPosition(position);
var prefix = range ? document.getText(range) : '';
var added : any = {};
var createNewProposal = function(kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry) : CompletionItem {
@ -30,39 +32,45 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
return proposal;
};
var matches = (name:string) => {
return prefix.length === 0 || name.length > prefix.length && name.substr(0, prefix.length) === prefix;
}
for (var name in phpGlobals.globalvariables) {
if (phpGlobals.globalvariables.hasOwnProperty(name)) {
if (phpGlobals.globalvariables.hasOwnProperty(name) && matches(name)) {
added[name] = true;
result.push(createNewProposal(CompletionItemKind.Variable, name, phpGlobals.globalvariables[name]));
}
}
for (var name in phpGlobals.globalfunctions) {
if (phpGlobals.globalfunctions.hasOwnProperty(name)) {
if (phpGlobals.globalfunctions.hasOwnProperty(name) && matches(name)) {
added[name] = true;
result.push(createNewProposal(CompletionItemKind.Function, name, phpGlobals.globalfunctions[name]));
}
}
for (var name in phpGlobals.compiletimeconstants) {
if (phpGlobals.compiletimeconstants.hasOwnProperty(name)) {
if (phpGlobals.compiletimeconstants.hasOwnProperty(name) && matches(name)) {
added[name] = true;
result.push(createNewProposal(CompletionItemKind.Field, name, phpGlobals.compiletimeconstants[name]));
}
}
for (var name in phpGlobals.keywords) {
if (phpGlobals.keywords.hasOwnProperty(name)) {
if (phpGlobals.keywords.hasOwnProperty(name) && matches(name)) {
added[name] = true;
result.push(createNewProposal(CompletionItemKind.Keyword, name, phpGlobals.keywords[name]));
}
}
var text = document.getText();
var variableMatch = /\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/g;
var match : RegExpExecArray = null;
while (match = variableMatch.exec(text)) {
var word = match[0];
if (!added[word]) {
added[word] = true;
result.push(createNewProposal(CompletionItemKind.Variable, word, null));
if (matches('$')) {
var variableMatch = /\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/g;
var match : RegExpExecArray = null;
while (match = variableMatch.exec(text)) {
var word = match[0];
if (!added[word]) {
added[word] = true;
result.push(createNewProposal(CompletionItemKind.Variable, word, null));
}
}
}
var functionMatch = /function\s+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*\(/g;

View file

@ -0,0 +1,25 @@
{
"name": "theme-colorful-defaults",
"displayName": "Colorful Default Themes - Please provide feedback in issue 1849",
"description": "The default VS Code Light and Dark themes with a touch of color. We are considering adding these to the default themes in the January release. Please provide feedback in issue 1849.",
"categories": [ "Themes" ],
"version": "0.1.5",
"publisher": "aeschli",
"engines": { "vscode": "*" },
"contributes": {
"themes": [
{
"label": "Dark+",
"description": "Default dark theme with a touch of color",
"uiTheme": "vs-dark",
"path": "./themes/dark_plus.tmTheme"
},
{
"label": "Light+",
"description": "Default light theme with a touch of color",
"uiTheme": "vs",
"path": "./themes/light_plus.tmTheme"
}
]
}
}

View file

@ -1,22 +0,0 @@
{
"name": "theme-dark-plus",
"version": "0.1.0",
"publisher": "vscode",
"engines": { "vscode": "*" },
"contributes": {
"themes": [
{
"label": "Dark+",
"description": "Dark theme with a touch of color",
"uiTheme": "vs-dark",
"path": "./themes/dark_plus.tmTheme"
},
{
"label": "Light+",
"description": "Light theme with a touch of color",
"uiTheme": "vs",
"path": "./themes/light_plus.tmTheme"
}
]
}
}

View file

@ -14,8 +14,6 @@
.monaco-editor.vs .token.constant { color: #dd0000; }
.monaco-editor.vs .token.string { color: #A31515; }
.monaco-editor.vs .token.string.escape { color: #A31515; }
.monaco-editor.vs .token.comment { color: #008000; }
.monaco-editor.vs .token.comment.shebang { color: #929292; }
.monaco-editor.vs .token.literal { color: #000000; }
.monaco-editor.vs .token.literal.string { color: #A31515; }
.monaco-editor.vs .token.literal.hex { color: #e07000; }
@ -83,7 +81,6 @@
/* VSXML */
.monaco-editor.vs .token.vs { color: #006400; }
.monaco-editor.vs .token.comment.vs { color: #aeb9ae; }
.monaco-editor.vs .token.tag.vs { color: #aeb9ae; }
.monaco-editor.vs .token.attribute.name.vs { color: #aeb9ae; }
.monaco-editor.vs .token.attribute.value.vs { color: #2c51cc; }
@ -109,9 +106,6 @@
.monaco-editor.vs-dark .token.constant { color: #dd0000; }
.monaco-editor.vs-dark .token.string { color: #CE9178; }
.monaco-editor.vs-dark .token.string.escape { color: #CE9178; }
.monaco-editor.vs-dark .token.comment { color: #929292; }
.monaco-editor.vs-dark .token.comment.shebang { color: #929292; }
.monaco-editor.vs-dark .token.comment.doc { color: #608B4E; }
.monaco-editor.vs-dark .token.literal { color: #e00000; }
.monaco-editor.vs-dark .token.literal.hex { color: #e07000; }
.monaco-editor.vs-dark .token.number { color: #B5CEA8; }
@ -204,9 +198,6 @@
.monaco-editor.hc-black .token.constant { color: #dd0000; }
.monaco-editor.hc-black .token.string { color: #CE9178; }
.monaco-editor.hc-black .token.string.escape { color: #CE9178; }
.monaco-editor.hc-black .token.comment { color: #008000; }
.monaco-editor.hc-black .token.comment.shebang { color: #929292; }
.monaco-editor.hc-black .token.comment.doc { color: #608B4E; }
.monaco-editor.hc-black .token.literal { color: #FFFFFF; }
.monaco-editor.hc-black .token.literal.hex { color: #FFFFFF; }
@ -301,18 +292,7 @@
.monaco-editor.vs .token.builtin.function { color: #0000FF; }
.monaco-editor.vs .token.comment,
.monaco-editor.vs .token.comment.block,
.monaco-editor.vs .token.comment.block.documentation,
.monaco-editor.vs .token.comment.line { color: #008000; }
/*
.monaco-editor.vs .token.comment.line.documentation
.monaco-editor.vs .token.comment.line.double-slash
.monaco-editor.vs .token.comment.line.double-dash
.monaco-editor.vs .token.comment.line.number-sign
.monaco-editor.vs .token.comment.line.percentage
.monaco-editor.vs .token.comment.line.character
*/
.monaco-editor.vs .token.comment { color: #008000; }
.monaco-editor.vs .token.constant { color: #dd0000; }
.monaco-editor.vs .token.constant.language { color: #0000FF; }
@ -441,15 +421,7 @@
.monaco-editor.vs-dark .token.builtin.function { color: #569CD6; }
.monaco-editor.vs-dark .token.comment,
.monaco-editor.vs-dark .token.comment.block,
.monaco-editor.vs-dark .token.comment.block.documentation,
.monaco-editor.vs-dark .token.comment.line { color: #608B4E; }
/*.monaco-editor.vs-dark .token.comment.line.double-slash
.monaco-editor.vs-dark .token.comment.line.double-dash
.monaco-editor.vs-dark .token.comment.line.number-sign
.monaco-editor.vs-dark .token.comment.line.percentage
.monaco-editor.vs-dark .token.comment.line.character*/
.monaco-editor.vs-dark .token.comment { color: #608B4E; }
.monaco-editor.vs-dark .token.constant { color: #569CD6; }
.monaco-editor.vs-dark .token.constant.language { color: #569CD6; }
@ -578,15 +550,7 @@
.monaco-editor.hc-black .token.builtin.function { color: #569CD6; }
.monaco-editor.hc-black .token.comment,
.monaco-editor.hc-black .token.comment.block,
.monaco-editor.hc-black .token.comment.block.documentation,
.monaco-editor.hc-black .token.comment.line { color: #608B4E; }
/*.monaco-editor.hc-black .token.comment.line.double-slash
.monaco-editor.hc-black .token.comment.line.double-dash
.monaco-editor.hc-black .token.comment.line.number-sign
.monaco-editor.hc-black .token.comment.line.percentage
.monaco-editor.hc-black .token.comment.line.character*/
.monaco-editor.hc-black .token.comment { color: #608B4E; }
.monaco-editor.hc-black .token.constant { color: #569CD6; }
.monaco-editor.hc-black .token.constant.language { color: #569CD6; }

View file

@ -23,6 +23,7 @@ interface Entry<T> {
export default class LanguageFeatureRegistry<T> {
private _clock: number = 0;
private _entries: Entry<T>[] = [];
private _onDidChange = new Emitter<number>();
private _supportName: string;
@ -41,7 +42,7 @@ export default class LanguageFeatureRegistry<T> {
selector,
provider,
_score: -1,
_time: Date.now()
_time: this._clock++
};
this._entries.push(entry);
@ -129,7 +130,7 @@ export default class LanguageFeatureRegistry<T> {
selector: undefined,
provider: model.getMode()[this._supportName],
_score: .5,
_time: 0
_time: -1
};
supportIndex = ~binarySearch(this._entries, supportEntry, LanguageFeatureRegistry._compareByScoreAndTime);
}

View file

@ -6,27 +6,42 @@
import 'vs/css!../browser/media/breakpointWidget';
import async = require('vs/base/common/async');
import errors = require('vs/base/common/errors');
import { CommonKeybindings } from 'vs/base/common/keyCodes';
import { CommonKeybindings, KeyCode } from 'vs/base/common/keyCodes';
import platform = require('vs/base/common/platform');
import lifecycle = require('vs/base/common/lifecycle');
import dom = require('vs/base/browser/dom');
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
import editorbrowser = require('vs/editor/browser/editorBrowser');
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService, IKeybindingContextKey } from 'vs/platform/keybinding/common/keybindingService';
import debug = require('vs/workbench/parts/debug/common/debug');
const $ = dom.emmet;
const CONTEXT_BREAKPOINT_WIDGET_VISIBLE = 'breakpointWidgetVisible';
const CLOSE_BREAKPOINT_WIDGET_COMMAND_ID = 'closeBreakpointWidget';
export class BreakpointWidget extends ZoneWidget {
public static INSTANCE: BreakpointWidget;
private inputBox: InputBox;
private toDispose: lifecycle.IDisposable[];
private breakpointWidgetVisible: IKeybindingContextKey<boolean>;
constructor(editor: editorbrowser.ICodeEditor, private lineNumber: number,
@IContextViewService private contextViewService: IContextViewService,
@debug.IDebugService private debugService: debug.IDebugService
@debug.IDebugService private debugService: debug.IDebugService,
@IKeybindingService keybindingService: IKeybindingService
) {
super(editor, { showFrame: true, showArrow: false });
this.toDispose = [];
this.create();
this.breakpointWidgetVisible = keybindingService.createKey(CONTEXT_BREAKPOINT_WIDGET_VISIBLE, false);
this.breakpointWidgetVisible.set(true);
BreakpointWidget.INSTANCE = this;
}
public fillContainer(container: HTMLElement): void {
@ -36,15 +51,16 @@ export class BreakpointWidget extends ZoneWidget {
const inputBoxContainer = dom.append(container, $('.inputBoxContainer'));
this.inputBox = new InputBox(inputBoxContainer, this.contextViewService, {
placeholder: `The breakpoint on line ${ this.lineNumber } will only stop if this condition is true`
placeholder: `Breakpoint on line ${ this.lineNumber } will only stop if this condition is true. 'Enter' to accept, 'esc' to cancel.`
});
this.toDispose.push(this.inputBox);
dom.addClass(this.inputBox.inputElement, platform.isWindows ? 'windows' : platform.isMacintosh ? 'mac' : 'linux');
this.inputBox.value = (breakpoint && breakpoint.condition) ? breakpoint.condition : '';
// Due to an electron bug we have to do the timeout, otherwise we do not get focus
setTimeout(() => this.inputBox.focus(), 0);
let disposed = false;
const toDispose: [lifecycle.IDisposable] = [this.inputBox, this];
const wrapUp = async.once<any, void>((success: boolean) => {
if (!disposed) {
disposed = true;
@ -64,20 +80,29 @@ export class BreakpointWidget extends ZoneWidget {
this.debugService.toggleBreakpoint(raw).done(null, errors.onUnexpectedError);
}
lifecycle.disposeAll(toDispose);
this.dispose();
}
});
toDispose.push(dom.addStandardDisposableListener(this.inputBox.inputElement, 'keydown', (e: dom.IKeyboardEvent) => {
this.toDispose.push(dom.addStandardDisposableListener(this.inputBox.inputElement, 'keydown', (e: dom.IKeyboardEvent) => {
const isEscape = e.equals(CommonKeybindings.ESCAPE);
const isEnter = e.equals(CommonKeybindings.ENTER);
if (isEscape || isEnter) {
wrapUp(isEnter);
}
}));
}
toDispose.push(dom.addDisposableListener(this.inputBox.inputElement, 'blur', () => {
wrapUp(true);
}));
public dispose(): void {
super.dispose();
this.breakpointWidgetVisible.reset();
BreakpointWidget.INSTANCE = undefined;
lifecycle.disposeAll(this.toDispose);
}
}
CommonEditorRegistry.registerEditorCommand(CLOSE_BREAKPOINT_WIDGET_COMMAND_ID, CommonEditorRegistry.commandWeight(8), { primary: KeyCode.Escape, }, false, CONTEXT_BREAKPOINT_WIDGET_VISIBLE, (ctx, editor, args) => {
if (BreakpointWidget.INSTANCE) {
BreakpointWidget.INSTANCE.dispose();
}
});

View file

@ -846,6 +846,9 @@ export class BreakpointsRenderer implements tree.IRenderer {
data.filePath.textContent = labels.getPathLabel(paths.dirname(breakpoint.source.uri.fsPath), this.contextService);
data.checkbox.checked = breakpoint.enabled;
data.actionBar.context = breakpoint;
if (breakpoint.condition) {
data.breakpoint.title = breakpoint.condition;
}
}
public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {

View file

@ -424,8 +424,12 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
}
public editBreakpoint(editor: editorbrowser.ICodeEditor, lineNumber: number): Promise {
const breakpointWidget = this.instantiationService.createInstance(BreakpointWidget, editor, lineNumber);
breakpointWidget.show({ lineNumber, column: 1 }, 2);
if (BreakpointWidget.INSTANCE) {
BreakpointWidget.INSTANCE.dispose();
}
this.instantiationService.createInstance(BreakpointWidget, editor, lineNumber);
BreakpointWidget.INSTANCE.show({ lineNumber, column: 1 }, 2);
return Promise.as(true);
}