com.threerings.presents.tools
Class GeneratedSourceMerger

java.lang.Object
  extended by com.threerings.presents.tools.GeneratedSourceMerger

public class GeneratedSourceMerger
extends Object

Merges updates to a generated source file into a previously generated version of that source while leaving changes outside marked sections alone.


Nested Class Summary
protected static class GeneratedSourceMerger.Section
           
 
Field Summary
protected  Pattern _sectionDelimiter
           
 
Constructor Summary
GeneratedSourceMerger()
           
 
Method Summary
protected  GeneratedSourceMerger.Section extractGeneratedSection(Matcher m, String input)
          Returns a section name and its contents from the given matcher pointing to the start of a section.
 String merge(String newlyGenerated, String previouslyGenerated)
          Returns previouslyGenerated with marked sections updated from the same marked sections in newlyGenerated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sectionDelimiter

protected final Pattern _sectionDelimiter
Constructor Detail

GeneratedSourceMerger

public GeneratedSourceMerger()
Method Detail

merge

public String merge(String newlyGenerated,
                    String previouslyGenerated)
             throws Exception
Returns previouslyGenerated with marked sections updated from the same marked sections in newlyGenerated. Everything outside these sections in previouslyGenerated is returned as is. A marked section starts with // GENERATED {name} START and ends with // GENERATED {name} END

If previouslyGenerated has a generated section replaced with // GENERATED {name} DISABLED, that section will no longer be updated.

Throws:
Exception

extractGeneratedSection

protected GeneratedSourceMerger.Section extractGeneratedSection(Matcher m,
                                                                String input)
Returns a section name and its contents from the given matcher pointing to the start of a section. m is at the end of the section when this returns.