Skip to content

ContextMenuHandler looks for the closest resolvable node#784

Closed
camilledejoye wants to merge 4 commits intophpactor:developfrom
camilledejoye:bugfix-777
Closed

ContextMenuHandler looks for the closest resolvable node#784
camilledejoye wants to merge 4 commits intophpactor:developfrom
camilledejoye:bugfix-777

Conversation

@camilledejoye
Copy link
Copy Markdown
Contributor

Fixes #777

I guess it's more a feature than a bugfiix but whatever :)

@dantleech
Copy link
Copy Markdown
Collaborator

hmm, I can't reproduce the fix based on the ticket (invoking context menu in empty space), and there is a third argument to reflectOffset ... is something missing?

@camilledejoye
Copy link
Copy Markdown
Contributor Author

camilledejoye commented Jun 19, 2019

Will look into it tomorrow

[EDIT] I wont have the time, but I indeed forgot a PR on the worse-reflection package to go along with it...
Will try to do it as soon as possible.

@camilledejoye
Copy link
Copy Markdown
Contributor Author

Just made phpactor/worse-reflection#57
Which is the missing part that explains why it was not working.
The only changes here are the fact that we use the position of the reflected offset instead of the one provided to the handler, since the node resolver will return the closest node to the offset instead of the node of the offset if it is unknown.

@dantleech
Copy link
Copy Markdown
Collaborator

We could update this to use the suggested interesting offset finder.

@camilledejoye
Copy link
Copy Markdown
Contributor Author

Yes, I may have talk about it here instead of in the worse-reflection package.
As soon I will have the time to make it work I will close the PR in the worse-reflection package and update this one.

@camilledejoye
Copy link
Copy Markdown
Contributor Author

camilledejoye commented Oct 13, 2019

Hi,

I'm working on closing this feature.
Already make a few comments on related PR in others repositories.
For this one we have to merge phpactor/code-transform#26 before.
And another one I will open on https://github.com/phpactor/code-transform-extension, I will update this message once the PR will be created.
The PR will register the Interesting offset finder as a service on the extension and allow us to it here for the ContextMenuHandler.

Edit: the PR link phpactor/code-transform-extension#1

@camilledejoye
Copy link
Copy Markdown
Contributor Author

@ping composer.lock updated to take the new changes into account
The CI should not be an issue

@dantleech
Copy link
Copy Markdown
Collaborator

dantleech commented Oct 13, 2019

Seems to be an issue:

Phpactor\Tests\Unit\Extension\ContextMenu\Handler\ContextMenuHandlerTest::testNoActionsAvailable
TypeError: Argument 2 passed to Phpactor\Extension\ContextMenu\Handler\ContextMenuHandler::__construct() must implement interface Phpactor\CodeTransform\Domain\Helper\InterestingOffsetFinder, instance of Double\Phpactor\Extension\Core\Application\Helper\ClassFileNormalizer\P53 given, called in /home/travis/build/phpactor/phpactor/tests/Unit/Extension/ContextMenu/Handler/ContextMenuHandlerTest.php on line 64

@camilledejoye
Copy link
Copy Markdown
Contributor Author

My bad didn't checked the unit tests, so used to have a hook on git push...

@dantleech
Copy link
Copy Markdown
Collaborator

dantleech commented Oct 13, 2019

Have done a qucik manual test:

In lib/Phpactor.php:

        $loader = ConfigLoaderBuilder::create()
            ->enableJsonDeserializer('json')
            ->enableYamlDeserializer('yaml')
            ->addXdgCandidate('phpactor', 'phpactor.json', 'json')
            ->addXdgCandidate('phpactor', 'phpactor.yml', 'yaml')
            ->addCandidate($cwd . '/.phpactor.json', 'json')
            ->addCandidate($cwd . '/.phpactor.yml', 'yaml')
            ->loader();

Invoking the context menu on any of the above methods gives the menu for the ConfigLoaderBuilder.

Can you reproduce? Seems to be the case for all methods calls. If so it's might be a bug in the "interesting offset finder" ....

@dantleech
Copy link
Copy Markdown
Collaborator

It's an issue with the offset finder, I tried to fix it this morning but failed, I created a failing test: https://github.com/phpactor/code-transform/pull/28/files.

@dantleech
Copy link
Copy Markdown
Collaborator

I fixed this case in code-transform, will test again tomorrow.

@camilledejoye
Copy link
Copy Markdown
Contributor Author

Seems to be working on quick tries.
Will see how today goes at work, that will gave me more examples :)
Nice job.

@dantleech
Copy link
Copy Markdown
Collaborator

Replacing with #825

@dantleech dantleech closed this Oct 15, 2019
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.

Context menu: Unknown symbol (or whitespace) should assume parent context.

2 participants