public class Transformer
extends java.lang.Object
Red (tfeng) |
Red (tfeng) |
Modifier and Type | Field and Description |
---|---|
static TransformRule[] |
RULES
The refactoring rules to be sequentially applied to the source code.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_afterTraverse()
Call the afterTraverse of all the refactoring rules.
|
protected void |
_beforeTraverse()
Call the beforeTraverse of all the refactoring rules.
|
protected static void |
_outputConfig()
Output XML configuration to the pre-defined file (specified with
"-config" argument in
main(String[]) ). |
protected void |
_outputSource(java.io.Writer writer,
java.lang.String fileName)
Output the Java source from the current AST with
ASTFormatter . |
protected void |
_parse()
Parse the Java source and retrieve the AST.
|
protected void |
_startTransform()
Start the transformation by first parsing the source with
_parse() , then call _beforeTraverse() ,
then traverse the AST with TypeAnalyzer visitor,
and finally call _afterTraverse() . |
static void |
main(java.lang.String[] args)
Transform a set of files into backtracking-enabled ones.
|
static int |
parseArguments(java.lang.String[] args,
int position)
Parse the command-line arguments starting from the given position.
|
static void |
transform(java.lang.String fileName,
org.eclipse.jdt.core.dom.CompilationUnit ast,
java.io.Writer writer,
java.lang.String[] classPaths,
java.lang.String[] crossAnalyzedTypes)
Transform the AST with given class paths, and output the result to
the writer.
|
static void |
transform(java.lang.String fileName,
java.io.Writer writer)
Transform the Java source in the file given by its name with no
explicit class path, and output the result to the writer.
|
static void |
transform(java.lang.String fileName,
java.io.Writer writer,
java.lang.String[] classPaths)
Transform the Java source in the file given by its name with
given class paths, and output the result to the writer.
|
static void |
transform(java.lang.String fileName,
java.io.Writer writer,
java.lang.String[] classPaths,
java.lang.String[] crossAnalyzedTypes)
Transform the Java source in the file given by its name with
given class paths, and output the result to the writer.
|
public static TransformRule[] RULES
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- The array of file names or names of directories.java.lang.Exception
- If any exception occures.public static int parseArguments(java.lang.String[] args, int position)
args
- The command-line arguments.position
- The starting position.public static void transform(java.lang.String fileName, org.eclipse.jdt.core.dom.CompilationUnit ast, java.io.Writer writer, java.lang.String[] classPaths, java.lang.String[] crossAnalyzedTypes) throws java.io.IOException, ASTMalformedException
If a output directory is set with the -output command-line argument, the output is written to a Java source file with that directory as the root directory. The given writer is not used in that case.
fileName
- The Java file name.ast
- The AST to be refactored.writer
- The writer where output is written.classPaths
- The class paths.crossAnalyzedTypes
- The array of names of types to be added to
the visitor's cross-analyzed types list.java.io.IOException
- If IO exception occurs when reading from
the Java file or riting to the output.ASTMalformedException
- If the Java source is illegal.transform(String, Writer)
public static void transform(java.lang.String fileName, java.io.Writer writer) throws java.io.IOException, ASTMalformedException
fileName
- The Java file name.writer
- The writer where output is written.java.io.IOException
- If IO exception occurs when reading from
the Java file or riting to the output.ASTMalformedException
- If the Java source is illegal.transform(String, Writer, String[])
public static void transform(java.lang.String fileName, java.io.Writer writer, java.lang.String[] classPaths) throws java.io.IOException, ASTMalformedException
If a output directory is set with the -output command-line argument, the output is written to a Java source file with that directory as the root directory. The given writer is not used in that case.
fileName
- The Java file name.writer
- The writer where output is written.classPaths
- The class paths.java.io.IOException
- If IO exception occurs when reading from
the Java file or riting to the output.ASTMalformedException
- If the Java source is illegal.transform(String, Writer)
public static void transform(java.lang.String fileName, java.io.Writer writer, java.lang.String[] classPaths, java.lang.String[] crossAnalyzedTypes) throws java.io.IOException, ASTMalformedException
If a output directory is set with the -output command-line argument, the output is written to a Java source file with that directory as the root directory. The given writer is not used in that case.
fileName
- The Java file name.writer
- The writer where output is written.classPaths
- The class paths.crossAnalyzedTypes
- The array of names of types to be added to
the visitor's cross-analyzed types list.java.io.IOException
- If IO exception occurs when reading from
the Java file or riting to the output.ASTMalformedException
- If the Java source is illegal.transform(String, Writer)
protected void _afterTraverse()
protected void _beforeTraverse()
protected static void _outputConfig() throws java.lang.Exception
main(String[])
).java.lang.Exception
- If any error occurs.protected void _outputSource(java.io.Writer writer, java.lang.String fileName) throws java.io.IOException
ASTFormatter
.writer
- The writer where the output is written to.fileName
- The file name of the writer.java.io.IOException
- If error occurs while writing to the writer.protected void _parse() throws java.io.IOException, ASTMalformedException
java.io.IOException
- If a file name is given, but exception
occurs when reading from the file.ASTMalformedException
- If the source is illegal.protected void _startTransform() throws java.io.IOException, ASTMalformedException
_parse()
, then call _beforeTraverse()
,
then traverse the AST with TypeAnalyzer
visitor,
and finally call _afterTraverse()
.java.io.IOException
- If a file name is given, but exception
occurs when reading from the file.ASTMalformedException
- If the source is illegal._afterTraverse()
,
_beforeTraverse()
,
_parse()