1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
Commit Graph

115 Commits

Author SHA1 Message Date
Matt Brown
62a5a74640 Fix #5108 - prevent crash on 0 type 2021-01-26 14:06:43 -05:00
Matt Brown
0624098865 Ensure getId() output can always be parsed as a type
Ref #5105
2021-01-25 23:41:51 -05:00
Joe Hoyle
531cd36767
Support completions on class references (#5085)
* Support compleitions on class references

This provides completions on class references (as opposed to initiated objects via the type map), so you can do `MyClass::` and get completitions for static methods and constants etc.

* Only provide completions for references that don't exist
2021-01-24 13:29:21 -05:00
Joe Hoyle
ba43e6d0f3
Remove file map cache when re-analyzing files (#5084)
* Remove file map cache when re-analyzing files

When the project is re-analyzed under the single thread condition (not using a process pool), the filemaps are not cleared before re-analyzing files. This means that file maps only get appended to. If you delete the contents of a file via the LSP, the file map will still be populated with all the old values for example.

In doing this I had to write a few more tests to check my assumptions too, so adding those additional tests.

* Rename test

* Formatting

* Formatting again!
2021-01-22 16:05:28 -05:00
orklah
37a2f8a33d
unused use statements (#4228) 2020-09-22 01:10:46 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
orklah
f66d57f19d
add native return types (#4116)
* add native return types

* remove redundant phpdoc
2020-09-04 16:26:33 -04:00
orklah
73f6fcde48
Short list syntax (#4102)
* Short list syntax

* revert unrelated CS
2020-09-02 00:17:41 -04:00
Tyson Andre
5f855a73d4
Fix expected php 8.0 syntax error (#4084)
This will very likely be parsed as an attribute in php 8.0
See
https://wiki.php.net/rfc/shorter_attribute_syntax_change#secondary_vote
2020-08-29 13:36:56 -04:00
Bruce Weirdan
1cf5153700
Test parallelization (#4045)
* Run tests in random order

Being able to run tests in any order is a pre-requisite for being able
to run them in parallel.

* Reset type coverage between tests, fix affected tests

* Reset parser and lexer between test runs and on php version change

Previously lexer was reset, but parser kept the reference to the old
one, and reference to the parser was kept by StatementsProvider. This
resulted in order-dependent tests - if the parser was first initialized
with phpVersion set to 7.4 then arrow functions worked fine, but were
failing when the parser was initially constructed with settings for 7.3

This can be demonstrated on current master by upgrading to
nikic/php-parser:4.9 and running:

```
vendor/bin/phpunit --no-coverage --filter="inferredArgArrowFunction" tests/ClosureTest.php
```

Now all tests using PHP 7.4 features must set the PHP version
accordingly.

* Marked more tests using 7.4 syntax

* Reset newline-between-annotation flag between tests

* Resolve real paths before passing them to checkPaths

When checkPaths is called from psalm.php the paths are resolved, so we
just mimicking SUT behaviour here.

* Restore newline-between-annotations in DocCommentTest

* Tweak Appveyor caches

* Tweak TravisCI caches

* Tweak CircleCI caches

* Run tests in parallel

Use `vendor/bin/paratest` instead of `vendor/bin/phpunit`

* Use default paratest runner on Windows

WrapperRunner is not supported on Windows.

* TRAVIS_TAG could be empty

* Restore appveyor conditional caching
2020-08-23 10:32:07 -04:00
Joe Hoyle
b8c4abf08b
Add ability to Go to Definition on Use statements (#3805)
This adds the ability to use the LSP's "Go to Definition" on `use MyClass` statements.

Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-11 17:16:44 -04:00
Joe Hoyle
0b6d682964
Fix going to definition on return type (#3806)
* Fix going to definition on return type

If a return type of a method or function is set incorrectly (with the PHP doc), then the references are not added for the `function() : MyClass` symbol, so the "Go to definition" feature of the LSP won't work. I don't believe an invalid return type or not should stop the symbol location being tracked (and not allowing code navigation).

In moved the symbol location tracking to be before the return early short circuit.

* Update SymbolLookupTest.php

Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-11 17:14:39 -04:00
Joe Hoyle
11af82a97f
Fix jumping to definition on nullable parameters (#3804)
Currently it's not possible to "Go to definition" (LSP) on nullable args like `function( ?MyClass )` as the reference is stored a `MyClass|null` in the reference map, which will now resolve to a class name.

This PR removed any nullable type from the union before adding it to the reference map (as the reference map is only use to indicate a symbol was used in a given location, I think this makes sense).
2020-07-11 17:12:03 -04:00
Joe Hoyle
d1ca68e57a
Fix offset calculation in getReferenceAtPosition (#3783)
* Fix calculation of getPositionFromOffse

* Add test for testGetSymbolPositionRange

* Fix code formatting.
2020-07-09 16:24:51 -04:00
Brown
370ffa28e4 Fix #3117 - invalidate all caches when composer lockfile changes 2020-04-12 11:41:37 -04:00
Matthew Brown
f94ab22a5f Be better about strict inference 2020-03-25 09:18:49 -04:00
Matthew Brown
a5f79353ed Fix #2157 - don’t merge closures and callable params 2019-09-22 00:58:30 -04:00
Matthew Brown
8d63d5dc4e Add lookup for builtin functions 2019-07-18 23:30:44 -04:00
Matthew Brown
5583ae842e Refactor signature selection a little 2019-07-18 23:08:54 -04:00
Matthew Brown
0e6bd79a09 Allow completion from functions to work without namespacing cc @iluuu1994 2019-07-18 21:50:59 -04:00
Matthew Brown
74e1b521a5 Add support for completing builtin class names
Fixes #1863
2019-07-17 22:50:57 -04:00
Matthew Brown
da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00
Matthew Brown
df3d7e1d2c Make line endings mostly all the same 2019-07-03 16:58:27 -04:00
Brown
5c76b3c82d Fix #1888 - add go-to-variable 2019-07-01 18:48:33 -04:00
Ilija Tovilo
67c3726254 Implement signature help - closes #1841 (#1862)
* Implement signature help - closes #1841

* Add explicit signature count

* [LSP] Do analysis for every signatureHelp request

See here: https://github.com/vimeo/psalm/pull/1862#issuecomment-507007346

* Don’t language server information when checking property for init

* Fix signature help for functions

* Add try-catch around signature help Functions::getStorage()
2019-07-01 15:54:32 -04:00
Matthew Brown
36e2ea6881 Fix #1822 - update use statements with classes 2019-06-30 11:12:50 -04:00
Matthew Brown
ca53019d6b Simplify class completion lookup
Ref #1822
2019-06-29 21:32:26 -04:00
Ilija Tovilo
16768e363c Jump between parens when autocompleting method with parameters (#1839) 2019-06-24 07:51:12 -04:00
Matthew Brown
766b1b0384 Add reference, not type
Ref #1835
2019-06-23 09:10:43 -04:00
Matthew Brown
37ffd6dad6 Fix #1832 - add references to docblock types 2019-06-23 08:47:49 -04:00
Matthew Brown
4735955829 Fix #1835 - move reference generation before argument analysis 2019-06-23 08:08:00 -04:00
Ilija Tovilo
caca3e52c9 Display function signature on multiple lines when it has parameters (#1833) 2019-06-22 13:07:56 -04:00
Brown
aa6677a177 Add autocompletion for some classes
Ref #1822
2019-06-21 17:10:35 -04:00
Brown
0ba535d179 Fix problem locating end of completion area 2019-06-12 13:43:35 -04:00
Brown
f700502b51 Add skipped completion test 2019-06-12 13:34:49 -04:00
Josh Di Fabio
3db32f2274 Enable LS completion when whitespace follows known type
This change enables completion when there is whitespace following
a known type and an object access operator, e.g.:
    $foo
        ->bar()
        ->baz();
2019-06-12 09:17:50 -04:00
Matthew Brown
b5cbc84351 Fix #1617 - add option to only show errors in reports 2019-06-09 12:37:28 -04:00
Ilija Tovilo
5a14e4b1cf Progress bar (#1709)
* Revert "Revert "Implement better progress""

This reverts commit 4302596654.

* Revert "Revert "Implement dots progress bar""

This reverts commit e41733d789.

* Revert "Revert "Switch to VoidProgress by default""

This reverts commit 304ffeb0a3.

* Revert "Revert "Pass success flag to progress""

This reverts commit 62a690ee4e.

* Improve socket communication

* Use an underscore

* Add means to disable progress

* Add extra newline before progress bar
2019-05-30 10:30:41 -04:00
Matthew Brown
4302596654 Revert "Implement better progress"
This reverts commit 042070d0fd.
2019-05-27 13:07:02 -04:00
Matthew Brown
e41733d789 Revert "Implement dots progress bar"
This reverts commit 0c5837b246.
2019-05-27 13:05:06 -04:00
Matthew Brown
304ffeb0a3 Revert "Switch to VoidProgress by default"
This reverts commit 63b46be361.
2019-05-27 13:04:38 -04:00
Ilija Tovilo
63b46be361 Switch to VoidProgress by default 2019-05-26 23:18:48 -04:00
Ilija Tovilo
0c5837b246 Implement dots progress bar 2019-05-26 23:18:48 -04:00
Ilija Tovilo
042070d0fd Implement better progress 2019-05-26 23:18:48 -04:00
Brown
963d5bb901 Fix #1656 - allow chained call completion 2019-05-17 12:38:29 -04:00
Brown
a1c9ad501b Fix #1654 - understand templated completions 2019-05-17 12:11:27 -04:00
Brown
0bd4dbcbc4 Bump to PHP 7.1
Fixes #1650
2019-05-16 18:36:36 -04:00
Brown
ff14f671b1 Add hopefully-more-portable method for evaluating method/property usage 2019-04-16 16:07:48 -04:00
Matthew Brown
c772914910 Add some formatting 2019-03-23 14:27:54 -04:00
Bruce Weirdan
3a2c457d87 More tests fixed 2019-03-02 08:43:19 -05:00
Bruce Weirdan
ec85096c96 Fixed identified issues 2019-03-02 08:43:19 -05:00
Matthew Brown
3ad1abece4 Add generation of json artifacts 2019-02-24 01:33:25 -05:00
Matthew Brown
a6755cc523 Fix default test versions to 7.3 2019-02-07 15:27:43 -05:00
Matthew Brown
214fd7d461 Add DuplicateFunction issue
Fixes #49
2019-01-06 16:40:44 -05:00
Brown
2d22db4cb7 Clear up use of reloadFiles 2019-01-02 12:10:52 -05:00
Matthew Brown
fd0ab47b80 Fix #1118 - detect possible issues with unions of mixed 2018-12-08 13:18:55 -05:00
Brown
b5f0159cdf Add backup hover analysis when file isn’t analysed 2018-11-20 16:32:40 -05:00
Brown
ca602f8e17 Fix language server crash after editing trait method names 2018-11-20 15:51:47 -05:00
Brown
46cbd0de8d Add phpunit psalm plugin 2018-11-14 13:19:38 -05:00
Brown
110ca66692 Namespace test providers under Internal cc @TysonAndre 2018-11-12 11:20:59 -05:00
Matthew Brown
4d79b61e93 Change _checker to _analyzer 2018-11-12 11:20:59 -05:00
Matthew Brown
4688b25fd9 Move internal classes to own namespace 2018-11-12 11:20:59 -05:00
Brown
f2c013e45f Improve API for setting temporary file contents 2018-11-09 10:42:55 -05:00
Brown
00b51627cc Fix tests 2018-10-26 16:29:16 -04:00
Brown
e286089eaa Add onchange events and symbol lookup with disabled completion 2018-10-26 16:17:15 -04:00