Initial Commit

pull/2/head
Felix Becker 2016-08-25 17:55:00 +02:00
commit 564e6e12af
17 changed files with 331 additions and 0 deletions

17
.editorconfig Normal file
View File

@ -0,0 +1,17 @@
[*]
insert_final_newline = true
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
[*.{json,yml}]
indent_size = 2
[composer.json]
indent_size = 4
[*.md]
trim_trailing_whitespace = false

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
out/
node_modules/
vendor/
composer.lock

10
.travis.yml Normal file
View File

@ -0,0 +1,10 @@
language: node_js
node_js:
- '5.10.0'
install:
- npm install
script:
- npm run lint

36
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,36 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out/test"
},
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch"
}
]
}

10
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
}

37
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,37 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": [
"run",
"--loglevel",
"silent"
],
"tasks": [
{
"taskName": "compile",
"isBuildCommand": true,
"problemMatcher": "$tsc"
},
{
"taskName": "watch",
// The tsc compiler is started in watching mode
"isWatching": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
]
}

9
.vscodeignore Normal file
View File

@ -0,0 +1,9 @@
.vscode/**
typings/**
out/test/**
test/**
src/**
**/*.map
.gitignore
tsconfig.json
tslint.json

24
README.md Normal file
View File

@ -0,0 +1,24 @@
# PHP IntelliSense
> **⚠ Work In Progress**
[![Latest Release](https://vsmarketplacebadge.apphb.com/version-short/felixfbecker.php-intellisense.svg)](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense) [![Installs](https://vsmarketplacebadge.apphb.com/installs/felixfbecker.php-intellisense.svg)](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense) [![Rating](https://vsmarketplacebadge.apphb.com/rating-short/felixfbecker.php-intellisense.svg)](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense) [![Build Status](https://travis-ci.org/felixfbecker/vscode-php-intellisense.svg?branch=master)](https://travis-ci.org/felixfbecker/vscode-php-intellisense) [![Dependency Status](https://gemnasium.com/felixfbecker/vscode-php-intellisense.svg)](https://gemnasium.com/felixfbecker/vscode-php-intellisense) [![Gitter](https://badges.gitter.im/felixfbecker/vscode-php-intellisense.svg)](https://gitter.im/felixfbecker/vscode-php-intellisense?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Advanced PHP IntelliSense for Visual Studio Code.
In opposite to the included PHP IntelliSense and other PHP extensions, this uses an AST to parse the source code
instead of relying on naive regular expression parsing.
## Features
- Find all symbols
## Todo
- Autocompletion
- Rename
- Goto definition
- Format document
- Hover
- Follow composer autoloading
## Contributing
This is just the VS Code extension that spawns the actual language server. The language server itself is implemented purely in PHP [in its own repository](https://github.com/felixfbecker/php-language-server).

7
composer.json Normal file
View File

@ -0,0 +1,7 @@
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"felixfbecker/language-server": "^2.0"
}
}

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "php-intellisense",
"displayName": "PHP IntelliSense",
"description": "Advanced Autocompletion and Refactoring support for PHP",
"publisher": "felixfbecker",
"author": "Felix Becker <felix.b@outlook.com>",
"license": "ISC",
"private": true,
"version": "0.0.1",
"engines": {
"vscode": "^1.4.0"
},
"categories": [
"Languages"
],
"activationEvents": [
"onLanguage:php"
],
"main": "./out/extension",
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"lint": "tslint -c tslint.json \"src/**/*.ts\""
},
"devDependencies": {
"tslint": "^3.15.1",
"typescript": "^1.8.10",
"vscode": "^0.11.17"
},
"dependencies": {
"vscode-languageclient": "^2.4.2-next.10"
}
}

36
src/extension.ts Normal file
View File

@ -0,0 +1,36 @@
'use strict';
import * as path from 'path';
import { ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient';
export function activate(context: ExtensionContext) {
// The server is implemented in PHP
const serverPath = context.asAbsolutePath(path.join('vendor', 'felixfbecker', 'language-server', 'bin', 'php-language-server.php'));
const serverOptions: ServerOptions = {
command: 'php',
args: [serverPath]
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for php documents
documentSelector: ['php']
// synchronize: {
// // Synchronize the setting section 'php' to the server
// configurationSection: 'php',
// // Notify the server about file changes to composer.json files contain in the workspace
// fileEvents: workspace.createFileSystemWatcher('**/composer.json')
// }
};
// Create the language client and start the client.
const disposable = new LanguageClient('PHP Language Client', serverOptions, clientOptions).start();
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
}

View File

@ -0,0 +1,22 @@
//
// Note: This example test is leveraging the Mocha test framework.
// Please refer to their documentation on https://mochajs.org/ for help.
//
// The module 'assert' provides assertion methods from node
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
// import * as vscode from 'vscode';
// import * as myExtension from '../extension';
// Defines a Mocha test suite to group tests of similar kind together
suite('Extension Tests', () => {
// Defines a Mocha unit test
test('Something 1', () => {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
});
});

22
src/test/index.ts Normal file
View File

@ -0,0 +1,22 @@
//
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
//
// This file is providing the test runner to use when running extension tests.
// By default the test runner in use is Mocha based.
//
// You can provide your own test runner if you want to override it by exporting
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.
const testRunner = require('vscode/lib/testrunner');
// You can directly control Mocha options by uncommenting the following lines
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
testRunner.configure({
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true // colored output from test results
});
module.exports = testRunner;

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "out",
"noLib": true,
"sourceMap": true,
"rootDir": "src"
},
"exclude": [
"node_modules"
]
}

47
tslint.json Normal file
View File

@ -0,0 +1,47 @@
{
"rules": {
"class-name": true,
"comment-format": [true, "check-space"],
"indent": [true, "spaces"],
"no-duplicate-variable": true,
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-var-keyword": true,
"one-line": [true, "check-catch", "check-finally", "check-else", "check-open-brace", "check-whitespace"],
"quotemark": [true, "single"],
"semicolon": [true, "always"],
"triple-equals": [true, "allow-null-check"],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
],
"variable-name": [true, "ban-keywords"],
"whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"],
"jsdoc-format": true,
"no-consecutive-blank-lines": true,
"one-variable-per-declaration": [true, "ignore-for-loop"],
"curly": true,
"no-empty": true,
"no-duplicate-key": true,
"no-unreachable": true,
"no-unused-expression": true,
"no-unused-variable": [true],
"eofline": true,
"trailing-comma": [true, {"singleline": "never", "multiline": "never"}],
"align": [true, "parameters", "statements"]
}
}

1
typings/node.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference path="../node_modules/vscode/typings/node.d.ts" />

1
typings/vscode-typings.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference path="../node_modules/vscode/typings/index.d.ts" />