spectacles / CodeComplice

CodeIntel for Sublime Text 2 / 3
Other
168 stars 18 forks source link

[Request] Autocomplete when implements an interface, abstract methods #3

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi

  1. Sometimes i extends an abstract class or implements an interface eg \ArrayAccess. The Interface require implements methods offsetGet, offsetSet..etc. Could you tell CodeComplice auto implements the methods ?
  2. previous version, you implemented construct, destruct methods, but still missing dynamic method get, set.
wizza-smile commented 9 years ago
  1. That's a good feature request! It should be possible, but first we'd have to fix 'Interfaces' per se. after extends it shows only classes, no Interfaces.
  2. if I type
class MyClass {
    public function __g  ( shows =>
         __get()
         __toString()
       )

so get (and set) are already working!

ghost commented 9 years ago

Ok, confirmed get, set are working, just previous it's indexing project so not shows.

wizza-smile commented 9 years ago

hey @ptcong, I implemented completions for Interfaces (v1.0.4). Now if you are

class MyClass implements ArrayAccess 
{

  public function [here]

}

it will show you all functions of ArrayAccess and complete with arguments! If you could play around with it and give me feedback on how to improve, fantastic!

Hope to hear from you soon!

ghost commented 9 years ago

Ok, i got it, but is there anyway to click to ArrayAccess and choose option implements all methods ? It is faster if the implemented class have many methods.

And is the feature works on project ?, i mean project have interfaces, abstract class.

spectacles commented 9 years ago

so, here it is, v1.0.5! If you now have this code and you are

abstract class AbstractClass
{
    abstract protected function method1();
    abstract protected function method2($arg);
}

class MyClass extends AbstractClass implements ArrayAccess
{

    [here]

}

and you call for completions with ctrl+shift+space (or whatever your key-binding is), it will show you

ArrayAccess (inherited)
AbstractClass (inherited)

which will give you completions for all methods. I am not sure if 'inherited' is technically correct here but it's close enough for now ;)

Please be sure to give feedback, is this working in your projects as well?

all the best!

ghost commented 9 years ago

Thax u, then when it available on packagecontrol.io ?

spectacles commented 9 years ago

I published it right now. I have no control over PackageControl inner update cycle, so I don't know when exactly you will receive your update, but it never took longer than 6 hours for me!

ghost commented 9 years ago

I just downloaded from git, it's amazing~ :dancer: But have you written block comment for methods of ArrayAccess ?

And could you implement the interfaces to http://php.net/manual/en/spl.misc.php

ghost commented 9 years ago

@wizza-smile The feature seem ok, but it missing arguments type hint. Eg:

abstract class AbstractClass
{
    abstract protected function method1();
    abstract protected function method2(ClassName $arg);
}

class MyClass extends AbstractClass implements ArrayAccess
{

    [here]

}

When i request implements AbstractClass, it complete

/** dockblocks **/
protected function method1();
/** dockblocks **/
protected function method2($arg);

It should be

/** dockblocks **/
protected function method1();
/** dockblocks **/
protected function method2(ClassName $arg);

Missing ClassName in method2. Could you resolve it ?

spectacles commented 9 years ago

I just pushed a commit that should resolve this issue!

ghost commented 9 years ago

i just downloaded and overrides to ST/Packages/CodeComplice but nothing happend

spectacles commented 9 years ago

Is this working for you now?

ghost commented 9 years ago

yes, works fine man

spectacles commented 9 years ago

:+1: