Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Using dreamweaver.codeHints.addFunction() in CS4

Contributor ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

Hello,

I have developed an extension (PHP Code Hints) which finds custom PHP variables and functions and adds them to Dreamweaver Code Hints using dw.codeHints.addMenu() and dw.codeHints.addFunction(). It was developed on CS3. Now, both functions have additional parameters on CS4.


PHP Code Hints still works fine on CS4 without any modifications as far as variables (use of addMenu) are concerned. But using addFunction does not yield the desired results: custom functions do not appear anymore in code hints. Yet they seem to be recorded somehow since when you type the parenthesis after the function name in source code, the name of the function and its arguments are shown as a tooltip:

CodeHintsFunctionsCS4.png

Here's my code which works on CS3:

function AjouterIndicateursFonctions(arrFonctions) {
     var i = 0;


    if (arrFonctions != null) {           
         // Reset function codehints
         dreamweaver.codeHints.resetMenu("CodeHints_Function_Arguments", arrFonctions, "PHP_MySQL");
         // Inserts functions into codehints
         for (i = 0; i < arrFonctions.length; i++) {
             // Rebuilds function list
             dw.codeHints.addFunction(
                         "CodeHints_Function_Arguments",     // Menu group
                         arrFonctions,                                    // Functions to add
                         "PHP_MySQL",                                            // Document types
                         false)                                                        // Case sensitiveness
         }
     }
}

CS4 documentation on dw.codeHints.addFunction() gives the new arguments, but it is not very understandable without an example (the given one has not been updated from... MX?), and types are not always described. So I am stuck on this problem and cannot find an answer. I was advised by David Powers to ask the forum for help, especially from Randy Edmunds.

So can you help on how to use the addFunction() on CS4?

Thank you in advance.

Best regards,


Xavier Pitel

TOPICS
Extensions

Views

4.5K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jun 04, 2009 Jun 04, 2009

Aw, crud, I messed that up. Solution below:

dw.codeHints.addFunction(
    "CodeHints_Function_Arguments",  // Menu group
    arrFonctions,                 // Functions to add
    "PHP_MySQL",                     // Document types
    false)                           // Case sensitiveness

You need to add 2 more parameters to this call so that it looks like this:

