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