mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
[php] missing user code auto-complete on 0.10.1 #161
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import assert = require('assert');
|
||||
import {CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Range, Position, Uri} from 'vscode';
|
||||
import {CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Range, Position, Uri, workspace, window} from 'vscode';
|
||||
import PHPCompletionItemProvider from '../features/completionItemProvider';
|
||||
import HoverProvider from '../features/hoverProvider';
|
||||
import SignatureHelpProvider from '../features/signatureHelpProvider';
|
||||
@@ -7,14 +7,19 @@ import SignatureHelpProvider from '../features/signatureHelpProvider';
|
||||
|
||||
var phpCompletionProvider = new PHPCompletionItemProvider();
|
||||
|
||||
var testSuggestionsFor = function(value:string, stringBefore:string):Promise<CompletionItem[]> {
|
||||
var uri = new Uri();
|
||||
var doc = new TextDocument(uri, value.split('\n'), '\n', 'php', 1, false);
|
||||
|
||||
var idx = stringBefore ? value.indexOf(stringBefore) + stringBefore.length : 0;
|
||||
var position = new Position(0, idx);
|
||||
|
||||
return phpCompletionProvider.provideCompletionItems(doc, position, null);
|
||||
var testSuggestionsFor = function(value:string, stringBefore:string):Thenable<CompletionItem[]> {
|
||||
return workspace.openTextDocument(Uri.parse("untitled:/foo/new.js")).then(document => {
|
||||
return window.showTextDocument(document).then(textEditor => {
|
||||
return textEditor.edit(editBuilder => {
|
||||
var lastLineLength = document.lineAt(document.lineCount - 1).text.length;
|
||||
editBuilder.replace(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(textEditor.document.lineCount - 1, lastLineLength)), value);
|
||||
}).then(() => {
|
||||
var idx = stringBefore ? value.indexOf(stringBefore) + stringBefore.length : 0;
|
||||
var position = new Position(0, idx);
|
||||
return phpCompletionProvider.provideCompletionItems(document, position, null);
|
||||
})
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
var assertSuggestion= function(completions:CompletionItem[], label:string, kind: CompletionItemKind) {
|
||||
@@ -25,9 +30,9 @@ var assertSuggestion= function(completions:CompletionItem[], label:string, kind:
|
||||
assert.equal(entries[0].kind, kind);
|
||||
};
|
||||
|
||||
suite("Extension Tests", () => {
|
||||
suite("PHP", () => {
|
||||
|
||||
test("Something 1", (testDone:(err?:any) => void) => {
|
||||
test("Intellisense", (testDone:(err?:any) => void) => {
|
||||
Promise.all([
|
||||
testSuggestionsFor('<?php ', 'php ').then(completions => {
|
||||
assertSuggestion(completions, '__CLASS__', CompletionItemKind.Field);
|
||||
|
||||
Reference in New Issue
Block a user