MehediDracula / PHP-Namespace-Resolver

PHP Namespace Resolver - VSCode Extension
https://marketplace.visualstudio.com/items?itemName=MehediDracula.php-namespace-resolver
MIT License
124 stars 31 forks source link

Extension is not working in v1.19.2 #18

Closed santigarcor closed 6 years ago

santigarcor commented 6 years ago

First I want to thank you for this extension it's awesome, but recently it stopped working. When I run the import class or expand class command nothing happens as you can see here:

peek 2018-01-17 07-56

Update: I debugged the extension and the problem seems to be in this line:

let namespaces = await this.findNamespaces(resolving, files);

after stopping the execution there, the debug console shows rejected promise not handled within 1 second.

MehediDracula commented 6 years ago

I've just tested on vscode v1.19.2 it's working here what is the version of the extension?

santigarcor commented 6 years ago

I have the 0.9.8. I think the problem happens when there are a lot of namespaces or files.

MehediDracula commented 6 years ago

can you please confirm this by testing on a small project?

santigarcor commented 6 years ago

I tested it in a smaller project and it worked fine

MehediDracula commented 6 years ago

i just tested on a large symfony app which has 150+ package. it's working here :confused:

santigarcor commented 6 years ago

It's weird, because for some reason in the debug console it shows this warning/error rejected promise not handled within 1 second.

I'll do more tests in the project that is being problematic and i'll let you know

santigarcor commented 6 years ago

The problem is that an exception is being thrown in this line inside the parseNamespaces method:

if (textLine.startsWith('namespace ') || textLine.startsWith('<?php namespace ')) { // Here you allow the namespace in the same line as the php tag.
  let fqcn = `${textLine.match(/^namespace\s+(.+)?;/).pop()}\\${resolving}`; // But here the regex doesn't include that.

The problem is the regex, because when the namespace is not in a single line it doesn't match with the regex. I'll submit a PR to fix it.

MehediDracula commented 6 years ago

thanks for the PR :relieved: