org.eclipse.xtext.xbase.compiler.output
Class TreeAppendable

java.lang.Object
  extended by org.eclipse.xtext.xbase.compiler.output.TreeAppendable
All Implemented Interfaces:
java.lang.CharSequence, ITraceRegionProvider, IAcceptor<java.lang.String>, IAppendable, ITreeAppendable

@NonNullByDefault
public class TreeAppendable
extends java.lang.Object
implements ITreeAppendable, IAcceptor<java.lang.String>, java.lang.CharSequence

Author:
Sebastian Zarnekow - Initial contribution and API

Nested Class Summary
static class TreeAppendable.Visitor
          A visitor can be used to manipulate an existing TreeAppendable or to create a completely new one recursively.
 
Constructor Summary
  TreeAppendable(ImportManager importManager, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, org.eclipse.emf.ecore.EObject source, java.lang.String indentation, java.lang.String lineSeparator)
           
protected TreeAppendable(SharedAppendableState state, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, org.eclipse.emf.ecore.EObject source)
           
protected TreeAppendable(SharedAppendableState state, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, java.util.Set<ILocationData> sourceLocations, boolean useForDebugging)
           
 
Method Summary
 void accept(java.lang.String text)
           
 TreeAppendable acceptVisitor(TreeAppendable.Visitor visitor)
           
 ITreeAppendable append(java.lang.CharSequence content)
           
 TreeAppendable append(JvmType type)
           
protected  void appendIndented(java.lang.String text)
           
protected  ITreeAppendable appendTreeAppendable(ITreeAppendable other)
           
 TreeAppendable appendUnsafe(java.lang.String string)
           
 char charAt(int index)
           
protected  void closeLastChild()
           
 void closeScope()
           
protected static java.util.Set<ILocationData> createAllLocationData(ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, org.eclipse.emf.ecore.EObject object, ILocationInFileProviderExtension.RegionDescription query)
           
protected static ILocationData createLocationData(org.eclipse.emf.ecore.EObject object, ITextRegionWithLineInformation textRegion)
           
protected static ILocationData createLocationData(ILocationInFileProvider locationProvider, org.eclipse.emf.ecore.EObject object, ILocationInFileProviderExtension.RegionDescription query)
           
 java.lang.String declareSyntheticVariable(java.lang.Object key, java.lang.String proposedName)
          declares a synthetic variable, where the name is not used in the current or any parent scope.
 java.lang.String declareVariable(java.lang.Object key, java.lang.String proposedName)
           
 TreeAppendable decreaseIndentation()
           
protected  void doGetContent(java.lang.StringBuilder result)
           
 java.util.List<? extends java.lang.Object> getChildren()
          Access the children of the TreeAppendable.
 java.lang.String getContent()
           
 java.util.List<java.lang.String> getImports()
           
 java.util.Set<ILocationData> getLocationData()
           
 java.lang.String getName(java.lang.Object key)
           
 java.lang.Object getObject(java.lang.String name)
           
 AbstractTraceRegion getTraceRegion()
          Returns the a trace region.
 boolean hasName(java.lang.Object key)
           
 boolean hasObject(java.lang.String name)
           
 TreeAppendable increaseIndentation()
           
 boolean isUseForDebugging()
           
 int length()
           
protected  void markClosed()
           
 TreeAppendable newLine()
           
 void openPseudoScope()
          opens a new variable scope, without having a new Java scope.
 void openScope()
          opens a new scope, backed up by a real Java Scope
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
           
 TreeAppendable trace(org.eclipse.emf.ecore.EObject object)
          same as trace(object, false)
 TreeAppendable trace(org.eclipse.emf.ecore.EObject object, boolean useForDebugging)
           
 ITreeAppendable trace(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature, int indexInList)
           
 TreeAppendable trace(org.eclipse.emf.ecore.EObject object, ILocationInFileProviderExtension.RegionDescription region, boolean useForDebugging)
           
 ITreeAppendable trace(ILocationData location)
           
 ITreeAppendable trace(ILocationData location, boolean useForDebugging)
           
 ITreeAppendable trace(java.lang.Iterable<? extends org.eclipse.emf.ecore.EObject> objects)
           
protected  TreeAppendable trace(java.util.Set<ILocationData> newData, boolean useForDebugging)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeAppendable

public TreeAppendable(ImportManager importManager,
                      ILocationInFileProvider locationProvider,
                      IJvmModelAssociations jvmModelAssociations,
                      org.eclipse.emf.ecore.EObject source,
                      java.lang.String indentation,
                      java.lang.String lineSeparator)

TreeAppendable

protected TreeAppendable(SharedAppendableState state,
                         ILocationInFileProvider locationProvider,
                         IJvmModelAssociations jvmModelAssociations,
                         org.eclipse.emf.ecore.EObject source)

TreeAppendable

protected TreeAppendable(SharedAppendableState state,
                         ILocationInFileProvider locationProvider,
                         IJvmModelAssociations jvmModelAssociations,
                         java.util.Set<ILocationData> sourceLocations,
                         boolean useForDebugging)
Method Detail

trace

public TreeAppendable trace(org.eclipse.emf.ecore.EObject object)
Description copied from interface: ITreeAppendable
same as trace(object, false)

Specified by:
trace in interface ITreeAppendable

trace

public TreeAppendable trace(org.eclipse.emf.ecore.EObject object,
                            boolean useForDebugging)
Specified by:
trace in interface ITreeAppendable
Parameters:
object - the object this part should be associated with
useForDebugging - whether the part is relevant for debugging

