The purpose of this tutorial is to teach you how to use PDT 's Content Assist function in order to write code quickly, easily, and accurately.
|
|
|
|
Making Content Assist Elements Available Within the Same Scope |
|
|
|
|
|
|
The Content Assist feature enables the selection and insertion of existing code elements to complete partially entered code.
A list of possible code elements appears in relevant locations within your files according to the context of your cursor, which you can then select to be automatically entered into your code.
Each type of code element will have a unique icon:
Reserved PHP Words |
|
Functions |
|
Templates |
|
Classes |
|
Interfaces |
|
Constants |
|
Variables (public) |
Content Assist works with the following elements: PHP Classes, Functions, Variables, Constants, Keywords, Interfaces, Attributes, Values, Nested Functions, Names and Syntax, as well as all user defined Classes, Functions, and Constants.
Note:
Content Assist works with both PHP and HTML.
By default, the Content Assist options will be automatically displayed once the first few characters of the code have been entered.
|
|
The following procedure demonstrates using Content Assist:
|
|
"define()" appears on the edit line. |
Note:
If the Content Assist window does not open automatically,
place your cursor at the required location and press Ctrl+Space.
To enable the Content Assist window to open automatically, go to the Content Assist Preferences page, accessed
from Window | Preferences | PHP | Editor
| Content Assist and mark the 'Enable auto-activation' checkbox.
When entering a function call, a Function Parameter Hint box will be displayed detailing the types of parameters that should be entered within the parentheses of the function call.
|
|
The following procedure demonstrates using the Function Parameter Hint feature:
|
|
A function parameter hint box will be displayed indicating the types of parameters that should be inserted between the parentheses. |
Elements within the same scope (e.g. within the same project, file or function) will be available for use with Content Assist.
Variables belonging to different scopes are not available to each other via Content Assist.
|
|
The following procedure demonstrates using Content Assist for inserting elements within the same function and file:
<?php define('continent','africa'); $control = ''; $mail = 'int@eclipse.org'; function media() { $music = ''; $messenger = ''; $ /*--------- Location_1*/ } $ /* ---------Location_2*/ ?>
|
|
|
Code elements defined in one file are also available for use by other files within the same project.
|
|
The following steps demonstrate using Content Assist for inserting elements within the same project:
|
|
When the element is highlighted, Content Assist displays the original location of the code element, its value ('africa') and all other information available. |
By using a comment you can assign a variable its exact class value. This assignment will affect the content assist of this variable accordingly.
|
|
To see and trial this feature:
<?php function getClass() { return new Test(); } class Test { function printValues($a, $b) { echo "Values: $a, $b"; } }
/* @var $myVar Test */ $myVar = getClass();
$myVar-> ?>
|
|
|
Note:
Without the comment, Content Assist will not be available for the function.
Content Assist options can be configured through the Content Assist Preferences page, accessible from Window | Preferences | PHP | Editor | Content Assist.
|
|
Related Links |
|
|
|