Search code examples
netbeansautocompletecode-templates

vdoc for php in Netbeans 6.9.1 seems not working


When I insert a vdoc, like discriped here, Netbeans not offers any suggestions:

/* @var $persistenceManager Tx_Extbase_Persistence_Manager */
$persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
$persistenceManager-> // no suggestions here

The switch of variablename and type has not changed the result. What is it, what I'm making wrong or is it just a bug?

My Netbeans Version:

Product Version: NetBeans IDE 6.9.1 (Build 201011082200)
Java: 1.6.0_23; Java HotSpot(TM) Client VM 19.0-b09
System: Windows 7 version 6.1 running on x86; Cp1252; de_DE (nb)

Solution

  • I suppose it is not technically a bug, but it is just as annoying as a mosquito buzzing in your ear. :-)

    The expansion of code templates from their abbreviations can be short-circuited by a few things. For example, if you start to type the abbreviation, make a mistake, backspace to erase and correct just a few characters but not the whole thing, then NetBeans won't detect that the abbreviation for the template was typed, and thus won't expand it. A little more commonly, if what you type opens up the auto-completion pop-up first, then the expansion of code templates is also stopped.

    When I tried out vdoc, the auto-completion pop-up got in the way for me. Likely, it is the same for you. If you type it quickly enough with the expansion key so that the auto-completion does not pop-up, it will probably work.

    Unfortunately, there is no easy switch or setting to control how quickly auto-completion shows up. Fortunately, there is a way to set it. I am assuming from your link and interest in "vdoc" that you are working on PHP files, so we'll set the auto-completion delay for that.

    • Open windows explorer and go to %USERPROFILE%\.netbeans\config\Editors\text. (%USERPROFILE% can be typed directly into the explorer path bar just like it was a path itself, or you can go to the C:\Users\your-log-in-name directory.)
    • Unless you already have one (I didn't) create a directory called x-php5
    • Inside that directory, create a sub-directory called Preferences
    • Inside that directory, create a text file named:
      org-netbeans-modules-editor-settings-CustomPreferences.xml
    • Open that file with a text editor, and put in the following:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE editor-preferences PUBLIC "-//NetBeans//DTD Editor Preferences 1.0//EN" "http://www.netbeans.org/dtds/EditorPreferences-1_0.dtd">
      <editor-preferences>
          <entry name="completion-auto-popup-delay" value="3000" />
      </editor-preferences>
      
    • Save it.

    • Stop and restart your NetBeans.
    • Give code template expansion a try.

    The completion-auto-popup-delay is set in milliseconds, so the above resets it to three (3) seconds. That is obviously too long to be useful. Once you get the code completion expansion working properly, go back in and edit the XML configuration file, and reduce the delay in increments until you are comfortable that you have both enough time to type and expand a code template, and that your auto-completion pop-up doesn't take an inordinate amount of time to react. It will be a balancing act.

    I don't know if it is strictly needed, but I made sure to stop and re-start NetBeans each time I made a change to the XML file.

    Also:

    Make sure you are typing the correct expansion key(s) after the abbreviation. I changed mine to SHIFT-Space and forgot all about it.

    • In NetBeans, Click on Tools then Options
    • In the Options dialog, click on the Editor icon in the toolbar
    • Click on the Code Templates tab
    • Check (and if necessary, change) the Expand Template on setting

      alt text