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.core.jdom;
13 import java.util.ArrayList;
16 import net.sourceforge.phpdt.core.JavaCore;
17 import net.sourceforge.phpdt.core.compiler.IProblem;
18 import net.sourceforge.phpdt.core.jdom.IDOMCompilationUnit;
19 import net.sourceforge.phpdt.core.jdom.IDOMFactory;
20 import net.sourceforge.phpdt.core.jdom.IDOMNode;
21 import net.sourceforge.phpdt.core.jdom.IDOMPackage;
22 import net.sourceforge.phpdt.internal.compiler.DocumentElementParser;
23 import net.sourceforge.phpdt.internal.compiler.IDocumentElementRequestor;
24 import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
25 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
26 import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
27 import net.sourceforge.phpdt.internal.core.util.CharArrayOps;
30 * The DOMBuilder constructs each type of JDOM document fragment,
31 * for the DOMFactory. The DOMBuilder has been separated from the
32 * DOMFactory to hide the implmentation of node creation and the
33 * public Requestor API methods.
37 public class DOMBuilder extends AbstractDOMBuilder implements IDocumentElementRequestor {
40 * True when parsing a single member - ignore any problems
41 * encountered after the member.
43 protected boolean fBuildingSingleMember= false;
46 * True when the single member being built has been
49 protected boolean fFinishedSingleMember = false;
52 * Collection of multiple fields in one declaration
54 protected ArrayList fFields;
56 Map options = JavaCore.getOptions();
59 * Creates a new DOMBuilder
61 public DOMBuilder() {}
63 * @see IDocumentElementRequestor#acceptImport(int declarationStart, int declarationEnd, int[] javaDocPositions, char[] name, int nameStartPosition, boolean onDemand)
65 public void acceptImport(int declarationStart, int declarationEnd, int[] javaDocPositions, char[] name,
66 int nameStart, boolean onDemand) {
67 int[] sourceRange = {declarationStart, declarationEnd};
68 int[] nameRange = {nameStart, declarationEnd - 1};
71 String importName = CharArrayOps.substring(fDocument, nameRange[0], nameRange[1] + 1 - nameRange[0]);
73 fNode= new DOMImport(fDocument, sourceRange, importName, nameRange, onDemand);
75 if (fBuildingSingleMember) {
76 fFinishedSingleMember= true;
80 * @see IDocumentElementRequestor#acceptInitializer(int declarationStart, int declarationEnd, int[] javaDocPositions, int modifiers, int modifiersStart, int bodyStart, int bodyEnd)
82 public void acceptInitializer(int declarationStart, int declarationEnd, int[] javaDocPositions, int modifiers,
83 int modifiersStart, int bodyStart, int bodyEnd) {
84 int[] sourceRange = {declarationStart, declarationEnd};
85 int[] commentRange = {-1, -1};
86 if (javaDocPositions != null) {
87 int length = javaDocPositions.length;
88 commentRange[0] = javaDocPositions[length - 2];
89 commentRange[1] = javaDocPositions[length - 1];
92 int[] modifiersRange = {-1, -1};
93 if (modifiersStart > declarationStart) {
94 modifiersRange[0] = modifiersStart;
95 modifiersRange[1] = bodyStart - 1;
97 fNode = new DOMInitializer(fDocument, sourceRange, commentRange, modifiers,
98 modifiersRange, bodyStart);
100 if (fBuildingSingleMember) {
101 fFinishedSingleMember= true;
105 * @see IDocumentElementRequestor#acceptPackage(int declarationStart, int declarationEnd, int[] javaDocPositions, char[] name, int nameStartPosition)
107 public void acceptPackage(int declarationStart, int declarationEnd, int[] javaDocPositions, char[] name,
108 int nameStartPosition) {
109 int[] sourceRange = {declarationStart, declarationEnd};
110 int[] nameRange = {nameStartPosition, declarationEnd - 1};
111 fNode= new DOMPackage(fDocument, sourceRange, CharArrayOps.charToString(name), nameRange);
113 if (fBuildingSingleMember) {
114 fFinishedSingleMember= true;
118 * Sets the abort flag to true. The parser has encountered an error
119 * in the current document. If we are only building a single member, and
120 * we are done with the member - don't worry about the error.
122 * @see IDocumentElementRequestor
124 public void acceptProblem(IProblem problem){
125 if (fBuildingSingleMember && fFinishedSingleMember) {
131 * Adds the given node to the current enclosing scope, building the JDOM
132 * tree. Nodes are only added to an enclosing scope when a compilation unit or type
133 * is being built (since those are the only nodes that have children).
135 * <p>NOTE: nodes are added to the JDOM via the method #basicAddChild such that
136 * the nodes in the newly created JDOM are not fragmented.
138 protected void addChild(IDOMNode child) {
139 super.addChild(child);
140 if (fStack.isEmpty() && fFields != null) {
145 * @see IDOMFactory#createCompilationUnit()
147 public IDOMCompilationUnit createCompilationUnit() {
148 return new DOMCompilationUnit();
151 * @see IDOMFactory#createCompilationUnit(String, String)
153 public IDOMCompilationUnit createCompilationUnit(ICompilationUnit compilationUnit) {
154 initializeBuild(compilationUnit.getContents(), true, true, false);
155 getParser(options).parseCompilationUnit(compilationUnit);
156 return super.createCompilationUnit(compilationUnit);
159 * @see IDOMFactory#createField(String)
161 //public IDOMField createField(char[] sourceCode) {
162 // initializeBuild(sourceCode, false, false, true);
163 // getParser(options).parseField(sourceCode);
164 // if (fAbort || fNode == null) {
168 // // we only accept field declarations with one field
169 // if (fFieldCount > 1) {
173 // fNode.normalize(this);
174 // return (IDOMField)fNode;
179 //public IDOMField[] createFields(char[] sourceCode) {
180 // initializeBuild(sourceCode, false, false, false);
181 // fFields= new ArrayList();
182 // getParser(options).parseField(sourceCode);
186 // IDOMField[] fields= new IDOMField[fFields.size()];
187 // fFields.toArray(fields);
188 // for (int i= 0; i < fields.length; i++) {
189 // DOMNode node= (DOMNode)fields[i];
190 // if (i < (fields.length - 1)) {
191 // DOMNode next= (DOMNode)fields[i + 1];
192 // node.fNextNode= next;
193 // next.fPreviousNode= node;
195 // ((DOMNode)fields[i]).normalize(this);
200 * @see IDOMFactory#createImport()
202 //public IDOMImport createImport() {
203 // return new DOMImport();
206 * @see IDOMFactory#createImport(String)
208 //public IDOMImport createImport(char[] sourceCode) {
209 // initializeBuild(sourceCode, false, false, true);
210 // getParser(options).parseImport(sourceCode);
211 // if (fAbort || fNode == null) {
214 // fNode.normalize(this);
215 // return (IDOMImport)fNode;
218 * Creates an INITIALIZER document fragment from the given source.
220 * @see IDOMFactory#createInitializer(String)
222 //public IDOMInitializer createInitializer(char[] sourceCode) {
223 // initializeBuild(sourceCode, false, false, true);
224 // getParser(options).parseInitializer(sourceCode);
225 // if (fAbort || fNode == null || !(fNode instanceof IDOMInitializer)) {
228 // fNode.normalize(this);
229 // return (IDOMInitializer)fNode;
232 * @see IDOMFactory#createMethod(String)
234 //public IDOMMethod createMethod(char[] sourceCode) {
235 // initializeBuild(sourceCode, false, false, true);
236 // getParser(options).parseMethod(sourceCode);
237 // if (fAbort || fNode == null) {
240 // fNode.normalize(this);
241 // return (IDOMMethod)fNode;
244 * @see IDOMFactory#createPackage()
246 public IDOMPackage createPackage() {
247 return new DOMPackage();
250 * @see IDOMFactory#createPackage(String)
252 //public IDOMPackage createPackage(char[] sourceCode) {
253 // initializeBuild(sourceCode, false, false, true);
254 // getParser(options).parsePackage(sourceCode);
255 // if (fAbort || fNode == null) {
258 // fNode.normalize(this);
259 // return (IDOMPackage)fNode;
262 * @see IDOMFactory#createType(String)
264 //public IDOMType createType(char[] sourceCode) {
265 // initializeBuild(sourceCode, false, true, false);
266 // getParser(options).parseType(sourceCode);
270 // if (fNode != null) fNode.normalize(this);
271 // return (IDOMType)fNode;
274 * Creates a new DOMMethod and inizializes.
276 * @param declarationStart - a source position corresponding to the first character
277 * of this constructor declaration
278 * @param modifiers - the modifiers for this constructor converted to a flag
279 * @param modifiersStart - a source position corresponding to the first character of the
281 * @param returnType - the name of the return type
282 * @param returnTypeStart - a source position corresponding to the first character
284 * @param returnTypeEnd - a source position corresponding to the last character
286 * @param returnTypeDimensionCount - the array dimension count as supplied on the
287 * return type (for instance, 'public int[] foo() {}')
288 * @param name - the name of this constructor
289 * @param nameStart - a source position corresponding to the first character of the name
290 * @param nameEnd - a source position corresponding to the last character of the name
291 * @param parameterTypes - a list of parameter type names
292 * @param parameterTypeStarts - a list of source positions corresponding to the
293 * first character of each parameter type name
294 * @param parameterTypeEnds - a list of source positions corresponding to the
295 * last character of each parameter type name
296 * @param parameterNames - a list of the names of the parameters
297 * @param parametersEnd - a source position corresponding to the last character of the
299 * @extendedReturnTypeDimensionCount - the array dimension count as supplied on the
300 * end of the parameter list (for instance, 'public int foo()[] {}')
301 * @extendedReturnTypeDimensionEnd - a source position corresponding to the last character
302 * of the extended return type dimension
303 * @param exceptionTypes - a list of the exception types
304 * @param exceptionTypeStarts - a list of source positions corresponding to the first
305 * character of the respective exception types
306 * @param exceptionTypeEnds - a list of source positions corresponding to the last
307 * character of the respective exception types
308 * @param bodyStart - a source position corresponding to the start of this
311 protected void enterAbstractMethod(int declarationStart, int[] javaDocPositions, int modifiers, int modifiersStart,
312 char[] returnType, int returnTypeStart, int returnTypeEnd, int returnTypeDimensionCount,
313 char[] name, int nameStart, int nameEnd, char[][] parameterTypes, int[] parameterTypeStarts,
314 int[] parameterTypeEnds, char[][] parameterNames, int[] parameterNameStarts,
315 int[] parameterNameEnds, int parametersEnd, int extendedReturnTypeDimensionCount,
316 int extendedReturnTypeDimensionEnd, char[][] exceptionTypes, int[] exceptionTypeStarts,
317 int[] exceptionTypeEnds, int bodyStart, boolean isConstructor) {
318 int[] sourceRange = {declarationStart, -1}; // will be fixed up on exit
319 int[] nameRange = {nameStart, nameEnd};
320 int[] commentRange = {-1, -1};
321 if (javaDocPositions != null) {
322 int length = javaDocPositions.length;
323 commentRange[0] = javaDocPositions[0];
324 commentRange[1] = javaDocPositions[length - 1];
326 int[] modifiersRange = {-1, -1};
327 if (modifiersStart > -1) {
328 modifiersRange[0] = modifiersStart;
330 modifiersRange[1] = nameStart - 1;
332 modifiersRange[1] = returnTypeStart - 1;
335 int[] returnTypeRange = null;
337 if (extendedReturnTypeDimensionCount > 0)
338 returnTypeRange = new int[] {returnTypeStart, returnTypeEnd,
339 parametersEnd + 1, extendedReturnTypeDimensionEnd};
341 returnTypeRange = new int[] {returnTypeStart, returnTypeEnd};
342 int[] parameterRange = {nameEnd + 1, parametersEnd};
343 int[] exceptionRange = {-1, -1};
344 if (exceptionTypes != null && exceptionTypes.length > 0) {
345 int exceptionCount = exceptionTypes.length;
346 exceptionRange[0] = exceptionTypeStarts[0];
347 exceptionRange[1] = exceptionTypeEnds[exceptionCount - 1];
349 int[] bodyRange = null;
350 if (exceptionRange[1] > -1) {
351 bodyRange = new int[] {exceptionRange[1] + 1, -1}; // will be fixed up on exit
353 bodyRange = new int[] {parametersEnd + 1, -1};
355 fNode = new DOMMethod(fDocument, sourceRange, CharArrayOps.charToString(name), nameRange, commentRange, modifiers,
356 modifiersRange, isConstructor, CharArrayOps.charToString(returnType), returnTypeRange,
357 CharArrayOps.charcharToString(parameterTypes),
358 CharArrayOps.charcharToString(parameterNames),
359 parameterRange, CharArrayOps.charcharToString(exceptionTypes), exceptionRange, bodyRange);
364 * @see IDocumentElementRequestor#enterClass(
365 int declarationStart,
366 int[] javaDocPositions,
376 char[][] superinterfaces,
377 int[] superinterfaceStarts,
378 int[] superinterfaceEnds,
381 public void enterClass(int declarationStart, int[] javaDocPositions, int modifiers, int modifiersStart, int keywordStart,
382 char[] name, int nameStart, int nameEnd, char[] superclass, int superclassStart,
383 int superclassEnd, char[][] superinterfaces, int[] superinterfaceStarts,
384 int[] superinterfaceEnds, int bodyStart) {
386 enterType(declarationStart, javaDocPositions, modifiers, modifiersStart, keywordStart,
387 name, nameStart, nameEnd, superclass, superclassStart,
388 superclassEnd, superinterfaces, superinterfaceStarts,
389 superinterfaceEnds, bodyStart, true);
392 * @see IDocumentElementRequestor#enterConstructor(
393 int declarationStart,
394 int[] javaDocPositions,
400 char[][] parameterTypes,
401 int [] parameterTypeStarts,
402 int [] parameterTypeEnds,
403 char[][] parameterNames,
404 int [] parameterNameStarts,
405 int [] parameterNameEnds,
407 char[][] exceptionTypes,
408 int [] exceptionTypeStarts,
409 int [] exceptionTypeEnds,
412 public void enterConstructor(int declarationStart, int[] javaDocPositions, int modifiers, int modifiersStart,
413 char[] name, int nameStart, int nameEnd, char[][] parameterTypes,
414 int[] parameterTypeStarts, int[] parameterTypeEnds, char[][] parameterNames,
415 int[] parameterNameStarts, int[] parameterNameEnds, int parametersEnd,
416 char[][] exceptionTypes, int[] exceptionTypeStarts, int[] exceptionTypeEnds,
420 String nameString = new String(fDocument, nameStart, nameEnd - nameStart);
421 int openParenPosition = nameString.indexOf('(');
422 if (openParenPosition > -1)
423 nameEnd = nameStart + openParenPosition - 1;
425 enterAbstractMethod(declarationStart, javaDocPositions, modifiers, modifiersStart,
427 name, nameStart, nameEnd, parameterTypes, parameterTypeStarts,
428 parameterTypeEnds, parameterNames, parameterNameStarts,
429 parameterNameEnds, parametersEnd, 0,
430 -1, exceptionTypes, exceptionTypeStarts,
431 exceptionTypeEnds, bodyStart,true);
434 * @see IDocumentElementRequestor#enterField(
435 int declarationStart,
436 int[] javaDocPositions,
442 int typeDimensionCount,
446 int extendedTypeDimensionCount,
447 int extendedTypeDimensionEnd)
449 public void enterField(int declarationStart, int[] javaDocPositions, int modifiers, int modifiersStart,
450 char[] type, int typeStart, int typeEnd, int typeDimensionCount, char[] name,
451 int nameStart, int nameEnd, int extendedTypeDimensionCount,
452 int extendedTypeDimensionEnd) {
453 int[] sourceRange = {declarationStart,
454 (extendedTypeDimensionEnd > nameEnd) ? extendedTypeDimensionEnd : nameEnd};
455 int[] nameRange = {nameStart, nameEnd};
456 int[] commentRange = {-1, -1};
457 if (javaDocPositions != null) {
458 int length = javaDocPositions.length;
459 commentRange[0] = javaDocPositions[0];
460 commentRange[1] = javaDocPositions[length - 1];
462 int[] modifiersRange = {-1, -1};
463 if (modifiersStart > -1) {
464 modifiersRange[0] = modifiersStart;
465 modifiersRange[1] = typeStart - 1;
467 int[] typeRange = {typeStart, typeEnd};
468 boolean hasInitializer = false; // fixed on exitField
469 int[] initializerRange = {-1, -1}; // fixed on exitField
470 boolean isVariableDeclarator = false;
471 if (fNode instanceof DOMField) {
472 DOMField field = (DOMField)fNode;
473 if (field.fTypeRange[0] == typeStart)
474 isVariableDeclarator = true;
476 fNode = new DOMField(fDocument, sourceRange, CharArrayOps.charToString(name), nameRange, commentRange,
477 modifiers, modifiersRange, typeRange, CharArrayOps.charToString(type), hasInitializer,
478 initializerRange, isVariableDeclarator);
483 * @see IDocumentElementRequestor#enterInterface(
484 int declarationStart,
485 int[] javaDocPositions,
492 char[][] superinterfaces,
493 int[] superinterfaceStarts,
494 int[] superinterfaceEnds,
497 public void enterInterface(int declarationStart, int[] javaDocPositions, int modifiers, int modifiersStart, int keywordStart,
498 char[] name, int nameStart, int nameEnd, char[][] superinterfaces,
499 int[] superinterfaceStarts, int[] superinterfaceEnds, int bodyStart) {
501 enterType(declarationStart, javaDocPositions, modifiers, modifiersStart, keywordStart,
502 name, nameStart, nameEnd, null, -1, -1, superinterfaces,
503 superinterfaceStarts, superinterfaceEnds, bodyStart, false);
506 * @see IDocumentElementRequestor#enterMethod(
507 int declarationStart,
508 int[] javaDocPositions,
514 int returnTypeDimensionCount,
518 char[][] parameterTypes,
519 int [] parameterTypeStarts,
520 int [] parameterTypeEnds,
521 char[][] parameterNames,
522 int [] parameterNameStarts,
523 int [] parameterNameEnds,
525 int extendedReturnTypeDimensionCount,
526 int extendedReturnTypeDimensionEnd,
527 char[][] exceptionTypes,
528 int [] exceptionTypeStarts,
529 int [] exceptionTypeEnds,
532 public void enterMethod(int declarationStart, int[] javaDocPositions, int modifiers, int modifiersStart,
533 char[] returnType, int returnTypeStart, int returnTypeEnd, int returnTypeDimensionCount,
534 char[] name, int nameStart, int nameEnd, char[][] parameterTypes, int[] parameterTypeStarts,
535 int[] parameterTypeEnds, char[][] parameterNames, int[] parameterNameStarts,
536 int[] parameterNameEnds, int parametersEnd, int extendedReturnTypeDimensionCount,
537 int extendedReturnTypeDimensionEnd, char[][] exceptionTypes, int[] exceptionTypeStarts,
538 int[] exceptionTypeEnds, int bodyStart) {
539 enterAbstractMethod(declarationStart, javaDocPositions, modifiers, modifiersStart,
540 returnType, returnTypeStart, returnTypeEnd, returnTypeDimensionCount,
541 name, nameStart, nameEnd, parameterTypes, parameterTypeStarts,
542 parameterTypeEnds, parameterNames, parameterNameStarts,
543 parameterNameEnds, parametersEnd, extendedReturnTypeDimensionCount,
544 extendedReturnTypeDimensionEnd, exceptionTypes, exceptionTypeStarts,
545 exceptionTypeEnds, bodyStart,false);
548 protected void enterType(int declarationStart, int[] javaDocPositions,
549 int modifiers, int modifiersStart, int keywordStart, char[] name,
550 int nameStart, int nameEnd, char[] superclass, int superclassStart,
551 int superclassEnd, char[][] superinterfaces, int[] superinterfaceStarts,
552 int[] superinterfaceEnds, int bodyStart, boolean isClass) {
554 int[] sourceRange = {declarationStart, -1}; // will be fixed in the exit
555 int[] commentRange = {-1, -1};
556 if (javaDocPositions != null) {
557 int length = javaDocPositions.length;
558 commentRange[0] = javaDocPositions[0];
559 commentRange[1] = javaDocPositions[length - 1];
561 int[] modifiersRange = {-1, -1};
562 if (modifiersStart > -1) {
563 modifiersRange[0] = modifiersStart;
564 modifiersRange[1] = (modifiersStart > -1) ? keywordStart - 1 : -1;
566 int[] typeKeywordRange = {keywordStart, nameStart - 1};
567 int[] nameRange = new int[] {nameStart, nameEnd};
568 int[] extendsKeywordRange = {-1, -1};
569 int[] superclassRange = {-1, -1};
570 int[] implementsKeywordRange = {-1, -1};
571 int[] interfacesRange = {-1, -1};
573 if (superclass != null) {
574 extendsKeywordRange[0] = nameEnd + 1;
575 extendsKeywordRange[1] = superclassStart - 1;
576 superclassRange[0] = superclassStart;
577 superclassRange[1] = bodyStart - 1;
579 if (superinterfaces != null && superinterfaces.length > 0) {
580 superclassRange[1] = superclassEnd;
581 if (superclassEnd > -1) {
582 implementsKeywordRange[0] = superclassEnd + 1;
584 implementsKeywordRange[0] = nameEnd + 1;
586 implementsKeywordRange[1] = superinterfaceStarts[0] - 1;
587 interfacesRange[0] = superinterfaceStarts[0];
588 interfacesRange[1] = superinterfaceEnds[superinterfaces.length - 1];
591 if (superinterfaces != null && superinterfaces.length > 0) {
592 extendsKeywordRange[0] = nameEnd + 1;
593 extendsKeywordRange[1] = superinterfaceStarts[0] - 1;
594 interfacesRange[0] = superinterfaceStarts[0];
595 interfacesRange[1] = superinterfaceEnds[superinterfaces.length - 1];
598 int[] openBodyRange = {bodyStart, -1}; // fixed by setTypeRanges(DOMNode)
599 int[] closeBodyRange = {-1, -1}; // will be fixed in exit
600 fNode = new DOMType(fDocument, sourceRange, new String(name), nameRange, commentRange,
601 modifiers, modifiersRange, typeKeywordRange, superclassRange, extendsKeywordRange,
602 CharArrayOps.charcharToString(superinterfaces), interfacesRange,
603 implementsKeywordRange, openBodyRange,
604 closeBodyRange, isClass);
610 * Finishes the configuration of the constructors and methods.
612 * @param bodyEnd - a source position corresponding to the closing bracket of the method
613 * @param declarationEnd - a source position corresponding to the end of the method
614 * declaration. This can include whitespace and comments following the closing bracket.
616 protected void exitAbstractMethod(int bodyEnd, int declarationEnd) {
617 DOMMethod method = (DOMMethod) fStack.pop();
618 method.setSourceRangeEnd(declarationEnd);
619 method.setBodyRangeEnd(bodyEnd + 1);
621 if (fBuildingSingleMember) {
622 fFinishedSingleMember= true;
626 * Finishes the configuration of the class DOM object which
627 * was created by a previous enterClass call.
629 * @see IDocumentElementRequestor#exitClass(int, int)
631 public void exitClass(int bodyEnd, int declarationEnd) {
632 exitType(bodyEnd, declarationEnd);
635 * Finishes the configuration of the method DOM object which
636 * was created by a previous enterConstructor call.
638 * @see IDocumentElementRequestor#exitConstructor(int, int)
640 public void exitConstructor(int bodyEnd, int declarationEnd) {
641 exitAbstractMethod(bodyEnd, declarationEnd);
644 * Finishes the configuration of the field DOM object which
645 * was created by a previous enterField call.
647 * @see IDocumentElementRequestor#exitField(int, int)
649 public void exitField(int bodyEnd, int declarationEnd) {
650 DOMField field = (DOMField)fStack.pop();
651 if (field.getEndPosition() < declarationEnd) {
652 field.setSourceRangeEnd(declarationEnd);
653 int nameEnd = field.fNameRange[1];
654 if (nameEnd < bodyEnd) {
655 /* see 1FVIIV8 - obtain initializer range */
656 String initializer = new String(fDocument, nameEnd + 1, bodyEnd - nameEnd);
657 int index = initializer.indexOf('=');
659 field.setHasInitializer(true);
660 field.setInitializerRange(nameEnd + index + 2, bodyEnd);
666 if (fBuildingSingleMember) {
667 fFinishedSingleMember= true;
671 * Finishes the configuration of the interface DOM object which
672 * was created by a previous enterInterface call.
674 * @see IDocumentElementRequestor#exitInterface(int, int)
676 public void exitInterface(int bodyEnd, int declarationEnd) {
677 exitType(bodyEnd, declarationEnd);
680 * Finishes the configuration of the method DOM object which
681 * was created by a previous enterMethod call.
683 * @see IDocumentElementRequestor#exitMethod(int, int)
685 public void exitMethod(int bodyEnd, int declarationEnd) {
686 exitAbstractMethod(bodyEnd, declarationEnd);
689 * Creates a new parser.
691 protected DocumentElementParser getParser(Map settings) {
692 return new DocumentElementParser(this, new DefaultProblemFactory(), new CompilerOptions(settings));
695 * Initializes the builder to create a document fragment.
697 * @param sourceCode - the document containing the source code to be analyzed
698 * @param buildingCompilationUnit - true if a the document is being analyzed to
699 * create a compilation unit, otherwise false
700 * @param buildingType - true if the document is being analyzed to create a
701 * type or compilation unit
702 * @param singleMember - true if building a single member
704 protected void initializeBuild(char[] sourceCode, boolean buildingCompilationUnit, boolean buildingType, boolean singleMember) {
705 super.initializeBuild(sourceCode, buildingCompilationUnit, buildingType);
706 fBuildingSingleMember= singleMember;
707 fFinishedSingleMember= false;