blob: 6f7a148fc5b8a58238519fdbd19f7f69863dd338 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="copyright" content="Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/. Contributors: IBM Corporation - initial API and implementation" />
<meta name="DC.rights.owner" content="(C) Copyright 2000, 2008" />
<meta content="public" name="security" />
<meta content="index,follow" name="Robots" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta content="concept" name="DC.Type" />
<meta name="DC.Title" content="Content assist" />
<meta name="abstract" content="Content assist helps you insert or finish a tag or function or finish a line of code in a structured text editor. The placement of the cursor in the source file provides the context for the content assist to offer suggestions for completion." />
<meta name="description" content="Content assist helps you insert or finish a tag or function or finish a line of code in a structured text editor. The placement of the cursor in the source file provides the context for the content assist to offer suggestions for completion." />
<meta content="content assistance, overview, structured text editors, content assistance" name="DC.subject" />
<meta content="content assistance, overview, structured text editors, content assistance" name="keywords" />
<meta scheme="URI" name="DC.Relation" content="csrcedt004.html" />
<meta scheme="URI" name="DC.Relation" content="tsrcedt005.html" />
<meta scheme="URI" name="DC.Relation" content="tsrcedt024.html" />
<meta content="XHTML" name="DC.Format" />
<meta content="csrcedt006" name="DC.Identifier" />
<meta content="en-us" name="DC.Language" />
<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
<title>Content assist</title>
</head>
<body id="csrcedt006"><a name="csrcedt006"><!-- --></a>
<h1 class="topictitle1">Content assist</h1>
<div><p>Content assist helps you insert or finish a tag or function or
finish a line of code in a structured text editor. The placement of the cursor
in the source file provides the context for the content assist to offer suggestions
for completion.</p>
<p>Most of the structured text editors have content assist. For a list of
editors that have content assist, see <a href="csrcedt004.html">Structured text editors for markup languages</a>. For information on how to get content
assistance, see <a href="tsrcedt005.html">Getting content assistance in structured text editors</a></p>
<p>The sections below describe specifics of HTML content assist, JavaScriptâ„¢ content
assist, and JSP content assist.</p>
<div class="section"><h4 class="sectiontitle">HTML content assist</h4><p>HTML is flexible in that some
HTML elements allow end tags to be optionally omitted, such as <samp class="codeph">P</samp>, <samp class="codeph">DT</samp>, <samp class="codeph">DD</samp>, <samp class="codeph">LI</samp>, <samp class="codeph">THEAD</samp>, <samp class="codeph">TR</samp>, <samp class="codeph">TD</samp>, <samp class="codeph">TH</samp>,
and so on. Other HTML elements that are defined to have no content may require
the end tag always be omitted, such as <samp class="codeph">BR</samp>, <samp class="codeph">HR</samp>, <samp class="codeph">LINK</samp>, <samp class="codeph">META</samp>,
and <samp class="codeph">IMG</samp>. This flexibility makes the content assist function
within the HTML source page editor less precise than it might be with a more
rigidly constrained markup language.</p>
<p>HTML content assist is most beneficial
when you need to complete a tag name, add an attribute name-value pair within
a start tag, or select from an enumerated list of attribute values.</p>
<p>Although
content assist only shows attribute names that have not already been specified
in a start tag, it does not take into account grammar constraints for tags.
For example, the <samp class="codeph">HEAD</samp> element in HTML only permits zero or
one occurrences of a <samp class="codeph">TITLE</samp> tag in its content. If you prompt
for content assist within a <samp class="codeph">HEAD</samp> content that already contains
a <samp class="codeph">TITLE</samp> tag, content assist will still show <samp class="codeph">TITLE</samp> in
its proposal list.</p>
<p>However, if an attribute is required according to
the DTD/Schema, that attribute will show up at the top of the list, with a
yellow circle indicator on its icon.</p>
<p>If your cursor is in a position
where content assist is available, a pop-up list of available choices is displayed.
The list is based on the context. For example, if you use content assist directly
after an opening paragraph tag (<samp class="codeph">&lt;p&gt;</samp>) , the first item
in the content assist list will be the corresponding closing paragraph (<samp class="codeph">&lt;/p&gt;</samp>)
tag.</p>
<p>The content assist list displays all available tags for the current
cursor position, including templates. The picture below shows the default
content assist list for a paragraph tag example:<br /><img src="../images/ncontass.gif" alt="HTML Content assist" /><br /></p>
<p>Tag proposals
are listed alphabetically. If you type a <samp class="codeph">&lt;</samp> (to begin a
new tag) before prompting for content assist, and begin typing the first one
or two letters of the tag that you want to add, the proposal list automatically
refreshes to reflect proposals that match the pattern you have typed. If you
do not type a <samp class="codeph">&lt;</samp> before prompting for content assist, you
can click within the proposal list and then type the letter that the tag begins
with, to reduce (somewhat) the amount of scrolling to locate the desired tag.</p>
<p>As
you type the first one or two letters of the attribute names or enumerated
attribute values that you want to add to a tag, the list automatically refreshes
to reflect proposals that match the pattern you have typed.</p>
<div class="restriction"><span class="restrictiontitle">Restriction:</span> <img src="../images/nlinux.gif" alt="For Linux." /> When using Linux (Motif
or GTK) and a DBCS locale, double-clicking on the content assist list can
sometimes cause the Javaâ„¢ VM to terminate. Instead of double-clicking
on the list, use the arrows and Enter keys to make the selection from the
list.</div>
</div>
<div class="section"><h4 class="sectiontitle">JSP content assist</h4><p>You have many options for embedding Java and
HTML code in your JSP pages by using content assist.</p>
<p>All of the JSP
tags are included both in the template list and in XML format (for example, <samp class="codeph">&lt;jsp:expression&gt;</samp>).
To add JSP scriptlet tags, for example, move the cursor to the appropriate
position in the file and press Ctrl+Space to use content assist. Select <img src="../images/nmacscrp.gif" alt="JSP scriptlet content assist" /> from the proposal list to insert <samp class="codeph">&lt;% %&gt;</samp> in the
document.</p>
<div class="p">Scriptlets are inserted in a tag <samp class="codeph">&lt;% %&gt;</samp>.
For example: <pre>&lt;% System.currentTimeMillis() %&gt;</pre>
</div>
<p>This
example will evaluate the Java statement to get the current time in
milliseconds.</p>
<div class="p">To have the result of the statement inserted in the file,
put an equals sign (=) in the front of the statement. For example: <pre>&lt;b&gt;This is the time : &lt;%= System.currentTimeMillis()%&gt;&lt;/b&gt;</pre>
</div>
<div class="p">When you are within a scriptlet you are writing pure Java code.
Therefore, content assist works exactly the same as it does for the Java editor.
For example, if you request content assist after <samp class="codeph">System</samp>,
content assist displays a list of methods. <div class="note"><span class="notetitle">Note:</span> Java content assist works only in a Web
project, because it requires a buildpath to find the appropriate Java classes.</div>
</div>
<div class="p">There
are also special tags such as useBean. For example: <pre>&lt;jsp:useBean id="useBean" class="java.lang.String"/&gt;</pre>
</div>
<p>The
useBean tag enables you to create a bean called <samp class="codeph">aString</samp> of
type <samp class="codeph">String</samp>. Then when you use content assist, this is recognized
as a declared variable. For example, if you use content assist after <samp class="codeph">aString</samp>,
as follows:</p>
<div class="p"> <pre>&lt;% aString. %&gt; </pre>
the content assist
list shows available methods. This is because <samp class="codeph">aString</samp> has
been declared as a bean of type String.</div>
<div class="p">If you use content assist after
the <samp class="codeph">a</samp>, as follows: <pre>&lt;% a %&gt; </pre>
content
assist knows that <samp class="codeph">aString</samp> exists, and it is shown in the
content assist list.</div>
</div>
</div>
<div><div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="csrcedt004.html" title="Structured text editor is any of several text editors that you can use to edit various markup languages such as HTML, JavaScript, or XML.">Structured text editors for markup
languages</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="tsrcedt005.html" title="To get help in adding markup to a file, you can use content assist in a structured text editor. Content assist helps you insert or finish a tag or function or finish a line of code in a structured text editor.">Getting content assistance in structured
text editors</a></div>
<div><a href="tsrcedt024.html" title="HTML content assist provides several templates, or chunks of predefined code, that you can insert into a file. You can use the default templates as provided, customize the default templates, or create your own templates.">Adding and removing HTML templates</a></div>
</div>
</div>
</body>
</html>