dumb-jump icon indicating copy to clipboard operation
dumb-jump copied to clipboard

PHP : won't jump to definition in other file if misleading pattern found locally

Open kermorgant opened this issue 7 years ago • 4 comments

Hi,

Thanks for this nice package !

I've tried to jump to the definition of 'Symfony\Bundle\FrameworkBundle\Controller\Controller' or 'Symfony\Component\HttpFoundation\Request' from the following file, but it will only loop inside the similar strings inside the file. On the other hand, jumping to Security works quite well.

 <?php

namespace AppBundle\Controller;

use AppBundle\Event\AppEvents;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;

/**
 * Annuaire controller.
 *
 * @Route("annuaire")
 */
class AnnuaireController extends Controller
{

    /**
     * @Route("/", name="annuaire")
     */
    public function indexAction(Request $request)
    {
        $form = $this->get('form.factory')->create(FicheFilterType::class);

        return $this->render('annuaire/index.html.twig', [
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/resultats", name="annuaire_resultats")
     */
    public function searchAction(Request $request)
    {
        $form = $this->get('form.factory')->create(FicheFilterType::class);
        $paginator  = $this->get('knp_paginator');

        $qb = $this->get('doctrine.orm.entity_manager')
            ->getRepository('AppBundle:Fiche')
            ->createQueryBuilder('f');

         ....
    }
}

kermorgant avatar May 20 '17 20:05 kermorgant

Thanks for this nice package !

You're welcome. Happy to hear you like it!

but it will only loop inside the similar strings inside the file

Thanks for the report. I am guessing this is just the aggressive mode not working in your case. Please try setting dumb-jump-aggressive to nil like this (setq dumb-jump-aggressive nil).

jacktasia avatar May 20 '17 20:05 jacktasia

Ok, indeed, thanks :)

Just by curiosity, do you think it would be thinkable to take namespace declarations into consideration for the suggestions ? (that would be a huge benefit for the 'Controller' example)

kermorgant avatar May 21 '17 07:05 kermorgant

Ok, indeed, thanks :)

No problem.

Just by curiosity, do you think it would be thinkable to take namespace declarations into consideration for the suggestions ? (that would be a huge benefit for the 'Controller' example)

dumb-jump isn't currently setup in a way that would make that easy, but it's definitely possible it would just require chainable rules (and regular expressions). I've thought a bit about this while making dumb-jump -- and it probably is the next logical step at improving dumb-jump -- but I haven't had the time to come up with a good generic system and it would certainly be another big step away from keeping it "dumb".

That said, I'll update this issue if/when I get more time to consider this, but happy to discuss implementation ideas or accept PRs.

jacktasia avatar May 21 '17 19:05 jacktasia

I'm affraid I won't be able to help you much but I'd happily help with tests if needed :)

Maybe you know about it , but I just saw ede-php-autoload today , and although I still have some issues with it, it has the same convenience as dumb-jump as to avoid setting up code indexing strategies (given you have composer managing the autoloader). Maybe it can give some ideas ?

kermorgant avatar May 21 '17 20:05 kermorgant