1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler;
13 import net.sourceforge.phpdt.core.compiler.IProblem;
16 * Part of the source element parser responsible for building the output. It
17 * gets notified of structural information as they are detected, relying on the
18 * requestor to assemble them together, based on the notifications it got.
20 * The structural investigation includes: - package statement - import
21 * statements - top-level types: package member, member types (member types of
22 * member types...) - fields - methods
24 * If reference information is requested, then all source constructs are
25 * investigated and type, field & method references are provided as well.
27 * Any (parsing) problem encountered is also provided.
29 * All positions are relative to the exact source fed to the parser.
31 * Elements which are complex are notified in two steps: - enter<Element> :
32 * once the element header has been identified - exit<Element> : once the
33 * element has been fully consumed
35 * other simpler elements (package, import) are read all at once: - accept<Element>
38 public interface IDocumentElementRequestor {
40 * @param declarationStart -
41 * a source position corresponding to the start of the package
43 * @param declarationEnd -
44 * a source position corresponding to the end of the package
46 * @param javaDocPositions -
47 * answer back an array of sourceStart/sourceEnd positions of the
48 * available JavaDoc comments. The array is a flattened
49 * structure: 2*n entries with consecutives start and end
50 * positions. If no JavaDoc is available, then null is answered
51 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
52 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
53 * equals to null if there are no javadoc comments
55 * the name of the package
56 * @param nameStartPosition -
57 * a source position corresponding to the first character of the
60 * a boolean equals to true if the import is an import on demand
62 void acceptImport(int declarationStart, int declarationEnd,
63 int[] javaDocPositions, char[] name, int nameStartPosition,
67 * @param declarationStart -
68 * a source position corresponding to the start of the package
70 * @param declarationEnd -
71 * a source position corresponding to the end of the package
73 * @param javaDocPositions -
74 * answer back an array of sourceStart/sourceEnd positions of the
75 * available JavaDoc comments. The array is a flattened
76 * structure: 2*n entries with consecutives start and end
77 * positions. If no JavaDoc is available, then null is answered
78 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
79 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
80 * equals to null if there are no javadoc comments
82 * the modifiers for this initializer
83 * @param modifiersStart -
84 * a source position corresponding to the start of the textual
85 * modifiers, is < 0 if there are no textual modifiers
87 * the position of the '{'
89 * the position of the '}'
91 void acceptInitializer(int declarationStart, int declarationEnd,
92 int[] javaDocPositions, int modifiers, int modifiersStart,
93 int bodyStart, int bodyEnd);
96 * Table of line separator position. This table is passed once at the end of
97 * the parse action, so as to allow computation of normalized ranges.
99 * A line separator might corresponds to several characters in the source,
102 void acceptLineSeparatorPositions(int[] positions);
105 * @param declarationStart -
106 * a source position corresponding to the start of the package
108 * @param declarationEnd -
109 * a source position corresponding to the end of the package
111 * @param javaDocPositions -
112 * answer back an array of sourceStart/sourceEnd positions of the
113 * available JavaDoc comments. The array is a flattened
114 * structure: 2*n entries with consecutives start and end
115 * positions. If no JavaDoc is available, then null is answered
116 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
117 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
118 * equals to null if there are no javadoc comments
120 * the name of the package
121 * @param nameStartPosition -
122 * a source position corresponding to the first character of the
125 void acceptPackage(int declarationStart, int declarationEnd,
126 int[] javaDocPositions, char[] name, int nameStartPosition);
130 * Used to report a problem while running the JDOM
132 void acceptProblem(IProblem problem);
135 * @param declarationStart -
136 * a source position corresponding to the start of this class.
137 * @param javaDocPositions -
138 * answer back an array of sourceStart/sourceEnd positions of the
139 * available JavaDoc comments. The array is a flattened
140 * structure: 2*n entries with consecutives start and end
141 * positions. If no JavaDoc is available, then null is answered
142 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
143 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
144 * equals to null if there are no javadoc comments
146 * the modifiers for this class
147 * @param modifiersStart -
148 * a source position corresponding to the start of the textual
149 * modifiers, is < 0 if there are no textual modifiers
150 * @param classStart -
151 * a source position corresponding to the start of the keyword
154 * the name of the class
156 * a source position corresponding to the start of the name
158 * a source position corresponding to the end of the name
159 * @param superclass -
160 * the name of the superclass
161 * @param superclassStart -
162 * a source position corresponding to the start of the superclass
164 * @param superclassEnd -
165 * a source position corresponding to the end of the superclass
167 * @param superinterfaces -
168 * the name of the superinterfaces
169 * @param superinterfaceStarts -
170 * an array of source positions corresponding to the start of
171 * their respective superinterface names
172 * @param superinterfaceEnds -
173 * an array of source positions corresponding to the end of their
174 * respective superinterface names
176 * a source position corresponding to the open bracket of the
179 void enterClass(int declarationStart, int[] javaDocPositions,
180 int modifiers, int modifiersStart, int classStart, char[] name,
181 int nameStart, int nameEnd, char[] superclass, int superclassStart,
182 int superclassEnd, char[][] superinterfaces,
183 int[] superinterfaceStarts, int[] superinterfaceEnds, int bodyStart);
185 void enterCompilationUnit();
188 * @param declarationStart -
189 * a source position corresponding to the first character of this
190 * constructor declaration
191 * @param javaDocPositions -
192 * answer back an array of sourceStart/sourceEnd positions of the
193 * available JavaDoc comments. The array is a flattened
194 * structure: 2*n entries with consecutives start and end
195 * positions. If no JavaDoc is available, then null is answered
196 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
197 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
198 * equals to null if there are no javadoc comments
200 * the modifiers for this constructor converted to a flag
201 * @param modifiersStart -
202 * a source position corresponding to the first character of the
205 * the name of this constructor
207 * a source position corresponding to the first character of the
210 * a source position corresponding to the last character of the
212 * @param parameterTypes -
213 * a list of parameter type names
214 * @param parameterTypeStarts -
215 * a list of source positions corresponding to the first
216 * character of each parameter type name
217 * @param parameterTypeEnds -
218 * a list of source positions corresponding to the last character
219 * of each parameter type name
220 * @param parameterNames -
221 * a list of the names of the parameters
222 * @param parametersEnd -
223 * a source position corresponding to the last character of the
225 * @param exceptionTypes -
226 * a list of the exception types
227 * @param exceptionTypeStarts -
228 * a list of source positions corresponding to the first
229 * character of the respective exception types
230 * @param exceptionTypeEnds -
231 * a list of source positions corresponding to the last character
232 * of the respective exception types
234 * a source position corresponding to the start of this
237 void enterConstructor(int declarationStart, int[] javaDocPositions,
238 int modifiers, int modifiersStart, char[] name, int nameStart,
239 int nameEnd, char[][] parameterTypes, int[] parameterTypeStarts,
240 int[] parameterTypeEnds, char[][] parameterNames,
241 int[] parameterNameStarts, int[] parameterNameEnds,
242 int parametersEnd, char[][] exceptionTypes,
243 int[] exceptionTypeStarts, int[] exceptionTypeEnds, int bodyStart);
246 * @param declarationStart -
247 * a source position corresponding to the first character of this
249 * @param javaDocPositions -
250 * answer back an array of sourceStart/sourceEnd positions of the
251 * available JavaDoc comments. The array is a flattened
252 * structure: 2*n entries with consecutives start and end
253 * positions. If no JavaDoc is available, then null is answered
254 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
255 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
256 * equals to null if there are no javadoc comments
258 * the modifiers for this field converted to a flag
259 * @param modifiersStart -
260 * a source position corresponding to the first character of the
263 * the name of the field type
265 * a source position corresponding to the start of the fields
268 * a source position corresponding to the end of the fields type
269 * @param typeDimensionCount -
270 * the array dimension indicated on the type (for example, 'int[]
273 * the name of this constructor
275 * a source position corresponding to the first character of the
278 * a source position corresponding to the last character of the
280 * @param extendedTypeDimensionCount -
281 * the array dimension indicated on the variable, (for example,
283 * @param extendedTypeDimnesionEnd -
284 * a source position corresponding to the end of the extened type
285 * dimension. This position should be -1 in case there is no
286 * extended dimension for the type.
288 void enterField(int declarationStart, int[] javaDocPositions,
289 int modifiers, int modifiersStart, char[] type, int typeStart,
290 int typeEnd, int typeDimensionCount, char[] name, int nameStart,
291 int nameEnd, int extendedTypeDimensionCount,
292 int extendedTypeDimensionEnd);
295 * @param declarationStart -
296 * a source position corresponding to the start of this class.
297 * @param javaDocPositions -
298 * answer back an array of sourceStart/sourceEnd positions of the
299 * available JavaDoc comments. The array is a flattened
300 * structure: 2*n entries with consecutives start and end
301 * positions. If no JavaDoc is available, then null is answered
302 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
303 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
304 * equals to null if there are no javadoc comments
306 * the modifiers for this class
307 * @param modifiersStart -
308 * a source position corresponding to the start of the textual
309 * modifiers, is < 0 if there are no textual modifiers
310 * @param interfaceStart -
311 * a source position corresponding to the start of the keyword
314 * the name of the class
316 * a source position corresponding to the start of the name
318 * a source position corresponding to the end of the name
319 * @param superinterfaces -
320 * the name of the superinterfaces
321 * @param superinterfaceStarts -
322 * an array of source positions corresponding to the start of
323 * their respective superinterface names
324 * @param superinterfaceEnds -
325 * an array of source positions corresponding to the end of their
326 * respective superinterface names
328 * a source position corresponding to the open bracket of the
331 void enterInterface(int declarationStart, int[] javaDocPositions,
332 int modifiers, int modifiersStart, int interfaceStart, char[] name,
333 int nameStart, int nameEnd, char[][] superinterfaces,
334 int[] superinterfaceStarts, int[] superinterfaceEnds, int bodyStart);
337 * @param declarationStart -
338 * a source position corresponding to the first character of this
339 * constructor declaration
340 * @param javaDocPositions -
341 * answer back an array of sourceStart/sourceEnd positions of the
342 * available JavaDoc comments. The array is a flattened
343 * structure: 2*n entries with consecutives start and end
344 * positions. If no JavaDoc is available, then null is answered
345 * instead of an empty array. e.g. { 10, 20, 25, 45 } -->
346 * javadoc1 from 10 to 20, javadoc2 from 25 to 45 The array is
347 * equals to null if there are no javadoc comments
349 * the modifiers for this constructor converted to a flag
350 * @param modifiersStart -
351 * a source position corresponding to the first character of the
353 * @param returnType -
354 * the name of the return type
355 * @param returnTypeStart -
356 * a source position corresponding to the first character of the
358 * @param returnTypeEnd -
359 * a source position corresponding to the last character of the
361 * @param returnTypeDimensionCount -
362 * the array dimension count as supplied on the return type (for
363 * example, 'public int[] foo() {}')
365 * the name of this constructor
367 * a source position corresponding to the first character of the
370 * a source position corresponding to the last character of the
372 * @param parameterTypes -
373 * a list of parameter type names
374 * @param parameterTypeStarts -
375 * a list of source positions corresponding to the first
376 * character of each parameter type name
377 * @param parameterTypeEnds -
378 * a list of source positions corresponding to the last character
379 * of each parameter type name
380 * @param parameterNames -
381 * a list of the names of the parameters
382 * @param parametersEnd -
383 * a source position corresponding to the last character of the
385 * @param extendedReturnTypeDimensionCount -
386 * the array dimension count as supplied on the end of the
387 * parameter list (for example, 'public int foo()[] {}')
388 * @param extendedReturnTypeDimensionEnd -
389 * a source position corresponding to the last character of the
390 * extended return type dimension. This position should be -1 in
391 * case there is no extended dimension for the type.
392 * @param exceptionTypes -
393 * a list of the exception types
394 * @param exceptionTypeStarts -
395 * a list of source positions corresponding to the first
396 * character of the respective exception types
397 * @param exceptionTypeEnds -
398 * a list of source positions corresponding to the last character
399 * of the respective exception types
401 * a source position corresponding to the start of this method's
404 void enterMethod(int declarationStart, int[] javaDocPositions,
405 int modifiers, int modifiersStart, char[] returnType,
406 int returnTypeStart, int returnTypeEnd,
407 int returnTypeDimensionCount, char[] name, int nameStart,
408 int nameEnd, char[][] parameterTypes, int[] parameterTypeStarts,
409 int[] parameterTypeEnds, char[][] parameterNames,
410 int[] parameterNameStarts, int[] parameterNameEnds,
411 int parametersEnd, int extendedReturnTypeDimensionCount,
412 int extendedReturnTypeDimensionEnd, char[][] exceptionTypes,
413 int[] exceptionTypeStarts, int[] exceptionTypeEnds, int bodyStart);
417 * a source position corresponding to the closing bracket of the
419 * @param declarationEnd -
420 * a source position corresponding to the end of the class
421 * declaration. This can include whitespace and comments
422 * following the closing bracket.
424 void exitClass(int bodyEnd, int declarationEnd);
427 * @param declarationEnd -
428 * a source position corresponding to the end of the compilation
431 void exitCompilationUnit(int declarationEnd);
435 * a source position corresponding to the closing bracket of the
437 * @param declarationEnd -
438 * a source position corresponding to the end of the method
439 * declaration. This can include whitespace and comments
440 * following the closing bracket.
442 void exitConstructor(int bodyEnd, int declarationEnd);
446 * a source position corresponding to the end of the field.
447 * @param declarationEnd -
448 * a source position corresponding to the end of the field. This
449 * can include whitespace and comments following the semi-colon.
451 void exitField(int bodyEnd, int declarationEnd);
455 * a source position corresponding to the closing bracket of the
457 * @param declarationEnd -
458 * a source position corresponding to the end of the interface
459 * declaration. This can include whitespace and comments
460 * following the closing bracket.
462 void exitInterface(int bodyEnd, int declarationEnd);
466 * a source position corresponding to the closing bracket of the
468 * @param declarationEnd -
469 * a source position corresponding to the end of the method
470 * declaration. This can include whitespace and comments
471 * following the closing bracket.
473 void exitMethod(int bodyEnd, int declarationEnd);