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

ede-php-autoload-complete-type-name a bit odd #26

Closed
xendk opened this issue Apr 6, 2017 · 6 comments
Closed

ede-php-autoload-complete-type-name a bit odd #26

xendk opened this issue Apr 6, 2017 · 6 comments

Comments

@xendk
Copy link
Contributor

xendk commented Apr 6, 2017

Trying to use ede-php-autoload-complete-type-name for completion is a bit of a challenge, for PSR-4 at least.

At first it returns full namespaces, but when traversing down, it only returns the last component. Instinctively, I'd expect it to either complete single components all the way, or return the full namespace (which is easier to deal with in a completion engine). Any objections against it returning the full name?

Secondly, I could use some information on the completions, whether its a directory or file, for colorization, later on, but I guess that's out of scope for ede-php-autoload-complete-type-name? Any tricks for how to determine whether a string would end in a class file, or require further expansion?

@stevenremot
Copy link
Collaborator

Regarding the completion only returning the last part of the namespace, this was made like this to ease the integration with semantic. Maybe ede-php-autoload-complete-type-name can return a kind of structure which has several fields, like the full completion, the last, and whether it mapped to a file or not ?

@xendk
Copy link
Contributor Author

xendk commented Apr 6, 2017

It could... I'll try hacking about a bit and try it out.

It returning "." as part of files is a bug, right?

@stevenremot
Copy link
Collaborator

stevenremot commented Apr 6, 2017

I never noticed the "." stuff... This is not wanted for sure

@xendk
Copy link
Contributor Author

xendk commented Apr 9, 2017

I think the "." is only triggered by completing on a subdirectory.

I had a quick look but got entirely sidetracked, so I thought I'd just report in..

I'd really like to work from a failing test, but discovered that ede-php-autoload-completion.feature only tests completion for non-composer projects. Why I thought I needed a composer project, I really don't know, but I tried cloning the non-composer tests, and discovered they failed due to the fallback mechanism getting in the way. An example:

  Scenario: Complete PSR-0 namespace with slashes
    Given I visit "src/main.php" in project "with-composer"
    Then completions for query "Psr0Ns\T" should be:
      | TheClass |
      Opening directory: No such file or directory, /home/xen/.emacs.d/ede-php-autoload/test/projects/with-composer/src/Fallback/Psr0/Psr0Ns

While not really related to the problem at hand, there should probably be some tests covering this.

@xendk
Copy link
Contributor Author

xendk commented Apr 10, 2017

I've created #27 which addresses both the "No such file or directory" issue and the "." issue.

Back at the issue at hand: I've managed to get ede-php-autoload-complete-type-name to return a stub structure (only with the existing name so far), and rewritten the completion step definition to take a table of values like so:

    And completions for query "Psr4Ns\TheSubdir\" should be:
      | name      | full-name                  |
      | TheClass1 | Psr4Ns\TheSubdir\TheClass1 |
      | TheClass2 | Psr4Ns\TheSubdir\TheClass2 |

I'll only check the columns given and ignore the rest (I'm very proud of myself on that one).

Now it's "just" a matter of filling out the tests and make sure that ede-php-autoload-complete-type-name actually returns the proper values.

@stevenremot
Copy link
Collaborator

PR merged

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

2 participants