diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..864d171 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,18 @@ + + diff --git a/.gitignore b/.gitignore index 70fdc89..f146fce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -out/ node_modules/ +out/ vendor/ -composer.lock -typings/ +.DS_Store +package-lock.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml index e5246ec..3b44f2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,41 @@ language: php php: - - '7.0' + - '7.0' cache: directories: - - $HOME/.npm - - $HOME/.composer/cache + - $HOME/.npm + - $HOME/.composer/cache before_install: - - nvm install 6.5.0 - - nvm use 6.5.0 + - nvm install 8 + - nvm use 8 install: - - npm install - - composer install --prefer-dist + - npm install script: - - npm run lint - - npm run compile + - npm run lint + - npm run build -after_success: - # If the build was triggered by a tag, publish the new version - - 'if [[ $TRAVIS_TAG == v* ]]; then vsce publish -p $VSCE_TOKEN; fi' +jobs: + include: + - stage: test + - stage: release + php: '7.0' + install: + - npm install + - composer install --prefer-dist --no-interaction --optimize-autoloader + script: + - npm run build + - npm run semantic-release + +stages: + - test + - name: release + if: branch = master AND type = push AND fork = false + +branches: + only: + - master diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5801050..bb7f6a3 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,37 +1,21 @@ -// 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" - ], + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", "tasks": [ { - "taskName": "compile", - "isBuildCommand": true, - "problemMatcher": "$tsc" + "type": "npm", + "script": "build", + "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" + "type": "npm", + "script": "watch", + "problemMatcher": [ + "$tsc-watch" + ] } ] } diff --git a/.vscodeignore b/.vscodeignore index d09f859..dd51dc5 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,9 +1,22 @@ +.github/** .vscode/** -typings/** +images/** +!images/logo.png out/test/** -test/** src/** +vendor/jetbrains/phpstorm-stubs/** +vendor/bin/** +**/.DS_Store +**/.editorconfig +**/.gitignore +**/.npmrc +**/.styleci.yml +**/.travis.yml +**/*.d.ts **/*.map -.gitignore -tsconfig.json -tslint.json +**/appveyor.yml +**/dependencies.yml +**/jshintrc +**/phpunit.xml.dist +**/tsconfig.json +**/tslint.json diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..464f2d9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ + +# See [GitHub releases](https://github.com/felixfbecker/vscode-php-intellisense/releases) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..089c294 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Felix Becker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 0956111..36c93ab 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # PHP IntelliSense -[![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) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.0-8892BF.svg)](https://php.net/) [![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) +[![vs marketplace](https://img.shields.io/vscode-marketplace/v/felixfbecker.php-intellisense.svg?label=vs%20marketplace)](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense) [![downloads](https://img.shields.io/vscode-marketplace/d/felixfbecker.php-intellisense.svg)](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense) [![rating](https://img.shields.io/vscode-marketplace/r/felixfbecker.php-intellisense.svg)](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense) [![build](https://travis-ci.org/felixfbecker/vscode-php-intellisense.svg?branch=master)](https://travis-ci.org/felixfbecker/vscode-php-intellisense) [![php: >=7.0.0](https://img.shields.io/badge/php->=7.0-8892BF.svg)](https://php.net/) [![chat: on 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) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) Advanced PHP IntelliSense for Visual Studio Code. -**Note: 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), all features need to be implemented there and all issues should be reported there.** +**Note: 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), all features need to be implemented there and all issues should be reported there. You do NOT need to install it manually though, it is bundled in this extension.** ## Installation -You need at least PHP 7 installed for the extension to work. You can either add it to your PATH or set the `php.executablePath` setting. +You need at least PHP 7 installed for the extension to work. You can either add it to your PATH or set the `php.executablePath` setting. I recommend to disable VS Code's built-in PHP IntelliSense by setting `php.suggest.basic` to `false` to avoid duplicate suggestions. @@ -17,6 +17,9 @@ I recommend to disable VS Code's built-in PHP IntelliSense by setting `php.sugge ### Completion ![Completion search demo](images/completion.gif) +### Signature Help +![Signature help demo](images/signatureHelp.gif) + ### Workspace symbol search ![Workspace symbol search demo](images/workspaceSymbol.gif) @@ -34,12 +37,14 @@ I recommend to disable VS Code's built-in PHP IntelliSense by setting `php.sugge ### Find all symbols ![Find all symbols demo](images/documentSymbol.gif) -### Format code -![Format code demo](images/formatDocument.gif) - ### Column-accurate error reporting ![Error reporting demo](images/publishDiagnostics.png) +### Code style linting +Please use a dedicated extension like [PHP CodeSniffer](https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs). + +### Format code +Please use a dedicated extension like [PHP CS Fixer](https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer). ## Todo - Rename @@ -49,9 +54,9 @@ I recommend to disable VS Code's built-in PHP IntelliSense by setting `php.sugge Clone whole repository and in root directory execute: ```bash -composer install +composer install npm install -npm run compile +npm run build code . ``` The last command will open the folder in VS Code. Hit `F5` to launch an Extension Development Host with the extension. diff --git a/composer.json b/composer.json index fd3c090..d3dc791 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "felixfbecker/language-server": "^4.3.3" + "felixfbecker/language-server": "^5.4" }, "scripts": { "parse-stubs": "LanguageServer\\ComposerScripts::parseStubs", diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..c395bfc --- /dev/null +++ b/composer.lock @@ -0,0 +1,748 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "8d7a96cebb3857223787685e8f9a61be", + "packages": [ + { + "name": "composer/xdebug-handler", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "e1809da56ce1bd1b547a752936817341ac244d8e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/e1809da56ce1bd1b547a752936817341ac244d8e", + "reference": "e1809da56ce1bd1b547a752936817341ac244d8e", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2018-08-16T10:54:23+00:00" + }, + { + "name": "felixfbecker/advanced-json-rpc", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", + "reference": "29f1d8c2c17f8c04f9768d382b72aeeb0715ebb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/29f1d8c2c17f8c04f9768d382b72aeeb0715ebb8", + "reference": "29f1d8c2c17f8c04f9768d382b72aeeb0715ebb8", + "shasum": "" + }, + "require": { + "netresearch/jsonmapper": "^1.0", + "php": ">=7.0", + "phpdocumentor/reflection-docblock": "^4.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "AdvancedJsonRpc\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "A more advanced JSONRPC implementation", + "time": "2017-10-28T21:26:16+00:00" + }, + { + "name": "felixfbecker/language-server", + "version": "v5.4.1", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-language-server.git", + "reference": "fe33c8cd7fb962af6853a8e99aeb47d9881d13aa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-language-server/zipball/fe33c8cd7fb962af6853a8e99aeb47d9881d13aa", + "reference": "fe33c8cd7fb962af6853a8e99aeb47d9881d13aa", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.0", + "felixfbecker/advanced-json-rpc": "^3.0.0", + "jetbrains/phpstorm-stubs": "dev-master", + "microsoft/tolerant-php-parser": "0.0.*", + "netresearch/jsonmapper": "^1.0", + "php": "^7.0", + "phpdocumentor/reflection-docblock": "^4.0.0", + "psr/log": "^1.0", + "sabre/event": "^5.0", + "sabre/uri": "^2.0", + "webmozart/glob": "^4.1", + "webmozart/path-util": "^2.3" + }, + "require-dev": { + "phpunit/phpunit": "^6.3", + "squizlabs/php_codesniffer": "^3.1" + }, + "bin": [ + "bin/php-language-server.php" + ], + "type": "library", + "autoload": { + "psr-4": { + "LanguageServer\\": "src/" + }, + "files": [ + "src/utils.php", + "src/FqnUtilities.php", + "src/ParserHelpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "PHP Implementation of the Visual Studio Code Language Server Protocol", + "keywords": [ + "autocompletion", + "code", + "intellisense", + "language", + "microsoft", + "php", + "refactor", + "server", + "studio", + "visual" + ], + "time": "2018-04-26T22:53:21+00:00" + }, + { + "name": "jetbrains/phpstorm-stubs", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/JetBrains/phpstorm-stubs.git", + "reference": "435257758651096093209ff56fa0ae1a6e63ec56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/435257758651096093209ff56fa0ae1a6e63ec56", + "reference": "435257758651096093209ff56fa0ae1a6e63ec56", + "shasum": "" + }, + "require-dev": { + "nikic/php-parser": "v4.0.1", + "phpdocumentor/reflection-docblock": "^4.3", + "phpunit/phpunit": "7.1.4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "PHP runtime & extensions header files for PhpStorm", + "homepage": "https://www.jetbrains.com/phpstorm", + "keywords": [ + "autocomplete", + "code", + "inference", + "inspection", + "jetbrains", + "phpstorm", + "stubs", + "type" + ], + "time": "2018-08-13T13:39:18+00:00" + }, + { + "name": "microsoft/tolerant-php-parser", + "version": "v0.0.13", + "source": { + "type": "git", + "url": "https://github.com/Microsoft/tolerant-php-parser.git", + "reference": "89ade271e639e0612deeccb0555f13c2224ecf84" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Microsoft/tolerant-php-parser/zipball/89ade271e639e0612deeccb0555f13c2224ecf84", + "reference": "89ade271e639e0612deeccb0555f13c2224ecf84", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Microsoft\\PhpParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rob Lourens", + "email": "roblou@microsoft.com" + } + ], + "description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios", + "time": "2018-08-07T04:52:21+00:00" + }, + { + "name": "netresearch/jsonmapper", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/cweiske/jsonmapper.git", + "reference": "3868fe1128ce1169228acdb623359dca74db5ef3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/3868fe1128ce1169228acdb623359dca74db5ef3", + "reference": "3868fe1128ce1169228acdb623359dca74db5ef3", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "JsonMapper": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@cweiske.de", + "homepage": "http://github.com/cweiske/jsonmapper/", + "role": "Developer" + } + ], + "description": "Map nested JSON structures onto PHP classes", + "time": "2017-11-28T21:30:01+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-30T07:14:17+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "sabre/event", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/event.git", + "reference": "f5cf802d240df1257866d8813282b98aee3bc548" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/event/zipball/f5cf802d240df1257866d8813282b98aee3bc548", + "reference": "f5cf802d240df1257866d8813282b98aee3bc548", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": ">=6", + "sabre/cs": "~1.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Sabre\\Event\\": "lib/" + }, + "files": [ + "lib/coroutine.php", + "lib/Loop/functions.php", + "lib/Promise/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "sabre/event is a library for lightweight event-based programming", + "homepage": "http://sabre.io/event/", + "keywords": [ + "EventEmitter", + "async", + "coroutine", + "eventloop", + "events", + "hooks", + "plugin", + "promise", + "reactor", + "signal" + ], + "time": "2018-03-05T13:55:47+00:00" + }, + { + "name": "sabre/uri", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/uri.git", + "reference": "a42126042c7dcb53e2978dadb6d22574d1359b4c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/a42126042c7dcb53e2978dadb6d22574d1359b4c", + "reference": "a42126042c7dcb53e2978dadb6d22574d1359b4c", + "shasum": "" + }, + "require": { + "php": ">=7" + }, + "require-dev": { + "phpunit/phpunit": "^6.0", + "sabre/cs": "~1.0.0" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\Uri\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "Functions for making sense out of URIs.", + "homepage": "http://sabre.io/uri/", + "keywords": [ + "rfc3986", + "uri", + "url" + ], + "time": "2017-02-20T20:02:35+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2018-01-29T19:49:41+00:00" + }, + { + "name": "webmozart/glob", + "version": "4.1.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/glob.git", + "reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/glob/zipball/3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe", + "reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe", + "shasum": "" + }, + "require": { + "php": "^5.3.3|^7.0", + "webmozart/path-util": "^2.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1", + "symfony/filesystem": "^2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Glob\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A PHP implementation of Ant's glob.", + "time": "2015-12-29T11:14:33+00:00" + }, + { + "name": "webmozart/path-util", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/path-util.git", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "webmozart/assert": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\PathUtil\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", + "time": "2015-12-17T08:42:14+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/dependencies.yml b/dependencies.yml new file mode 100644 index 0000000..853dffa --- /dev/null +++ b/dependencies.yml @@ -0,0 +1,35 @@ +collectors: + +- type: js-npm + path: / + actors: + # pull requests for new major versions + - type: js-npm + versions: "Y.0.0" + settings: + # these updates should generally not have an effect on users + commit_message_prefix: "chore: " + +# receive pull requests to update composer.lock for any update to the language server or dependencies of it +# after merging, depending on whether it was a patch or feature update, +# semantic-release will bundle a new patch or feature version of the extension +- type: php-composer + path: / + settings: + collect_transitive: true + actors: + + - type: php-composer + versions: "L.L.Y" + settings: + commit_message_prefix: "fix: " + + - type: php-composer + versions: "L.Y.0" + settings: + commit_message_prefix: "feat: " + + - type: php-composer + versions: "Y.0.0" + settings: + commit_message_prefix: "chore: " diff --git a/images/formatDocument.gif b/images/formatDocument.gif deleted file mode 100644 index d8e49fe..0000000 Binary files a/images/formatDocument.gif and /dev/null differ diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..a887384 Binary files /dev/null and b/images/logo.png differ diff --git a/images/logo.svg b/images/logo.svg deleted file mode 100644 index b967929..0000000 --- a/images/logo.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - -logo - - - - - - - - - - - - - diff --git a/images/signatureHelp.gif b/images/signatureHelp.gif new file mode 100644 index 0000000..9f921ff Binary files /dev/null and b/images/signatureHelp.gif differ diff --git a/package.json b/package.json index 9ae40db..3f8470c 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "description": "Advanced Autocompletion and Refactoring support for PHP", "publisher": "felixfbecker", "author": "Felix Becker ", - "license": "ISC", + "license": "MIT", "private": true, "preview": false, - "version": "1.1.3", + "version": "1.5.4", "engines": { - "vscode": "^1.7.0" + "vscode": "^1.17.1" }, "keywords": [ "php", @@ -19,9 +19,9 @@ "refactor" ], "categories": [ - "Languages" + "Programming Languages" ], - "icon": "images/logo.svg", + "icon": "images/logo.png", "galleryBanner": { "color": "#6682BA", "theme": "dark" @@ -34,7 +34,8 @@ "url": "https://github.com/felixfbecker/php-language-server/issues" }, "activationEvents": [ - "onLanguage:php" + "onLanguage:php", + "workspaceContains:**/*.php" ], "contributes": { "configuration": { @@ -53,21 +54,74 @@ }, "main": "./out/extension", "scripts": { - "compile": "tsc -p .", + "build": "tsc -p .", "watch": "tsc -w -p .", - "postinstall": "node ./node_modules/vscode/bin/install && typings prune && typings install", - "lint": "tslint -c tslint.json \"src/**/*.ts\"" + "postinstall": "node ./node_modules/vscode/bin/install", + "lint": "tslint -c tslint.json \"src/**/*.ts\"", + "semantic-release": "semantic-release", + "commitmsg": "commitlint -e $GIT_PARAMS" }, "devDependencies": { - "tslint": "^4.2.0", + "@commitlint/cli": "^6.2.0", + "@commitlint/config-conventional": "^6.1.3", + "@types/mocha": "5.0.0", + "@types/mz": "^0.0.31", + "@types/node": "^8.0.24", + "@types/semver": "^5.3.34", + "husky": "^0.14.3", + "semantic-release": "^15.5.0", + "semantic-release-vsce": "^2.1.1", + "tslint": "^5.0.0", "typescript": "^2.1.4", - "typings": "^2.0.0", - "vsce": "^1.8.1", "vscode": "^1.0.0" }, "dependencies": { "mz": "^2.4.0", "semver": "^5.3.0", "vscode-languageclient": "^3.0.3" + }, + "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ] + }, + "release": { + "verifyConditions": [ + "semantic-release-vsce", + "@semantic-release/github" + ], + "prepare": { + "path": "semantic-release-vsce", + "packageVsix": "php-intellisense.vsix" + }, + "publish": [ + "semantic-release-vsce", + { + "path": "@semantic-release/github", + "assets": "php-intellisense.vsix" + } + ] + }, + "contributes": { + "configuration": { + "type": "object", + "title": "PHP IntelliSense", + "properties": { + "php.memoryLimit": { + "type": "string", + "default": "4095M", + "description": "The memory limit of the php language server. [Number][K|M|G]. Use '-1' to allow unlimited use of the RAM (default is 4G).", + "pattern": "^\\d+[KMG]?$" + }, + "php.executablePath": { + "type": [ + "string", + "null" + ], + "default": null, + "description": "The path to a PHP 7+ executable." + } + } + } } } diff --git a/src/extension.ts b/src/extension.ts index c178bc7..fc9b83f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -12,6 +12,19 @@ export async function activate(context: vscode.ExtensionContext): Promise const conf = vscode.workspace.getConfiguration('php'); const executablePath = conf.get('executablePath') || 'php'; + const memoryLimit = conf.get('memoryLimit') || '4095M'; + + if (memoryLimit !== '-1' && !/^\d+[KMG]?$/.exec(memoryLimit)) { + const selected = await vscode.window.showErrorMessage( + 'The memory limit you\'d provided is not numeric, nor "-1" nor valid php shorthand notation!', + 'Open settings' + ); + if (selected === 'Open settings') { + await vscode.commands.executeCommand('workbench.action.openGlobalSettings'); + } + return; + } + // Check path (if PHP is available and version is ^7.0.0) let stdout: string; try { @@ -49,10 +62,24 @@ export async function activate(context: vscode.ExtensionContext): Promise } const serverOptions = () => new Promise((resolve, reject) => { - function spawnServer(...args: string[]): ChildProcess { + // Use a TCP socket because of problems with blocking STDIO + const server = net.createServer(socket => { + // 'connection' listener + console.log('PHP process connected'); + socket.on('end', () => { + console.log('PHP process disconnected'); + }); + server.close(); + resolve({ reader: socket, writer: socket }); + }); + // Listen on random port + server.listen(0, '127.0.0.1', () => { // The server is implemented in PHP - args.unshift(context.asAbsolutePath(path.join('vendor', 'felixfbecker', 'language-server', 'bin', 'php-language-server.php'))); - const childProcess = spawn(executablePath, args); + const childProcess = spawn(executablePath, [ + context.asAbsolutePath(path.join('vendor', 'felixfbecker', 'language-server', 'bin', 'php-language-server.php')), + '--tcp=127.0.0.1:' + server.address().port, + '--memory-limit=' + memoryLimit + ]); childProcess.stderr.on('data', (chunk: Buffer) => { console.error(chunk + ''); }); @@ -60,32 +87,16 @@ export async function activate(context: vscode.ExtensionContext): Promise console.log(chunk + ''); }); return childProcess; - } - if (process.platform === 'win32') { - // Use a TCP socket on Windows because of blocking STDIO - const server = net.createServer(socket => { - // 'connection' listener - console.log('PHP process connected'); - socket.on('end', () => { - console.log('PHP process disconnected'); - }); - server.close(); - resolve({ reader: socket, writer: socket }); - }); - // Listen on random port - server.listen(0, '127.0.0.1', () => { - spawnServer('--tcp=127.0.0.1:' + server.address().port); - }); - } else { - // Use STDIO on Linux / Mac - resolve(spawnServer()); - } + }); }); // Options to control the language client const clientOptions: LanguageClientOptions = { // Register the server for php documents - documentSelector: ['php'], + documentSelector: [ + { scheme: 'file', language: 'php' }, + { scheme: 'untitled', language: 'php' } + ], uriConverters: { // VS Code by default %-encodes even the colon after the drive letter // NodeJS handles it much better @@ -93,12 +104,11 @@ export async function activate(context: vscode.ExtensionContext): Promise protocol2Code: str => vscode.Uri.parse(str) }, synchronize: { - // Synchronize the setting section 'phpIntelliSense' to the server - configurationSection: 'phpIntelliSense' - // Notify the server about file changes to composer.json files contain in the workspace - // fileEvents: vscode.workspace.createFileSystemWatcher('**/composer.json') - }, - initializationOptions: vscode.workspace.getConfiguration('phpIntelliSense') + // Synchronize the setting section 'php' to the server + configurationSection: 'php', + // Notify the server about changes to PHP files in the workspace + fileEvents: vscode.workspace.createFileSystemWatcher('**/*.php') + } }; // Create the language client and start the client. diff --git a/tsconfig.json b/tsconfig.json index 086e5c7..243b241 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,14 +15,11 @@ "noImplicitReturns": true, "noUnusedLocals": true, "allowUnreachableCode": false, - "allowUnusedLabels": false, - "typeRoots": [ - "typings/modules", - "typings/globals" - ] + "allowUnusedLabels": false }, "exclude": [ "node_modules", - "out" + "out", + "vendor" ] } diff --git a/typings.json b/typings.json deleted file mode 100644 index af82dc8..0000000 --- a/typings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "dependencies": { - "mz": "registry:npm/mz#2.4.0+20161114225638", - "semver": "registry:npm/semver#5.0.0+20160723033700" - }, - "globalDependencies": { - "mocha": "registry:env/mocha#2.2.5+20160926180742", - "node": "registry:env/node#6.0.0+20170213133316" - } -}