trace

public TreeAppendable trace(org.eclipse.emf.ecore.EObject object,
                            ILocationInFileProviderExtension.RegionDescription region,
                            boolean useForDebugging)

trace

protected TreeAppendable trace(java.util.Set<ILocationData> newData,
                               boolean useForDebugging)

trace

public ITreeAppendable trace(ILocationData location)
Specified by:
trace in interface ITreeAppendable

trace

public ITreeAppendable trace(ILocationData location,
                             boolean useForDebugging)
Specified by:
trace in interface ITreeAppendable
Parameters:
location - the location that should be traced
useForDebugging - whether the part is relevant for debugging

createLocationData

@Nullable
protected static ILocationData createLocationData(ILocationInFileProvider locationProvider,
                                                           org.eclipse.emf.ecore.EObject object,
                                                           ILocationInFileProviderExtension.RegionDescription query)

createAllLocationData

protected static java.util.Set<ILocationData> createAllLocationData(ILocationInFileProvider locationProvider,
                                                                    IJvmModelAssociations jvmModelAssociations,
                                                                    org.eclipse.emf.ecore.EObject object,
                                                                    ILocationInFileProviderExtension.RegionDescription query)

trace

public ITreeAppendable trace(java.lang.Iterable<? extends org.eclipse.emf.ecore.EObject> objects)
Specified by:
trace in interface ITreeAppendable
Parameters:
objects - the iterable of EObjects that contribute output. May not be empty.

trace

public ITreeAppendable trace(org.eclipse.emf.ecore.EObject object,
                             org.eclipse.emf.ecore.EStructuralFeature feature,
                             int indexInList)
Specified by:
trace in interface ITreeAppendable

createLocationData

protected static ILocationData createLocationData(org.eclipse.emf.ecore.EObject object,
                                                  ITextRegionWithLineInformation textRegion)

acceptVisitor

public TreeAppendable acceptVisitor(TreeAppendable.Visitor visitor)

getLocationData

public java.util.Set<ILocationData> getLocationData()

getChildren

public java.util.List<? extends java.lang.Object> getChildren()
Access the children of the TreeAppendable. The list contains either strings or other TreeAppendables. The list may be empty.

Returns:
the children of this appendable.

accept

public void accept(@Nullable
                   java.lang.String text)
Specified by:
accept in interface IAcceptor<java.lang.String>
This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.

markClosed

protected void markClosed()

closeLastChild

protected void closeLastChild()

append

public TreeAppendable append(JvmType type)
Specified by:
append in interface IAppendable
Specified by:
append in interface ITreeAppendable

appendTreeAppendable

protected ITreeAppendable appendTreeAppendable(ITreeAppendable other)

append

public ITreeAppendable append(java.lang.CharSequence content)
Specified by:
append in interface IAppendable
Specified by:
append in interface ITreeAppendable

appendUnsafe

public TreeAppendable appendUnsafe(java.lang.String string)

newLine

public TreeAppendable newLine()
Specified by:
newLine in interface IAppendable
Specified by:
newLine in interface ITreeAppendable

increaseIndentation

public TreeAppendable increaseIndentation()
Specified by:
increaseIndentation in interface IAppendable
Specified by:
increaseIndentation in interface ITreeAppendable

decreaseIndentation

public TreeAppendable decreaseIndentation()
Specified by:
decreaseIndentation in interface IAppendable
Specified by:
decreaseIndentation in interface ITreeAppendable

getImports

public java.util.List<java.lang.String> getImports()
Specified by:
getImports in interface IAppendable

openScope

public void openScope()
Description copied from interface: IAppendable
opens a new scope, backed up by a real Java Scope

Specified by:
openScope in interface IAppendable

openPseudoScope

public void openPseudoScope()
Description copied from interface: IAppendable
opens a new variable scope, without having a new Java scope.

Specified by:
openPseudoScope in interface IAppendable

declareVariable

public java.lang.String declareVariable(java.lang.Object key,
                                        java.lang.String proposedName)
Specified by:
declareVariable in interface IAppendable

declareSyntheticVariable

public java.lang.String declareSyntheticVariable(java.lang.Object key,
                                                 java.lang.String proposedName)
Description copied from interface: IAppendable
declares a synthetic variable, where the name is not used in the current or any parent scope.

Specified by:
declareSyntheticVariable in interface IAppendable

getName

public java.lang.String getName(java.lang.Object key)
Specified by:
getName in interface IAppendable

hasName

public boolean hasName(java.lang.Object key)
Specified by:
hasName in interface IAppendable

getObject

public java.lang.Object getObject(java.lang.String name)
Specified by:
getObject in interface IAppendable

hasObject

public boolean hasObject(java.lang.String name)
Specified by:
hasObject in interface IAppendable

closeScope

public void closeScope()
Specified by:
closeScope in interface IAppendable

getContent

public java.lang.String getContent()
Specified by:
getContent in interface IAppendable

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Specified by:
toString in interface IAppendable
Overrides:
toString in class java.lang.Object

doGetContent

protected void doGetContent(java.lang.StringBuilder result)

length

public int length()
Specified by:
length in interface java.lang.CharSequence
Specified by:
length in interface IAppendable

getTraceRegion

public AbstractTraceRegion getTraceRegion()
Description copied from interface: ITraceRegionProvider
Returns the a trace region.

Specified by:
getTraceRegion in interface ITraceRegionProvider

appendIndented

protected void appendIndented(java.lang.String text)

isUseForDebugging

public boolean isUseForDebugging()