Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 10 00:53
    kibblewhite edited #814
  • Jun 10 00:47
    kibblewhite edited #814
  • Jun 10 00:45
    kibblewhite edited #814
  • Jun 10 00:45
    kibblewhite edited #814
  • Jun 10 00:44
    kibblewhite edited #814
  • Jun 10 00:43
    kibblewhite edited #814
  • Jun 10 00:41
    kibblewhite edited #814
  • Jun 10 00:34
    kibblewhite opened #814
  • Jun 08 15:08
    rickmedlin opened #813
  • Jun 06 12:29
    james090500 commented #779
  • Jun 04 04:50
    ghuntley opened #812
  • Jun 04 00:41
    h4de5 commented #462
  • May 29 15:17
    tskorupka commented #805
  • May 27 08:52
    Geekimo commented #779
  • May 18 15:35
    amasotti commented #779
  • May 14 01:24
    JoabioVilela commented #544
  • May 12 22:19
    gonzad26 opened #811
  • May 03 12:02
    rk0cc commented #809
  • Apr 30 16:22
    apfelchips commented #807
  • Apr 30 16:10
    apfelchips commented #807
Phil Nelson
@phil-nelson
say my files are in a git project and I switch branch. Is it up to the language server or client to recognise that files have changed and to reprocess them?
Felix Becker
@felixfbecker
you might have to reload your window for that.
there is no file watching atm
Phil Nelson
@phil-nelson
yeah I'm talking generally - should it be the responsibility of the client or server?
Felix Becker
@felixfbecker
the server needs to tell the client what files to watch, then the client tells the server about changes and the server needs to react
Phil Nelson
@phil-nelson
right ok - so sounds like the client could do inotify (or whatever) and tell the server about changes if they aren't open in the editor and they change
Felix Becker
@felixfbecker
I think there’s something in the protocol for this
Phil Nelson
@phil-nelson
right ok, I'll have a read. I'm trying to avoid having to reindex everything after changing branches, which I do quite often - even if it only takes a couple of minutes
would happily accept a PR
Phil Nelson
@phil-nelson
it does say "Servers are allowed to run there own file watching mechansim and not rely on clients to provide file events. However this is not recommended ..."
Felix Becker
@felixfbecker
I know
what’s your point?
Phil Nelson
@phil-nelson
I thought when you said you'd accept a PR that you were thinking it would be worth doing on the server side
Felix Becker
@felixfbecker
no, sorry
but the server needs to register what files to watch, implement didChangeWatchedFiles, remove the old state for the changed documents from the index and reindex those documents
Phil Nelson
@phil-nelson
ah right I see. I'll look into it after I get my head around how the indexing works to see if it makes sense to do for my signatureHelp PR
Felix Becker
@felixfbecker
I mean, it should definitely be a different PR
Phil Nelson
@phil-nelson
yeah
Felix Becker
@felixfbecker
did you read my review comment on the signature help PR?
Phil Nelson
@phil-nelson
yeah I've been looking into that. I'm not familiar with how the indexing works, this is a bit of a learning curve for me. I'm trying to figure out what we would store. Would it be a mapping of fqnd FunctionLike nodes (i.e. "[Foo][Bar][methodName] => Node") or store more specific signature information, like "[Foo][Bar][methodName] => [SignatureHelp]")
but for static analysis I don't thikn the SignatureHelp objects would be very useful, so perhaps some other objects that are more useful.
Felix Becker
@felixfbecker
for now, it’s probably enough to store SignatureHelp or a dead simple structure in the Definition class
Phil Nelson
@phil-nelson
@felixfbecker this needs a lot of tidying up but before I continue is this along the lines of what you're thinking? https://github.com/felixfbecker/php-language-server/compare/master...phil-nelson:signatureHelp-index
basically I made the TreeAnalyzer collect SignatureInformation and added that to the index, stored as fqn => SignatureInformation, then in the SignatureHelpProvider I can now just use $index->getSignatureInformation($fqn)
I still have to tidy things up/add doc blocks/make it wait for the index to finish in the same way Hover does if it doesn't find anything - but wanted to first check with you that this is what you were thinking
Felix Becker
@felixfbecker
No, I was thinking to add it as a field to the Definition class
like hovers are stored
Phil Nelson
@phil-nelson
@felixfbecker ok thanks - I've updated that branch if you have a chance to have a look for any more feedback
Felix Becker
@felixfbecker
looks great!
you should open a PR :)
see what CI says
Phil Nelson
@phil-nelson
will do, thanks for the help/feedback so far :)
Felix Becker
@felixfbecker
always awesome to see when someone takes the time to dig into the code and contribute!
Phil Nelson
@phil-nelson
@felixfbecker @jens1o this is a messy fix for the issue I found being discussed in #465:
diff --git a/src/DefinitionResolver.php b/src/DefinitionResolver.php
index 72bdce4..5a8f077 100644
--- a/src/DefinitionResolver.php
+++ b/src/DefinitionResolver.php
@@ -571,12 +571,25 @@ class DefinitionResolver

             // If we get to a ForeachStatement, check the keys and values
             if ($n instanceof Node\Statement\ForeachStatement) {
-                if ($n->foreachKey instanceof Node\Expression\Variable
+                $isForeachCollection = false;
+                if ($n->forEachCollectionName) {
+                    if ($n->forEachCollectionName === $var) {
+                        $isForeachCollection = true;                                                                                                                                           
+                    } else {                                                                                                                                                                   
+                        foreach ($n->forEachCollectionName->getDescendantNodes() as $childNode) {                                                                                              
+                            if ($childNode === $var) {                                                                                                                                         
+                                $isForeachCollection = true;                                                                                                                                   
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (!$isForeachCollection && $n->foreachKey instanceof Node\Expression\Variable
                     && $n->foreachKey->expression->getName() === $name
                 ) {
                     return $n->foreachKey;
                 }
-                if ($n->foreachValue
+                if (!$isForeachCollection && $n->foreachValue
                     && $n->foreachValue->expression instanceof Node\Expression\Variable
                     && $n->foreachValue->expression->getName() === $name
@jens1o are you able to apply the above to test your case by any chance?
Phil Nelson
@phil-nelson
the issue is that if the foreach item being iterated matches the foreach value, it gets into a loop trying to resolve that variable. So when traversing the AST "up" we need to find out if we got there from the foreach collection, or from inside the foreach loop. If we got there from the collection, we don't want to try and match the foreach key/value
Felix Becker
@felixfbecker
Sounds like you should just start your search at the parent node
Phil Nelson
@phil-nelson
the problem is I can't see a way to know when to do that, the collection being iterated in the ForeachStatementnode does not have an identifiable type like the ForeachKey or ForeachValue, it's just an Expression. So when traversing up, we don't know if we got to the ForeachStatement from within the loop or from the collection
Felix Becker
@felixfbecker
But every node has a parent node prop
so just start “traversing up” at the parent?
Khadija-Yusuf
@Khadija-Yusuf
Hello people its my first time learning php language today and I came across sum of two arrays php. If you could help me I would appreciate.Thank you.
Troy Patrick
@teasp00n
hey guys. cheers for your work on this project :)
i have a codebase that when I use this I hit the physical memory limit on my system. this is sub optimal :p are there any plans to cap memory usage for the in memory cache and implement some LRU eviction policy or something like that?
Nufflee
@Nufflee
hello
image.png
this is kinda offtopic but does anyone know how to achieve that the active parameter is underlined and bold in signature help? like here ^^^
Nufflee
@Nufflee
oh, and im sorry for that issue, it was an accident and i forgot to address it before
Filipe Luis 
@flschaves_twitter
hey guys, whats going on