001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core;
011:
012: /**
013: * Common protocol for Java elements that support source code assist and code
014: * resolve.
015: * <p>
016: * This interface is not intended to be implemented by clients.
017: * </p>
018: */
019: public interface ICodeAssist {
020:
021: /**
022: * Performs code completion at the given offset position in this compilation unit,
023: * reporting results to the given completion requestor. The <code>offset</code>
024: * is the 0-based index of the character, after which code assist is desired.
025: * An <code>offset</code> of -1 indicates to code assist at the beginning of this
026: * compilation unit.
027: *
028: * @param offset the given offset position
029: * @param requestor the given completion requestor
030: *
031: * @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
032: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
033: * <li> The position specified is < -1 or is greater than this compilation unit's
034: * source length (INDEX_OUT_OF_BOUNDS)
035: * </ul>
036: *
037: * @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
038: * @deprecated Use {@link #codeComplete(int, ICompletionRequestor)} instead.
039: */
040: void codeComplete(int offset, ICodeCompletionRequestor requestor)
041: throws JavaModelException;
042:
043: /**
044: * Performs code completion at the given offset position in this compilation unit,
045: * reporting results to the given completion requestor. The <code>offset</code>
046: * is the 0-based index of the character, after which code assist is desired.
047: * An <code>offset</code> of -1 indicates to code assist at the beginning of this
048: * compilation unit.
049: *
050: * @param offset the given offset position
051: * @param requestor the given completion requestor
052: * @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
053: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
054: * <li> The position specified is < -1 or is greater than this compilation unit's
055: * source length (INDEX_OUT_OF_BOUNDS)
056: * </ul>
057: *
058: * @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
059: * @since 2.0
060: * @deprecated Use {@link #codeComplete(int, CompletionRequestor)} instead.
061: */
062: void codeComplete(int offset, ICompletionRequestor requestor)
063: throws JavaModelException;
064:
065: /**
066: * Performs code completion at the given offset position in this compilation unit,
067: * reporting results to the given completion requestor. The <code>offset</code>
068: * is the 0-based index of the character, after which code assist is desired.
069: * An <code>offset</code> of -1 indicates to code assist at the beginning of this
070: * compilation unit.
071: * <p>
072: *
073: * @param offset the given offset position
074: * @param requestor the given completion requestor
075: * @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
076: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
077: * <li> The position specified is < -1 or is greater than this compilation unit's
078: * source length (INDEX_OUT_OF_BOUNDS)
079: * </ul>
080: *
081: * @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
082: * @since 3.0
083: */
084: void codeComplete(int offset, CompletionRequestor requestor)
085: throws JavaModelException;
086:
087: /**
088: * Performs code completion at the given offset position in this compilation unit,
089: * reporting results to the given completion requestor. The <code>offset</code>
090: * is the 0-based index of the character, after which code assist is desired.
091: * An <code>offset</code> of -1 indicates to code assist at the beginning of this
092: * compilation unit.
093: * It considers types in the working copies with the given owner first. In other words,
094: * the owner's working copies will take precedence over their original compilation units
095: * in the workspace.
096: * <p>
097: * Note that if a working copy is empty, it will be as if the original compilation
098: * unit had been deleted.
099: * </p>
100: *
101: * @param offset the given offset position
102: * @param requestor the given completion requestor
103: * @param owner the owner of working copies that take precedence over their original compilation units
104: * @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
105: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
106: * <li> The position specified is < -1 or is greater than this compilation unit's
107: * source length (INDEX_OUT_OF_BOUNDS)
108: * </ul>
109: *
110: * @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
111: * @since 3.0
112: * @deprecated Use {@link #codeComplete(int, CompletionRequestor, WorkingCopyOwner)} instead.
113: */
114: void codeComplete(int offset, ICompletionRequestor requestor,
115: WorkingCopyOwner owner) throws JavaModelException;
116:
117: /**
118: * Performs code completion at the given offset position in this compilation unit,
119: * reporting results to the given completion requestor. The <code>offset</code>
120: * is the 0-based index of the character, after which code assist is desired.
121: * An <code>offset</code> of -1 indicates to code assist at the beginning of this
122: * compilation unit.
123: * It considers types in the working copies with the given owner first. In other words,
124: * the owner's working copies will take precedence over their original compilation units
125: * in the workspace.
126: * <p>
127: * Note that if a working copy is empty, it will be as if the original compilation
128: * unit had been deleted.
129: * </p>
130: *
131: * @param offset the given offset position
132: * @param requestor the given completion requestor
133: * @param owner the owner of working copies that take precedence over their original compilation units
134: * @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
135: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
136: * <li> The position specified is < -1 or is greater than this compilation unit's
137: * source length (INDEX_OUT_OF_BOUNDS)
138: * </ul>
139: *
140: * @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
141: * @since 3.0
142: */
143: void codeComplete(int offset, CompletionRequestor requestor,
144: WorkingCopyOwner owner) throws JavaModelException;
145:
146: /**
147: * Returns the Java elements corresponding to the given selected text in this compilation unit.
148: * The <code>offset</code> is the 0-based index of the first selected character.
149: * The <code>length</code> is the number of selected characters.
150: * <p>
151: * Note that if the <code>length</code> is 0 and the <code>offset</code> is inside an identifier
152: * or the index just after an identifier then this identifier is considered as the selection.
153: * </p>
154: *
155: * @param offset the given offset position
156: * @param length the number of selected characters
157: * @return the Java elements corresponding to the given selected text
158: *
159: * @exception JavaModelException if code resolve could not be performed. Reasons include:
160: * <ul>
161: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
162: * <li> The range specified is not within this element's
163: * source range (INDEX_OUT_OF_BOUNDS)
164: * </ul>
165: *
166: */
167: IJavaElement[] codeSelect(int offset, int length)
168: throws JavaModelException;
169:
170: /**
171: * Returns the Java elements corresponding to the given selected text in this compilation unit.
172: * The <code>offset</code> is the 0-based index of the first selected character.
173: * The <code>length</code> is the number of selected characters.
174: * It considers types in the working copies with the given owner first. In other words,
175: * the owner's working copies will take precedence over their original compilation units
176: * in the workspace.
177: * <p>
178: * Note that if the <code>length</code> is 0 and the <code>offset</code> is inside an identifier
179: * or the index just after an identifier then this identifier is considered as the selection.
180: * </p>
181: * <p>
182: * Note that if a working copy is empty, it will be as if the original compilation
183: * unit had been deleted.
184: * </p>
185: *
186: * @param offset the given offset position
187: * @param length the number of selected characters
188: * @param owner the owner of working copies that take precedence over their original compilation units
189: * @return the Java elements corresponding to the given selected text
190: *
191: * @exception JavaModelException if code resolve could not be performed. Reasons include:
192: * <ul>
193: * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
194: * <li> The range specified is not within this element's
195: * source range (INDEX_OUT_OF_BOUNDS)
196: * </ul>
197: * @since 3.0
198: */
199: IJavaElement[] codeSelect(int offset, int length,
200: WorkingCopyOwner owner) throws JavaModelException;
201: }
|