dw.codeHints.addFunction(
    "CodeHints_Function_Arguments", // Menu group
    arrFonctions,                 // Functions to add
    "PHP_MySQL

...

Votes

Translate
Adobe Employee ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

Xavier,

I have developed an extension (PHP Code Hints) which finds custom PHP variables and functions and adds them to Dreamweaver Code Hints using dw.codeHints.addMenu() and dw.codeHints.addFunction(). It was developed on CS3. Now, both functions have additional parameters on CS4.


PHP Code Hints still works fine on CS4 without any modifications as far as variables (use of addMenu) are concerned. But using addFunction does not yield the desired results: custom functions do not appear anymore in code hints. Yet they seem to be recorded somehow since when you type the parenthesis after the function name in source code, the name of the function and its arguments are shown as a tooltip...

Yes, there are new parameters added, but they are all optional, so it should not make a difference.

Did you check to see if the function names are in the list, but maybe in a different place (i.e. not in alphabetic order) ?

Otherwise, send me a private e-mail in this forum so I can get a copy of your extension.

Randy

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

Hello Randy,

Thank you for your answer.

I have double-checked, but custom functions do not appear in the list, even in non-alphabetical order. And should they be in non-alphabetical order, it would not be a problem if they are correctly selected as you type. But none of this happens.

There's one paramater that seems not to be optional - 'source' -, but that should default to "empty", maybe that's the problem?

I have sent you my extension through private mail.

If you test it on CS3 and CS4, you'll see that it works on the former, but partly on the latter. As previously indicated, though, customs functions seem to be recorded somehow since when you type the parenthesis after the function name in source code, the name of the function and its arguments are shown as a tooltip...

Thanks a lot for your help.

Best regards,

Xavier Pitel

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 02, 2009 Jun 02, 2009

Copy link to clipboard

Copied

Xavier,

dw.codeHints.addFunction(
    "CodeHints_Function_Arguments",  // Menu group
    arrFonctions,                 // Functions to add
    "PHP_MySQL",                     // Document types
    false)                           // Case sensitiveness

You need to add 2 more parameters to this call so that it looks like this:

dw.codeHints.addFunction(
    "CodeHints_Function_Arguments", // Menu group
    arrFonctions,                 // Functions to add
    "PHP_MySQL",                     // Document types
    false,                           // Case sensitiveness

    false,                           // bClassPattern (default)

    true)                            // bAddToObjectMethodList

The documentation here:

http://help.adobe.com/en_US/Dreamweaver/10.0_API_Ref/WS5b3ccc516d4fbf351e63e3d117f9e08d19-7ff9.html

states that bAddToObjectMethodList defaults to true, but that is incorrect. It actually defaults to false.

Sorry for the disconnect,

Randy

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 04, 2009 Jun 04, 2009

Copy link to clipboard

Copied

Aw, crud, I messed that up. Solution below:

dw.codeHints.addFunction(
    "CodeHints_Function_Arguments",  // Menu group
    arrFonctions,                 // Functions to add
    "PHP_MySQL",                     // Document types
    false)                           // Case sensitiveness

You need to add 2 more parameters to this call so that it looks like this:

dw.codeHints.addFunction(
    "CodeHints_Function_Arguments", // Menu group
    arrFonctions,                 // Functions to add
    "PHP_MySQL",                     // Document types
    false,                           // Case sensitiveness

    false,                           // bClassPattern (default)

    true)                           // bAddToObjectMethodList

The bAddToObjectMethodList parameter does default to true as the documentation states, but you need to use false. And there are several other parameters between those 2, so here's what I used to get it to work:

dw.codeHints.addFunction(
     "CodeHints_Function_Arguments",     // Menu group
     arrFonctions,                   // Functions to add
     "PHP_MySQL",                       // Document types
     false,                             // Case sensitiveness
     "",             // object
     "",             // description
     "",             // icon
     "",             // source
     "",             // DocURI
     false,         // bClassPattern
     false);         // bAddToObjectMethodList

I just added empty strings for the other parameters to mimic the defaults. Play around with it and see if you need/want to put something in those.

Regards,

Randy

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

Thank you so much, Randy, for showing the right solution.

I am still curious about the description (where does it appear?), the source (what is it?), the bAddToObjectMethodList(how to use it?) and the restriction (which strings are allowed?) arguments, though. I wish the documentation would be a little more explicit and give thorough examples on these new arguments.

Thanks again,

Xavier

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

Here's some more info I found:

source:
list the filename where the codehint is generated from (specially if they are built on fly from other included ajax libraries e.g. SpryAccordion.js).

bAddToObjectMethodList:
when the function signature (pattern) has something like “foo.abc(x, y)” for class foo, it will add the static method “abc(x,y)” to class foo when this flag is set to true.

restriction:
it is used to filter for different code block section in a single doc type (e.g. Javascript code hints are only available within <script> tag boundaries) since they can still appear in PHP docs in client side code blocks.

description:
is currently does not appears to be used but was supposed more info/documentation in the tooltip, may be we will use in future release.

HTH,

Randy

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

Correction-

description:

does appears in “tooltip” as you step up/step down through the function list provided that description is supplied.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 07, 2009 Jun 07, 2009

Copy link to clipboard

Copied

And one more clarification: you cannot add any formatting to 'description', other than "line breaks" (which are added by simply inserting a '\n' in the string).

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 08, 2009 Jun 08, 2009

Copy link to clipboard

Copied

LATEST

Thank you, Virgil, for this clarification.

Best regards,

Xavier

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 08, 2009 Jun 08, 2009

Copy link to clipboard

Copied

Thank you very much, Randy, I will try and use this in a future version of PHP Code Hints.

Regards,

Xavier

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

how to use a dreamweaver extensions to add an mp3 to my cat breeds web page http://www.catwebsite.org?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 06, 2009 Jun 06, 2009

Copy link to clipboard

Copied

Please start a new forum post for new questions.

Try searching the Dreamweaver Exchange for "mp3":

http://www.adobe.com/cfusion/exchange/index.cfm?searchfield=mp3&search_exchange=3&search_category=-1&search_license=&search_rating=&search_platform=0&search_pubdate=&num=25&startnum=1&event=search&sticky=true&sort=0&Submit=

Randy

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines