Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommentRefactor ¶
type CommentRefactor struct{}
CommentRefactor is the to refactor the comments present in a source code file
func NewCommentRefactor ¶
func NewCommentRefactor() CommentRefactor
NewCommentRefactor is the constructor for the comment refactor
func (CommentRefactor) Initiate ¶
Initiate will initiate the refactoring of comments corresponding to the go source file name provided It will send the comments through the out channel and expects the refactored input for each import send in the output to come If any error happens in the process it will send through the error channel. After ranging over the out channel check for the last error from the error channel so that error while finishing the refactoring is captured
type NonGoFileRefactor ¶
type NonGoFileRefactor struct{}
NonGoFileRefactor does refactor non-go files
func NewNonGoFileRefactor ¶
func NewNonGoFileRefactor() NonGoFileRefactor
NewNonGoFileRefactor is the constructor for the non go file refactor
func (NonGoFileRefactor) Initiate ¶
Initiate will initiate the refactoring of content in non-go source file name provided It will send the content through the out channel and expects the refactored input for each import send in the output to come If any error happens in the process it will send through the error channel. After ranging over the out channel check for the last error from the error channel so that error while finishing the refactoring is captured
type PackageRefactor ¶
type PackageRefactor struct { }
PackageRefactor is the to refactor the import package names present in a source code file
func NewPackageRefactor ¶
func NewPackageRefactor() PackageRefactor
NewPackageRefactor is the constructor for the package import name refactor
func (PackageRefactor) Initiate ¶
Initiate will initiate the refactoring of import packages corresponding to the go source file name provided It will send the imports through the out channel and expects the refactored input for each import send in the output to come If any error happens in the process it will send through the error channel. After ranging over the out channel check for the last error from the error channel so that error while finishing the refactoring is captured
type Refactor ¶
type Refactor struct { //Name to identify the refactor Name string //Find is the string to be found Find string //Replace is the string to be replaced in the place of the string to be found Replace string //IsRegex indicates that the string to be found is a regular expression IsRegex bool //Source is the source to be refactored Source RefactorSource }
Refactor is represents a change to be done in a source file
type RefactorSource ¶
type RefactorSource interface { //Initiate will read the given file and initiate the refactoring. Through the returned output //channel the code to be refactored will be streamed and through the in channel it will replace the code with the refactored one. //During processing of each source code stream, if any error occurs it will be pushed to the error channel. Else nil will be pushed to it. //The absolute path to the file from the refactor source code string has to be recovered //This method also returns the error if any else nil is returned Initiate(file string, in chan string) (chan string, chan error, error) }
RefactorSource has to be implmented by any source to act as an source code to be refactored
type Source ¶
type Source struct { //Path is absolute path at which the source file exists Path string //FileName is the name of the source file FileName string //RelativeDestination is the relative path in the destination to put the refactored file RelativeDestination string //Refactors is the list of refactors Refactors []Refactor }
Source holds the source file and list of refactors to be done on it
func (*Source) Copy ¶
Copy copies a source file to a given destination. The destination shouldn't have the destination file name. It should only contain the absolute path to the destination directory. If any error occurs while copying, like unsuccessful copying of the file, or unsuccessful creation of the destination directory, it will be reported back. It will also return the absolute path to the destination file.
func (*Source) Generate ¶
Generate will generate a source file in the given destination path. It will copy the source file and makes the required refactors in the newly created destination file. The required destination directory has to be provided as argument. The file name will be same as the source. If the file name also has to be changed, it has to be specified under the refactor list.