• Login
Community
  • Login

Custom static function with parameter hints.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 639 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Martijn Wieringa
    last edited by Aug 6, 2019, 9:33 AM

    I’m trying to add some custom functions to the php.xml file so parameter hints can be available.
    With normal functions it works fine:

    <KeyWord name=“myFunction” func=“yes”>
    <Overload retVal=“string”>
    <Param name=“string sValue”/>
    <Param name=“bool bValue”/>
    </Overload>
    </KeyWord>

    if i type “myFunction(” in a php file, the parameter hints show up perfectly.

    But when i add a static function:

    <KeyWord name=“myClass::myStaticFunction” func=“yes”>
    <Overload retVal=“string”>
    <Param name=“string sValue”/>
    <Param name=“bool bValue”/>
    </Overload>
    </KeyWord>

    It doesnt seem to work. I expected when i type “myClass::myStaticFunction(” parameter hints would show up… but they dont. Howcome?

    1 Reply Last reply Reply Quote 0
    • P
      PeterJones
      last edited by Aug 6, 2019, 1:43 PM

      @Martijn-Wieringa said:

      they don’t. How come?

      I believe it’s because :: are not “word characters”. The Settings > Preferences > Delimiters is supposed to allow you to specify extra characters, but it doesn’t always work right. (I just tried in this case, but couldn’t get it to work.)

      It also might mess up the sorting: I know that when I was looking at the new copy of the auto-completion documentation, I learned that you must properly sort the <KeyWord> tags, otherwise they will not be recognized. But even when sorted correctly (as far as I could tell), I couldn’t get it to work with :: in it.

      Not tested, but you might want to try having a non-function auto-complete entry for the full <KeyWord name="myClass::myStaticFunction" />, and then a yes-function entry for the name="myStaticFunction" with the complete overload/param definition. I don’t know if it will work, but it’s worth a try. Or just not include the myClass:: prefix at all (or make the non-function entry just be myClass::, and the full definition the yes-function version. (If your reason for not wanting to do that was that different classes uses different parameter lists for the same function, you may be able to use multiple <Overload> tags for the same function.

      1 Reply Last reply Reply Quote 2
      • M
        Martijn Wieringa
        last edited by Aug 7, 2019, 6:28 AM

        @PeterJones

        I thought it had something to do with ::
        Based on your info, i now use this workaround:

        <KeyWord name=“myStaticFunction” func=“yes”>
        <Overload retVal=“myClass | string”>
        <Param name=“string sValue”/>
        <Param name=“bool bSort”/>
        </Overload>
        <Overload retVal=“myClass2 | string”>
        <Param name=“string sValue”/>
        <Param name=“bool bSort”/>
        </Overload>
        <Overload retVal=“myClass3 | array”>
        <Param name=“string sValue”/>
        <Param name=“bool bSort”/>
        </Overload>
        </KeyWord>

        I’ve added "myClassName | " before each return value so i can easily find the parameter list i need for given class…
        it’s not as perfect as it could/should be, but it will work for now. Hopefully they’ll make a fix in the future ;)

        Thanks for your help!

        1 Reply Last reply Reply Quote 2
        2 out of 3
        • First post
          2/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors