org.eclipse.xtext.formatting.impl
Class FormattingConfigBasedStream

java.lang.Object
  extended by org.eclipse.xtext.formatting.impl.AbstractTokenStream
      extended by org.eclipse.xtext.formatting.impl.BaseTokenStream
          extended by org.eclipse.xtext.formatting.impl.FormattingConfigBasedStream
All Implemented Interfaces:
ITokenStream, ITokenStreamExtension

public class FormattingConfigBasedStream
extends BaseTokenStream

Author:
Moritz Eysholdt - Initial contribution and API

Nested Class Summary
protected  class FormattingConfigBasedStream.Line
           
protected  class FormattingConfigBasedStream.LineEntry
           
 
Field Summary
protected  java.util.Set<AbstractFormattingConfig.ElementLocator> activeRangeLocators
           
protected  FormattingConfig cfg
           
protected  FormattingConfigBasedStream.Line currentLine
           
protected  IHiddenTokenHelper hiddenTokenHelper
           
protected  int indentationLevel
           
protected  java.lang.String indentationPrefix
           
protected  org.eclipse.emf.ecore.EObject last
           
protected  IElementMatcherProvider.IElementMatcher<AbstractFormattingConfig.ElementPattern> matcher
           
protected  java.lang.String preservedWS
           
protected  boolean preserveSpaces
           
 
Fields inherited from class org.eclipse.xtext.formatting.impl.BaseTokenStream
out
 
Constructor Summary
FormattingConfigBasedStream(ITokenStream out, java.lang.String indentation, FormattingConfig cfg, IElementMatcherProvider.IElementMatcher<AbstractFormattingConfig.ElementPattern> matcher, IHiddenTokenHelper hiddenTokenHelper, boolean preserveSpaces)
           
 
Method Summary
protected  void addLineEntry(org.eclipse.emf.ecore.EObject grammarElement, java.lang.String value, boolean isHidden)
           
protected  java.util.Set<AbstractFormattingConfig.ElementLocator> collectLocators(org.eclipse.emf.ecore.EObject ele)
           
protected  java.util.Set<AbstractFormattingConfig.ElementLocator> collectLocatorsForComments(java.util.Collection<AbstractFormattingConfig.ElementLocator> semanticLocators, org.eclipse.emf.ecore.EObject left, org.eclipse.emf.ecore.EObject right)
           
protected  FormattingConfigBasedStream.Line createLine()
           
protected  FormattingConfigBasedStream.Line createLine(int leftover)
           
protected  FormattingConfigBasedStream.Line createLine(java.util.List<FormattingConfigBasedStream.LineEntry> entries)
           
protected  FormattingConfigBasedStream.Line createLine(java.util.List<FormattingConfigBasedStream.LineEntry> initialEntries, int leftover)
           
 FormattingConfigBasedStream.LineEntry createLineEntry(org.eclipse.emf.ecore.EObject grammarElement, java.lang.String value, boolean isHidden, java.util.Set<AbstractFormattingConfig.ElementLocator> beforeLocators, java.lang.String leadingWS, int indent, ParserRule hiddenTokenDefition)
           
protected  Pair<java.lang.Integer,RuleCall> findTopmostHiddenTokenDef()
           
 void flush()
           
 void init(ParserRule startRule)
           
 void writeHidden(org.eclipse.emf.ecore.EObject grammarElement, java.lang.String value)
           
 void writeSemantic(org.eclipse.emf.ecore.EObject grammarElement, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeRangeLocators

protected java.util.Set<AbstractFormattingConfig.ElementLocator> activeRangeLocators

cfg

protected FormattingConfig cfg

currentLine

protected FormattingConfigBasedStream.Line currentLine

hiddenTokenHelper

protected IHiddenTokenHelper hiddenTokenHelper

indentationLevel

protected int indentationLevel

indentationPrefix

protected java.lang.String indentationPrefix

last

protected org.eclipse.emf.ecore.EObject last

matcher

protected IElementMatcherProvider.IElementMatcher<AbstractFormattingConfig.ElementPattern> matcher

preservedWS

protected java.lang.String preservedWS

preserveSpaces

protected boolean preserveSpaces
Constructor Detail

FormattingConfigBasedStream

public FormattingConfigBasedStream(ITokenStream out,
                                   java.lang.String indentation,
                                   FormattingConfig cfg,
                                   IElementMatcherProvider.IElementMatcher<AbstractFormattingConfig.ElementPattern> matcher,
                                   IHiddenTokenHelper hiddenTokenHelper,
                                   boolean preserveSpaces)
Method Detail

addLineEntry

protected void addLineEntry(org.eclipse.emf.ecore.EObject grammarElement,
                            java.lang.String value,
                            boolean isHidden)
                     throws java.io.IOException
Throws:
java.io.IOException

collectLocators

protected java.util.Set<AbstractFormattingConfig.ElementLocator> collectLocators(org.eclipse.emf.ecore.EObject ele)

collectLocatorsForComments

protected java.util.Set<AbstractFormattingConfig.ElementLocator> collectLocatorsForComments(java.util.Collection<AbstractFormattingConfig.ElementLocator> semanticLocators,
                                                                                            org.eclipse.emf.ecore.EObject left,
                                                                                            org.eclipse.emf.ecore.EObject right)

createLine

protected FormattingConfigBasedStream.Line createLine()

createLine

protected FormattingConfigBasedStream.Line createLine(int leftover)

createLine

protected FormattingConfigBasedStream.Line createLine(java.util.List<FormattingConfigBasedStream.LineEntry> entries)

createLine

protected FormattingConfigBasedStream.Line createLine(java.util.List<FormattingConfigBasedStream.LineEntry> initialEntries,
                                                      int leftover)

createLineEntry

public FormattingConfigBasedStream.LineEntry createLineEntry(org.eclipse.emf.ecore.EObject grammarElement,
                                                             java.lang.String value,
                                                             boolean isHidden,
                                                             java.util.Set<AbstractFormattingConfig.ElementLocator> beforeLocators,
                                                             java.lang.String leadingWS,
                                                             int indent,
                                                             ParserRule hiddenTokenDefition)

findTopmostHiddenTokenDef

protected Pair<java.lang.Integer,RuleCall> findTopmostHiddenTokenDef()

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface ITokenStream
Overrides:
flush in class BaseTokenStream
Throws:
java.io.IOException

init

public void init(ParserRule startRule)
Specified by:
init in interface ITokenStreamExtension
Overrides:
init in class BaseTokenStream

writeHidden

public void writeHidden(org.eclipse.emf.ecore.EObject grammarElement,
                        java.lang.String value)
                 throws java.io.IOException
Specified by:
writeHidden in interface ITokenStream
Overrides:
writeHidden in class AbstractTokenStream
Throws:
java.io.IOException

writeSemantic

public void writeSemantic(org.eclipse.emf.ecore.EObject grammarElement,
                          java.lang.String value)
                   throws java.io.IOException
Specified by:
writeSemantic in interface ITokenStream
Overrides:
writeSemantic in class AbstractTokenStream
Throws:
java.io.IOException