public class StructureHelper
extends java.lang.Object
Body parentBody = new ...; // for each child element SourceConstruct element = new ...; helper.resolveDuplicates(element); Body body = new ...; // create and initialize the body newElements.put(element, body); helper.pushChild(parentBody, element); parentBody.setChildren(helper.popChildren(parentBody).toArray(...));
Note that calling parentBody.addChild(element)
for each child
element would generally be less efficient than using the pattern shown above.
Clients can use this class as it stands or subclass it as circumstances warrant.
Constructor and Description |
---|
StructureHelper() |
Modifier and Type | Method and Description |
---|---|
java.util.List<IElement> |
popChildren(java.lang.Object body)
Retrieves and forgets the child elements previously remembered for the
given body.
|
void |
pushChild(java.lang.Object parentBody,
IElement child)
Remembers the given element as a child for the given parent body.
|
void |
resolveDuplicates(ISourceConstructImplExtension element)
Resolves duplicate source constructs by incrementing their
occurrence count . |
public final void pushChild(java.lang.Object parentBody, IElement child)
parentBody
- the body of a parent element (not null
)child
- the handle for a child element (not null
)popChildren(Object)
public final java.util.List<IElement> popChildren(java.lang.Object body)
body
- a body (not null
)null
)pushChild(Object, IElement)
public void resolveDuplicates(ISourceConstructImplExtension element)
occurrence count
.element
- a source construct (not null
)Copyright (c) 2014, 2018 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0