Documentation ¶
Index ¶
- type BooleanUnfold
- type RewriteAction
- func AddAssignmentAction(assignment veneers.Assignment) RewriteAction
- func AddCommentsAction(comments []string) RewriteAction
- func ArrayToAppendAction() RewriteAction
- func DisjunctionAsOptionsAction() RewriteAction
- func DuplicateAction(duplicateName string) RewriteAction
- func MapToIndexAction() RewriteAction
- func OmitAction() RewriteAction
- func RenameAction(newName string) RewriteAction
- func RenameArgumentsAction(newNames []string) RewriteAction
- func StructFieldsAsArgumentsAction(explicitFields ...string) RewriteAction
- func StructFieldsAsOptionsAction(explicitFields ...string) RewriteAction
- func UnfoldBooleanAction(unfoldOpts BooleanUnfold) RewriteAction
- func VeneerTrailAsCommentsAction() RewriteAction
- type RewriteRule
- func AddAssignment(selector Selector, assignment veneers.Assignment) RewriteRule
- func AddComments(selector Selector, comments []string) RewriteRule
- func ArrayToAppend(selector Selector) RewriteRule
- func DisjunctionAsOptions(selector Selector) RewriteRule
- func Duplicate(selector Selector, duplicateName string) RewriteRule
- func MapToIndex(selector Selector) RewriteRule
- func Omit(selector Selector) RewriteRule
- func Rename(selector Selector, newName string) RewriteRule
- func RenameArguments(selector Selector, newNames []string) RewriteRule
- func StructFieldsAsArguments(selector Selector, explicitFields ...string) RewriteRule
- func StructFieldsAsOptions(selector Selector, explicitFields ...string) RewriteRule
- func UnfoldBoolean(selector Selector, unfoldOpts BooleanUnfold) RewriteRule
- func VeneerTrailAsComments(selector Selector) RewriteRule
- type Selector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BooleanUnfold ¶
type RewriteAction ¶
func AddAssignmentAction ¶
func AddAssignmentAction(assignment veneers.Assignment) RewriteAction
AddAssignmentAction adds an assignment to an existing option.
func AddCommentsAction ¶ added in v0.0.11
func AddCommentsAction(comments []string) RewriteAction
AddCommentsAction adds comments to an option.
func ArrayToAppendAction ¶
func ArrayToAppendAction() RewriteAction
ArrayToAppendAction updates the option to perform an "append" assignment.
Example:
``` func Tags(tags []string) { this.resource.tags = tags } ```
Will become:
``` func Tags(tags string) { this.resource.tags.append(tags) } ```
This action returns the option unchanged if:
- it doesn't have exactly one argument
- the argument is not an array
func DisjunctionAsOptionsAction ¶
func DisjunctionAsOptionsAction() RewriteAction
DisjunctionAsOptionsAction uses the branches of the first argument's disjunction (assuming it is one) and turns them into options.
Example:
``` func Panel(panel Panel|Row) { this.resource.panels.append(panel) } ```
Will become:
``` func Panel(panel Panel) { this.resource.panels.append(panel) } func Row(row Row) { this.resource.panels.append(row) } ```
This action returns the option unchanged if:
- it has no arguments
- the first argument is not a disjunction or a reference to one
FIXME: considers the first argument only.
func DuplicateAction ¶
func DuplicateAction(duplicateName string) RewriteAction
func MapToIndexAction ¶ added in v0.0.8
func MapToIndexAction() RewriteAction
MapToIndexAction updates the option to perform an "index" assignment.
Example:
``` func Elements(elements map[string]Element) { this.resource.elements = elements } ```
Will become:
``` func Elements(key string, elements Element) { this.resource.elements[key] = tags } ```
This action returns the option unchanged if:
- it doesn't have exactly one argument
- the argument is not a map
func RenameArgumentsAction ¶
func RenameArgumentsAction(newNames []string) RewriteAction
RenameArgumentsAction renames the arguments of an options.
func StructFieldsAsArgumentsAction ¶
func StructFieldsAsArgumentsAction(explicitFields ...string) RewriteAction
StructFieldsAsArgumentsAction uses the fields of the first argument's struct (assuming it is one) and turns them into arguments.
Optionally, an explicit list of fields to turn into arguments can be given.
Example:
``` func Time(time {from string, to string) { this.resource.time = time } ```
Will become:
``` func Time(from string, to string) { this.resource.time.from = from this.resource.time.to = to } ```
This action returns the option unchanged if:
- it has no arguments
- the first argument is not a struct or a reference to one
FIXME: considers the first argument only.
func StructFieldsAsOptionsAction ¶
func StructFieldsAsOptionsAction(explicitFields ...string) RewriteAction
StructFieldsAsOptionsAction uses the fields of the first argument's struct (assuming it is one) and turns them into options.
Optionally, an explicit list of fields to turn into options can be given.
Example:
``` func GridPos(gridPos {x int, y int) { this.resource.gridPos = gridPos } ```
Will become:
``` func X(x int) { this.resource.gridPos.x = x } func Y(y int) { this.resource.gridPos.y = y } ```
This action returns the option unchanged if:
- it has no arguments
- the first argument is not a struct or a reference to one
FIXME: considers the first argument only.
func UnfoldBooleanAction ¶
func UnfoldBooleanAction(unfoldOpts BooleanUnfold) RewriteAction
UnfoldBooleanAction transforms an option accepting a boolean argument into two argument-less options.
Example:
``` func Editable(editable bool) { this.resource.editable = editable } ```
Will become:
``` func Editable() { this.resource.editable = true } func ReadOnly() { this.resource.editable = false } ```
func VeneerTrailAsCommentsAction ¶
func VeneerTrailAsCommentsAction() RewriteAction
VeneerTrailAsCommentsAction removes an option.
type RewriteRule ¶
type RewriteRule struct { Selector Selector Action RewriteAction }
func AddAssignment ¶
func AddAssignment(selector Selector, assignment veneers.Assignment) RewriteRule
func AddComments ¶ added in v0.0.11
func AddComments(selector Selector, comments []string) RewriteRule
func ArrayToAppend ¶
func ArrayToAppend(selector Selector) RewriteRule
func DisjunctionAsOptions ¶
func DisjunctionAsOptions(selector Selector) RewriteRule
func Duplicate ¶
func Duplicate(selector Selector, duplicateName string) RewriteRule
func MapToIndex ¶ added in v0.0.8
func MapToIndex(selector Selector) RewriteRule
func Omit ¶
func Omit(selector Selector) RewriteRule
func Rename ¶
func Rename(selector Selector, newName string) RewriteRule
func RenameArguments ¶
func RenameArguments(selector Selector, newNames []string) RewriteRule
func StructFieldsAsArguments ¶
func StructFieldsAsArguments(selector Selector, explicitFields ...string) RewriteRule
func StructFieldsAsOptions ¶
func StructFieldsAsOptions(selector Selector, explicitFields ...string) RewriteRule
func UnfoldBoolean ¶
func UnfoldBoolean(selector Selector, unfoldOpts BooleanUnfold) RewriteRule
func VeneerTrailAsComments ¶
func VeneerTrailAsComments(selector Selector) RewriteRule
type Selector ¶
func ByBuilder ¶
ByBuilder matches options by their name and the name of the builder containing them.. Note: the comparison on builder and options names is case-insensitive.