Skip to content

Commit

Permalink
Merge pull request #9 from TysonAndre/release-0.1.0
Browse files Browse the repository at this point in the history
Release Phan 0.1.0
  • Loading branch information
TysonAndre committed Feb 17, 2018
2 parents 156c40d + 6114363 commit 806d58a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 41 deletions.
49 changes: 33 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,11 @@ However, bugs in this VS code extension (crashes, etc) or related to the languag
1. PHP 7.1+ must be installed.
You can either add it to your PATH or set the `phan.executablePath` setting.
2. Your Operating System must be Unix/Linux
(Phan support depends on `pcntl` module being installed, which is only available on those platforms)
(Phan's Language Server Protocol support depends on `pcntl` module being installed, which is only available on those platforms)

A future release may support Windows, but it won't be as fast.
3. [The `php-ast` PECL extension](https://pecl.php.net/package/ast) must be installed and enabled.
4. Depends on using a checkout of Phan with https://github.com/phan/phan/pull/1144 installed


### Installing from source

This extension hasn't been published yet. It can be installed locally with the following method:

```bash
npm install
npm run build
node node_modules/.bin/vsce package
```

The generated VSIX file can be used locally with the steps from https://stackoverflow.com/a/38866913
3. (Optional) For optimal performance and accuracy of analysis,
[the `php-ast` PECL extension](https://pecl.php.net/package/ast) should be installed and enabled.

### Setup steps

Expand Down Expand Up @@ -122,6 +109,24 @@ And then point to that phan installation:

## Release History

### 0.1.0 (2018-02-16)

- By default, allow running this extension without `php-ast` installed.
Note that the polyfill has bugs in a few edge cases (e.g. getting phpdoc for closures, successfully parsing uncommon PHP syntax).
This polyfill is based on `tolerant-php-parser`.

To make this extension refuse to start if `php-ast` is not installed, set `phan.allowPolyfillParser` to false.
- Fix a bug where Phan would fail to parse and analyze files that were added to the project after startup.
- Analyze all PHP files that are in other **open** tabs or split windows.
Previously, Phan would analyze only the most recently changed file.
- If file change notifications are being sent to Phan faster than Phan can re-analyze the open files,
make Phan batch the file change notifications before parsing and analyzing the project. (batched along with file open/close/delete notifications)

This change to Phan should help improve Phan's responsiveness (e.g. if editing large files).
- Update Phan.

See [Phan's NEWS](https://raw.githubusercontent.com/phan/phan/34ca3b7b079291e1a634afbdc71a3453dbb3118c/NEWS.md) for more details

### 0.0.10 (2018-02-07)

- Add an option `phan.connectToServerWithStdio` to allow clients to continue to use stdio to communicate with the Phan language server. ([Issue #8](https://github.com/TysonAndre/vscode-php-phan/issues/8))
Expand Down Expand Up @@ -189,6 +194,18 @@ And then point to that phan installation:

- Reword README, rename extension to php-phan

## Installing from source

This can be installed locally with the following method:

```bash
npm install
npm run build
node node_modules/.bin/vsce package
```

The generated VSIX file can be used locally with the steps from https://stackoverflow.com/a/38866913

## Credits

This VS Code extension and many parts of the language server protocol implementation are based on [PHP IntelliSense](https://github.com/felixfbecker/vscode-php-intellisense)
Expand Down
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"private": true,
"preview": false,
"version": "0.0.10",
"version": "0.1.0",
"engines": {
"vscode": "^1.16.0",
"os": [
Expand Down Expand Up @@ -51,10 +51,10 @@
"devDependencies": {
"@types/mocha": "^2.2.48",
"@types/mz": "0.0.31",
"@types/node": "^8.9.0",
"@types/node": "^8.9.4",
"@types/semver": "^5.5.0",
"tslint": "^5.7.0",
"typescript": "^2.7.1",
"typescript": "^2.7.2",
"vsce": "^1.36.2",
"vscode": "^1.1.0"
},
Expand Down Expand Up @@ -152,6 +152,13 @@
],
"default": null,
"description": "Optional (Advanced). If provided, this overrides the Phan script to use (using a Phan branch supporting the Language Server Protocol). e.g. /path/to/phan_git_checkout/phan. (Modifying requires restart)"
},
"phan.allowPolyfillParser": {
"type": [
"boolean"
],
"default": true,
"description": "If set to true, this extension will run even if php-ast is not installed. Installing php-ast is strongly recommended for performance reasons and for consistency with full Phan analysis."
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function checkPHPVersion(context: vscode.ExtensionContext, phpExecutablePa
return true;
}

async function checkPHPAstInstalledAndSupported(context: vscode.ExtensionContext, phpExecutablePath: string): Promise<boolean> {
async function checkPHPAstInstalledAndSupported(context: vscode.ExtensionContext, phpExecutablePath: string, allowPolyfillParser: boolean): Promise<boolean> {
let stdout = '';
try {
[stdout] = await execFile(phpExecutablePath, ['-r', 'if (extension_loaded("ast")) { echo "ext-ast " . (new ReflectionExtension("ast"))->getVersion(); } else { echo "None"; }']);
Expand All @@ -62,11 +62,15 @@ async function checkPHPAstInstalledAndSupported(context: vscode.ExtensionContext
}

if (stdout.match(/^None/)) {
if (allowPolyfillParser) {
// Phan will probably use the polyfill parser based on tolerant-php-parser.
return true;
}
vscode.window.showErrorMessage('php-ast is not installed or not enabled. php-ast 0.1.5 or newer must be installed. PHP Path: ' + phpExecutablePath);
return false;
}

// Parse version and discard OS info like 7.1.8--0ubuntu0.16.04.2
// Parse version and discard OS info like 7.1.14--0ubuntu0.16.04.2
const astMatch = stdout.match(/^ext-ast ([^\s]+)/m);
if (!astMatch) {
vscode.window.showErrorMessage('Error parsing php-ast module version. Please check the output of `if (extension_loaded("ast")) { echo "ext-ast " . (new ReflectionExtension("ast"))->getVersion(); } else { echo "None"; }`. PHP Path: ' + phpExecutablePath);
Expand Down Expand Up @@ -176,6 +180,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const enableDebugLog = conf.get<boolean>('enableDebugLog');
const useFallbackParser = conf.get<boolean>('useFallbackParser');
const analyzeOnlyOnSave = conf.get<boolean>('analyzeOnlyOnSave');
const allowPolyfillParser = conf.get<boolean>('allowPolyfillParser') || false;
const memoryLimit = conf.get<string>('memoryLimit') || null;
const connectToServerWithStdio = conf.get<boolean>('connectToServerWithStdio');
const additionalCLIFlags = conf.get<string[]>('additionalCLIFlags') || [];
Expand All @@ -188,7 +193,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}

// Check if php-ast is installed
const isPHPASTInstalled: boolean = await checkPHPAstInstalledAndSupported(context, phpExecutablePath);
const isPHPASTInstalled: boolean = await checkPHPAstInstalledAndSupported(context, phpExecutablePath, allowPolyfillParser);
if (!isPHPASTInstalled) {
return;
}
Expand Down Expand Up @@ -240,6 +245,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
// php phan --language-server-analyze-only-on-save [args]
args.unshift('--language-server-analyze-only-on-save');
}
if (allowPolyfillParser) {
// php phan --allow-polyfill-parser [args]
args.unshift('--allow-polyfill-parser');
}
if (enableDebugLog) {
// php phan --language-server-verbose [args]
args.unshift('--language-server-verbose');
Expand Down

0 comments on commit 806d58a

Please sign in to comment.