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

Fully qualified namespace not found #17

Open
tonglil opened this issue Jun 11, 2015 · 6 comments
Open

Fully qualified namespace not found #17

tonglil opened this issue Jun 11, 2015 · 6 comments

Comments

@tonglil
Copy link

tonglil commented Jun 11, 2015

Can't seem to insert some use statements for classes.

I have verified that they are indeed in the tags file.

@arnaud-lb
Copy link
Owner

Hi @tonglil,

Could you provide an example (tag file + the file where the class is declared) ?

@tonglil
Copy link
Author

tonglil commented Jun 23, 2015

Yes, when it happens again I will provide the directory structure, the file, and the tag file.

I might have to redact some things though but we shall see. If I do, I will say what.

@mikedfunk
Copy link
Contributor

+1 been getting the same problem for quite a while. I will see if I can recreate the problem.

@dstrunk
Copy link

dstrunk commented Oct 20, 2017

I'm getting this issue in a new Laravel project. I've recorded a screencap to show what exactly is happening in my case. For demonstration purposes, I removed the tags file and regenerated it manually. To demonstrate that the plugin works on certain files, I added the namespace of the class directly in the file. Then I attempted to add the same namespace to a file within tests/Unit, after which I got the "Fully qualified namespace not found":

php-namespace-post

Here's the generated tags:

https://gist.github.com/dstrunk/f56eb483a829fc95d1e2a90eb43465ec

I'm using Universal ctags (ctags.io), version d9d7aa7

@ghost
Copy link

ghost commented Dec 8, 2019

Same error message. I am running NVIM v0.4.3 on Ubuntu 18.04 and create my tags file using Universal Ctags which I have built rather than snap installed.
While trying to insert a Use Statement I seem to run into two problems inside the PhpFindFqn(name) function:

  1. This try-catch block
    try wincmd P catch /.*/ return endtry 1
    The wincmd P does not seem to work. If I comment that out

  2. These if-statements:

        if search('^\s*\%(/\*.*\*/\s*\)\?\%(\%(abstract\|final\)\_s\+\)*\%(class\|interface\|trait\)\_s\+' . a:name . '\>') > 0
            if search('^\%(<?\%(php\s\+\)\?\)\?\s*namespace\s\+', 'be') > 0
                let start = col('.')
                call search('\([[:blank:]]*[[:alnum:]\\_]\)*', 'ce')
                let end = col('.')
                let ns = strpart(getline(line('.')), start, end-start)
                return ['class', ns . "\\" . a:name]
            else
                return ['class', a:name]
            endif
        elseif search('^\s*function\_s\+' . a:name . '\>') > 0
            if search('^\%(<?\%(php\s\+\)\?\)\?\s*namespace\s\+', 'be') > 0
                let start = col('.')
                call search('\([[:blank:]]*[[:alnum:]\\_]\)*', 'ce')
                let end = col('.')
                let ns = strpart(getline(line('.')), start, end-start)
                return ['function', ns . "\\" . a:name]
            else
                return a:name
            endif

        else
            throw a:name . ": not found!"
        endif

do throw a:name . ": not found!" so I figure the regex does not fit may tags file. I am running this inside a test project trying to insert an import for the HomeService (so I shortend the tags file contents):

430-0	composer.json	/^        {$/;"	o	array:authors
478-HomeHandler	src/Handler/HomeHandler.php	/^class HomeHandler$/;"	c	namespace:WithoutForm\\Test\\Handler
581:HomeService	src/Service/HomeService.php	/^class HomeService$/;"	c	namespace:WithoutForm\\Test\\Service
684-WithoutForm\\\\Test\\\\	composer.json	/^        "WithoutForm\\\\Test\\\\": "src\/"$/;"	s	object:autoload.psr-4
795:__construct	src/Handler/HomeHandler.php	/^    public function __construct(HomeService $homeService)$/;"	f	class:WithoutForm\\Test\\Handler\\HomeHandler
947:__construct	src/Service/HomeService.php	/^    public function __construct()$/;"	f	class:WithoutForm\\Test\\Service\\HomeService
1075-authors	composer.json	/^    "authors": [$/;"	a
1122-autoload	composer.json	/^    "autoload": {$/;"	o

@arnaud-lb
Copy link
Owner

Hi,

The plugin works like this:

  1. Use the tagfile to find where the class is declared
  2. If there are multiple declarations of the same symbol, prompt the user
  3. Open the class in the preview window
  4. Find the namespace of the class in the preview window
  5. Close the preview window

The error fully qualified class name was not found is not displayed when steps 1-3 fail, so they were probably successful here.

Could you provide a php file and a tag file where this can be reproduced ?

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

No branches or pull requests

4 participants