Skip to content

Add constant fetch to reference map#5115

Merged
muglug merged 3 commits intovimeo:masterfrom
joehoyle:add-const-fetch-to-reference
Jan 28, 2021
Merged

Add constant fetch to reference map#5115
muglug merged 3 commits intovimeo:masterfrom
joehoyle:add-const-fetch-to-reference

Conversation

@joehoyle
Copy link
Copy Markdown
Contributor

To support showing constant types on hover of constant references, we need to add them to the ref map.

I'm not sure on the best format for the Symbol Information, I went with const APPLE string but perhaps there's a better formula to use here?

For global constants (though not in a namespace), I wasn't yet able to see where they were stored (see the failing test). It looks like Codebase::getStubbedConstantType() doesn't have it.

I'm also adding this to support both constant compleitions, but also it will mean effectively any word in typing will become a *unknown_const reference.

To support showing constant types on hover of constant references, we need to add them to the ref map.
@muglug
Copy link
Copy Markdown
Collaborator

muglug commented Jan 27, 2021

Mind fixing the Psalm issue and test?

@joehoyle
Copy link
Copy Markdown
Contributor Author

@muglug sorry, was looking for some guidance on:

For global constants (though not in a namespace), I wasn't yet able to see where they were stored (see the failing test). It looks like Codebase::getStubbedConstantType() doesn't have it.

Do you know what I'm doing wrong here? Where should I be looking for storage of constants in the root NS?

@muglug
Copy link
Copy Markdown
Collaborator

muglug commented Jan 28, 2021

ConstantFetchAnalyzer::getGlobalConstType seems to be the one

@joehoyle
Copy link
Copy Markdown
Contributor Author

Ok fixed up the tests, I was wrongly assuming that defining a constant in any file will cause it to be added to global constants, but that doesn't seem to be the case. I guess just because a constant is defined in any file doesn't mean it is considered globally defined, as that file may not be loaded.

@muglug muglug merged commit 5759472 into vimeo:master Jan 28, 2021
@muglug
Copy link
Copy Markdown
Collaborator

muglug commented Jan 28, 2021

Thanks!

danog pushed a commit to danog/psalm that referenced this pull request Jan 29, 2021
* Add constant fetch to reference map

To support showing constant types on hover of constant references, we need to add them to the ref map.

* Fix root constants

* PHPCBF
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.

2 participants