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

Improvements for autocompletion and goto #421

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

acran
Copy link

@acran acran commented Feb 24, 2021

This PR adds some improvements/fixes:

  • correctly allow "go to declaration" when clicking on expressions with scope resolution operator ::, e.g. MyClass::class to go to MyClass
  • sort exact matches of search string first in autocomplete suggestions
  • remove duplicate suggestions for variable names
  • correctly scope variable name suggestions to current function

fixes #368
fixes #366

With the buffer position on the class name followed by a scope
resolution operator "::" getFullWordFromBufferPosition would select the
whole expression; but a later goto would then only look at the member
part and wrongfully try andgo to that member instead of the class
definition:

    MyClass::class
      ^-- Buffer position here

* getFullWordFromBufferPosition returns "MyClass::class"
* goto tries to go to member "class" of class MyClass and fails

Adding the colon to forwardRegex will return only the class name instead
if buffer position is before the scope resolution operator but not if
after:

    MyClass::class
      ^-- getFullWordFromBufferPosition now returns "MyClass"
    MyClass::class
               ^-- but here still returns "MyClass::class"
This will sort suggestions containing exact matches of the search prefix
first providing a better quality of suggestions
getAllVariablesInFunction returns every variable used in a function so
far which willl then be used for autocompletion suggestions. But with
variables used mulitple times in the function they will appear as
duplicates in the suggestions.
To fix this this now returns a list of unique variable names.
Changes made to the language-php syntax package broke the detection of
opening and closing code blocks resulting in isInFunction always
returning false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

variable duplications self and this not completing
1 participant