Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt Microsoft/tolerant-php-parser #357

Merged
merged 151 commits into from
Jun 9, 2017
Merged
Show file tree
Hide file tree
Changes from 150 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
13241a7
initialize tolerant-php-parser
mousetraps Feb 3, 2017
027801e
update parser branch for development
mousetraps Mar 1, 2017
df315df
start refactoring definition resolver
mousetraps Mar 1, 2017
591ecbd
Extract static FQN methods to FqnUtilities
mousetraps Mar 1, 2017
b1eb435
update definition resolver interfaces
mousetraps Mar 2, 2017
e7b04f7
extract symbol information
mousetraps Mar 2, 2017
2280e78
extract to tree analyzer interface
mousetraps Mar 5, 2017
722898f
refactor
mousetraps Mar 5, 2017
15eed55
Symbol support for Microsoft/tolerant-php-parser
mousetraps Mar 5, 2017
cdf8fc3
add getNodeAtPosition, fix definition collector tests
mousetraps Mar 6, 2017
d3f2beb
Hover and Go-To definition (in progress)
mousetraps Mar 6, 2017
c18bec0
small fixes, add diagnostic mode
mousetraps Mar 6, 2017
1316761
fix scoped expression definition resolution
mousetraps Mar 6, 2017
d21e7e7
Fix qualified name resolution
mousetraps Mar 6, 2017
4653f10
fix variableName symbol info, offsets in tests
mousetraps Mar 6, 2017
1ff1b38
fix subscript expression resolution
mousetraps Mar 6, 2017
d02253c
fix base class logic
mousetraps Mar 6, 2017
afca7ea
fix definitions namespaced function calls
mousetraps Mar 7, 2017
e45648d
fix global constant fallback
mousetraps Mar 7, 2017
167b6ac
Update getDocBlock to use context information. All Definition tests p…
mousetraps Mar 7, 2017
4324530
Find all references support
mousetraps Mar 9, 2017
0824e6d
start adding validation tests
mousetraps Mar 15, 2017
81ba7df
fix some crashes, perf issues
mousetraps Mar 15, 2017
6e7f77b
add script to help profile
mousetraps Mar 15, 2017
7b633f5
minor perf improvements
mousetraps Mar 21, 2017
cd4c6d6
Add validation test filesize threshold
mousetraps Mar 24, 2017
c84b91d
Fix exception during definition resolution
mousetraps Mar 24, 2017
946b5b1
Fix exception during diagnostics parsing
mousetraps Mar 24, 2017
4ac56d8
Update logging
mousetraps Mar 28, 2017
a69c93b
Print null docs in language server perf log
mousetraps Mar 28, 2017
42dc2c9
Update validation tests
mousetraps Mar 28, 2017
105f9bf
Include max-recursion comparison in perf test
mousetraps Mar 28, 2017
a5fec94
Fix misc. issues in language server
mousetraps Mar 28, 2017
d62bdea
revert earlier change to fix tests
mousetraps Mar 29, 2017
7d68e3a
Only traverse tree 1x for definitions + references
mousetraps Mar 29, 2017
fa52aef
revert isClass -> canBeInstantiated
mousetraps Apr 10, 2017
651e6be
add definition comparison to validation tests
mousetraps Apr 10, 2017
21cee77
include traits and interfaces when retrieving fqn
mousetraps Apr 10, 2017
b02c164
fix property / constant ancestor check
mousetraps Apr 10, 2017
3d5d46d
don't use generator during iteration
mousetraps Apr 10, 2017
864a7a8
test multipe frameworks in perf test script
mousetraps Apr 10, 2017
5996544
Update definition validation tests
mousetraps Apr 10, 2017
5bd827f
include validation tests in separate test group
mousetraps Apr 11, 2017
219c018
Disclude anonymous class members from definitions
mousetraps Apr 11, 2017
e6ba591
Catch all errors in perf test
mousetraps Apr 11, 2017
981b74a
don't get docblock comment for namespace definition nodes
mousetraps Apr 11, 2017
57ebd58
Update validation tests to verify more definition properties, references
mousetraps Apr 11, 2017
39fe9dc
fix issue where vars not being resolved to corresponding parameter de…
mousetraps Apr 11, 2017
0b0cad2
update validation test
mousetraps Apr 12, 2017
35ce3af
fix issue where call expression references weren't being properly ind…
mousetraps Apr 12, 2017
d6d9712
clarify logic around scoped and member access expressions
mousetraps Apr 12, 2017
ed2a591
Add stats from last perf run
mousetraps Apr 12, 2017
8d11ec7
Update validation test comparison exceptions
mousetraps Apr 13, 2017
05bccec
Ensure duplicate ScopedPropertyAccess expressions don't appear
mousetraps Apr 13, 2017
26152b1
Temporary change to expose index to validation tests
mousetraps Apr 13, 2017
52d70a2
Update test case locations
mousetraps Apr 13, 2017
596d7f0
Add isolated validation test cases
mousetraps Apr 13, 2017
2ab7fc0
add more validation test cases
mousetraps Apr 13, 2017
6d39d87
Fix class inheritance issue, fix parenthesized expression type resolu…
mousetraps Apr 13, 2017
4382821
Update logger to better handle errors
mousetraps Apr 16, 2017
54f385f
Fix misc. issues, add more test cases, update validation test
mousetraps Apr 16, 2017
65686c6
Fix namespace name, use variable issues
mousetraps Apr 16, 2017
f5a93a2
refactor definition resolver, fix misc. issues
mousetraps Apr 19, 2017
bfbad09
Fix and start cleaning up type resolution issues
mousetraps Apr 20, 2017
347a5a1
Update + clarify type resolution logic
mousetraps Apr 20, 2017
223a2ea
fix return type resolution issue
mousetraps Apr 20, 2017
ed64692
fix trait use and scoped call expressions
mousetraps Apr 20, 2017
76c8536
first pass at completion provider (work in progress)
mousetraps Apr 26, 2017
3e22956
Fix tolerant-php-parser branch ref
roblourens Apr 26, 2017
7940ea4
Revert "Fix tolerant-php-parser branch ref" (I blame @mousetraps)
roblourens Apr 26, 2017
8af671e
Add validation test submodules
roblourens May 1, 2017
f201ecd
Rewrite ValidationTest
roblourens May 1, 2017
4d47671
Fix ValidationTest to read serialized results
roblourens May 1, 2017
587822b
$references are now an array, not an object - fix removing skipped refs
roblourens May 2, 2017
ede5edc
Add .expected.json files and skipped.json
roblourens May 2, 2017
ce548de
Update baselines - failing tests are verified as expected
roblourens May 2, 2017
dc67337
Rewrite .expected file on test failure and rename "broken" -> "_cases"
roblourens May 2, 2017
bb94aea
Add newStatic.php to skipped.json
roblourens May 2, 2017
30da705
Fix codesniffer reference
roblourens May 2, 2017
31441f4
Remove ParserResourceFactory and DefinitionResolverInterface (leave o…
roblourens May 2, 2017
57f9e1f
Fix completions test (insertText is optional)
roblourens May 2, 2017
de08134
Point at master branch of tolerant-php-parser
roblourens May 12, 2017
addc862
Add Diagnostic source and severity
roblourens May 14, 2017
1bb710f
Fix absolute paths and escaped slashes in validation expected output
roblourens May 15, 2017
22ddb81
Also fix disabled validation test output files
roblourens May 15, 2017
403e0c5
Remove diagnostics log disable hack
roblourens May 15, 2017
e46d0de
Fix 'type_class' set to wrong value
roblourens May 15, 2017
90b40ef
Fix composer references
roblourens May 17, 2017
253f9b5
Fix completions on -> next to an unrelated token
roblourens May 18, 2017
91f1379
Don't try to filter completions by member name, vscode does it
roblourens May 18, 2017
1fa29cc
Fix exception thrown when getting completions on Definitions with a n…
roblourens May 18, 2017
67081c4
Clean up completions, fix exceptions thrown from running strpos on em…
roblourens May 18, 2017
b541262
Fix completion tests to handle receiving all items
roblourens May 19, 2017
f2e6e3a
Remove tmp test logging
roblourens May 19, 2017
fc3e8ef
Fix ParseErrorTests
roblourens May 19, 2017
a9be548
Remove LoggedDefinitionResolver
roblourens May 19, 2017
552d99e
Merge remote-tracking branch 'upstream/master' into tolerant
roblourens May 19, 2017
5e9dfa1
Remove original DefinitionResolver, remove "Tolerant" on file names
roblourens May 19, 2017
cf9590b
Remove "use PhpParser\Node"
roblourens May 19, 2017
71d71a8
Remove obsolete NodeVisitors
roblourens May 19, 2017
442fc7e
Remove remaining 'use PhpParser\' statements and some dead code
roblourens May 19, 2017
b4e77f2
Remove more PhpParser\Node references
roblourens May 19, 2017
6e1f638
Remove nikic/php-parser reference
roblourens May 19, 2017
d7a4034
Merge branch 'tolerantMasterMerge' into tolerant
roblourens May 22, 2017
97937ea
Fix unsupported hover test
roblourens May 22, 2017
f51af8b
Minor cleanup
roblourens May 24, 2017
836cdb7
Fix HoverTest after previous fixture change
roblourens May 24, 2017
3dfe505
Remove "Tolerant" alias
roblourens May 24, 2017
9c35aa6
Remove stats.md
roblourens May 25, 2017
2248148
Remove nullDocs logging - Tolerant parser doesn't produce null Source…
roblourens May 25, 2017
05aa935
Bump phpunit memory limit
roblourens May 25, 2017
2568a42
Fix autofixable formatting errors
roblourens May 25, 2017
de44ce5
Fix error from completions after typing 'new'
roblourens Jun 1, 2017
077f0be
Remove 'void' return annotation
roblourens Jun 1, 2017
260969b
Remove Performance.php comments
roblourens Jun 2, 2017
f144ca7
Refactor findVariableDefinitionsInNode to simplify and avoid closure use
roblourens Jun 3, 2017
d56d1b7
$index can be private again
roblourens Jun 3, 2017
e0a7b21
Fix possible Node/MissingToken mismatch (error reported in Lumen proj…
roblourens Jun 6, 2017
65363b7
Add comment on try/catch in DefinitionResolver
roblourens Jun 6, 2017
f16866a
Restore type annotation
roblourens Jun 6, 2017
f1c0cc5
Remove comments, question answered by Felix
roblourens Jun 6, 2017
3cb0c03
Restore more type annotations
roblourens Jun 6, 2017
01e7243
Fix indentation
roblourens Jun 6, 2017
825c671
Remove unnecessary group import
roblourens Jun 6, 2017
eef8244
Make Index->references private again
roblourens Jun 6, 2017
aba798a
Cleanup
roblourens Jun 7, 2017
d4cabc6
Annotate TreeAnalyzer->update
roblourens Jun 7, 2017
70cf60e
Add missing props to TreeAnalyzer, remove unused getUri
roblourens Jun 7, 2017
829d307
Improve strStartsWith
roblourens Jun 7, 2017
af5a5fe
Mark test incomplete instead of commenting it out
roblourens Jun 7, 2017
b2a849d
Cleanup ValidationTest some more
roblourens Jun 7, 2017
586b0d6
Move validation testcases out of frameworks folder
roblourens Jun 7, 2017
fc7d7f4
Use reflection to get Definition props (now includes fqn and declarat…
roblourens Jun 7, 2017
344a2ce
Remove filterSkippedReferences, no longer relevant
roblourens Jun 7, 2017
0a15afc
Cleanup, fix incorrect count() usage
roblourens Jun 7, 2017
cfc8cc7
Make FqnUtilities a module of functions, not a static class
roblourens Jun 7, 2017
ae37940
Fix error when getting completions in anon function closure 'use'
roblourens Jun 7, 2017
eda52a8
Fix error from calling ltrim on null variableName
roblourens Jun 8, 2017
1d314de
Make ParserHelper a module of functions, not a static class
roblourens Jun 8, 2017
68656d9
Use === "" instead of strlen check
roblourens Jun 8, 2017
4ade5fd
Fix sniff issues, exclude 'cases' test files from codesniff
roblourens Jun 8, 2017
3131a9c
Polish TreeAnalyzer
felixfbecker Jun 8, 2017
54073c5
More polish
felixfbecker Jun 8, 2017
adf65e5
Polish CompletionProvider
felixfbecker Jun 8, 2017
a1ae0f6
Take tolerant-php-parser from Packagist instead of github
roblourens Jun 8, 2017
bc5717a
Check if node has parent
felixfbecker Jun 9, 2017
d3d7f7d
Remove unneeded group use
felixfbecker Jun 9, 2017
9ad3c5a
Remove dead if block
roblourens Jun 9, 2017
4b573ac
Inline strStartsWith and remove it
roblourens Jun 9, 2017
4486ea0
Don't recheck condition
felixfbecker Jun 9, 2017
349d3cb
Remove ParserKind reference from Perf test
roblourens Jun 9, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor/
.phpls/
composer.lock
stubs
*.ast
27 changes: 27 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[submodule "validation/frameworks/php-language-server"]
path = validation/frameworks/php-language-server
url = https://github.com/felixfbecker/php-language-server
[submodule "validation/frameworks/wordpress"]
path = validation/frameworks/wordpress
url = https://github.com/wordpress/wordpress
[submodule "validation/frameworks/drupal"]
path = validation/frameworks/drupal
url = https://github.com/drupal/drupal
[submodule "validation/frameworks/tolerant-php-parser"]
path = validation/frameworks/tolerant-php-parser
url = https://github.com/microsoft/tolerant-php-parser
[submodule "validation/frameworks/symfony"]
path = validation/frameworks/symfony
url = https://github.com/symfony/symfony
[submodule "validation/frameworks/math-php"]
path = validation/frameworks/math-php
url = https://github.com/markrogoyski/math-php
[submodule "validation/frameworks/codeigniter"]
path = validation/frameworks/codeigniter
url = https://github.com/bcit-ci/codeigniter
[submodule "validation/frameworks/cakephp"]
path = validation/frameworks/cakephp
url = https://github.com/cakephp/cakephp
[submodule "validation/frameworks/phpunit"]
path = validation/frameworks/phpunit
url = https://github.com/sebastianbergmann/phpunit
71 changes: 71 additions & 0 deletions Performance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace LanguageServer\Tests;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, this is a benchmark that is run manually and depends on the git submodules, correct?

not blocking, but what do you think about moving this to a function that returns can be called in ComposerScripts.php and also in a PHPUnit test that asserts it stays below a threshold and catches performance regressions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to write an assert that a test runs in less than N seconds. You can really only compare performance between two runs on a given machine under controlled conditions.

If you want to do this in Travis or something (which would be awesome) maybe we could have it check out the previous version and run the test, then immediately check out the new version and run the test, and run several times and average the runs. But you still have to think about other things happening on the same machine, filesystem caching, other environmental things out of our control, so it might still end up flaky. I think doing this right is out of scope of this PR.

require __DIR__ . '/vendor/autoload.php';

use Exception;
use LanguageServer\Index\Index;
use LanguageServer\ParserKind;
use LanguageServer\PhpDocument;
use LanguageServer\DefinitionResolver;
use Microsoft\PhpParser;
use phpDocumentor\Reflection\DocBlockFactory;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;

$totalSize = 0;

$frameworks = ["drupal", "wordpress", "php-language-server", "tolerant-php-parser", "math-php", "symfony", "CodeIgniter", "cakephp"];

foreach($frameworks as $framework) {
$iterator = new RecursiveDirectoryIterator(__DIR__ . "/validation/frameworks/$framework");
$testProviderArray = array();

foreach (new RecursiveIteratorIterator($iterator) as $file) {
if (strpos((string)$file, ".php") !== false) {
$totalSize += $file->getSize();
$testProviderArray[] = $file->getPathname();
}
}

if (count($testProviderArray) === 0) {
throw new Exception("ERROR: Validation testsuite frameworks not found - run `git submodule update --init --recursive` to download.");
}


$parserKinds = [ParserKind::PHP_PARSER, ParserKind::TOLERANT_PHP_PARSER];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ParserKind still exist?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damnit, one sec :)

foreach ($parserKinds as $kind) {
$start = microtime(true);

foreach ($testProviderArray as $idx => $testCaseFile) {
if (filesize($testCaseFile) > 10000) {
continue;
}
if ($idx % 1000 === 0) {
echo "$idx\n";
}

$fileContents = file_get_contents($testCaseFile);

$docBlockFactory = DocBlockFactory::createInstance();
$index = new Index;
$maxRecursion = [];
$definitions = [];

$definitionResolver = new DefinitionResolver($index);
$parser = new PhpParser\Parser();

try {
$document = new PhpDocument($testCaseFile, $fileContents, $index, $parser, $docBlockFactory, $definitionResolver);
} catch (\Throwable $e) {
continue;
}
}

echo "------------------------------\n";

echo "Time [$framework, $kind]: " . (microtime(true) - $start) . PHP_EOL;

}
}

8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"require": {
"php": ">=7.0",
"nikic/php-parser": "^3.0.5",
"phpdocumentor/reflection-docblock": "^3.0",
"sabre/event": "^5.0",
"felixfbecker/advanced-json-rpc": "^2.0",
Expand All @@ -38,7 +37,8 @@
"webmozart/glob": "^4.1",
"sabre/uri": "^2.0",
"jetbrains/phpstorm-stubs": "dev-master",
"composer/composer": "^1.3"
"composer/composer": "^1.3",
"Microsoft/tolerant-php-parser": "^0.0.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -47,7 +47,9 @@
"LanguageServer\\": "src/"
},
"files" : [
"src/utils.php"
"src/utils.php",
"src/FqnUtilities.php",
"src/ParserHelpers.php"
]
},
"autoload-dev": {
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ruleset name="PHP Language Server">
<file>src</file>
<file>tests</file>
<exclude-pattern>tests/Validation/cases</exclude-pattern>
<rule ref="PSR2">
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations"/>
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"/>
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</whitelist>
</filter>
<php>
<ini name="memory_limit" value="256M"/>
<ini name="memory_limit" value="1024M"/>
</php>
</phpunit>
Loading