fillswitch

command
v0.0.0-...-f5f96ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: BSD-2-Clause Imports: 21 Imported by: 0

README

fillswitch Build Status Coverage Status GoDoc Go Report Card

fillswitch - fills (type) switches with case statements


For example, the following (type) switches,

var stmt ast.Stmt
switch stmt := stmt.(type) {
}

var kind ast.ObjKind
switch kind {
}

become:

var stmt ast.Stmt
switch stmt := stmt.(type) {
case *ast.AssignStmt:
case *ast.BadStmt:
case *ast.BlockStmt:
case *ast.BranchStmt:
case *ast.CaseClause:
case *ast.CommClause:
case *ast.DeclStmt:
case *ast.DeferStmt:
case *ast.EmptyStmt:
case *ast.ExprStmt:
case *ast.ForStmt:
case *ast.GoStmt:
case *ast.IfStmt:
case *ast.IncDecStmt:
case *ast.LabeledStmt:
case *ast.RangeStmt:
case *ast.ReturnStmt:
case *ast.SelectStmt:
case *ast.SendStmt:
case *ast.SwitchStmt:
case *ast.TypeSwitchStmt:
}

var kind ast.ObjKind
switch kind {
case ast.Bad:
case ast.Con:
case ast.Fun:
case ast.Lbl:
case ast.Pkg:
case ast.Typ:
case ast.Var:
}

after applying fillswitch for the (type) switch statements.

Installation

% go get -u github.com/davidrjenni/reftools/cmd/fillswitch

Usage

% fillswitch [-modified] -file=<filename> -offset=<byte offset> -line=<line number>

Flags:

-file:     filename
-modified: read an archive of modified files from stdin
-offset:   byte offset of the (type) switch, optional if -line is present
-line:     line number of the (type) switch, optional if -offset is present

If -offset as well as -line are present, then the tool first uses the more specific offset information. If there was no (type) switch found at the given offset, then the line information is used.

Documentation

Overview

Fillswitch fills a (type) switch with case statements.

For example, the following (type) switches,

var stmt ast.Stmt
switch stmt := stmt.(type) {
}

var kind ast.ObjKind
switch kind {
}

become:

var stmt ast.Stmt
switch stmt := stmt.(type) {
case *ast.AssignStmt:
case *ast.BadStmt:
case *ast.BlockStmt:
case *ast.BranchStmt:
case *ast.CaseClause:
case *ast.CommClause:
case *ast.DeclStmt:
case *ast.DeferStmt:
case *ast.EmptyStmt:
case *ast.ExprStmt:
case *ast.ForStmt:
case *ast.GoStmt:
case *ast.IfStmt:
case *ast.IncDecStmt:
case *ast.LabeledStmt:
case *ast.RangeStmt:
case *ast.ReturnStmt:
case *ast.SelectStmt:
case *ast.SendStmt:
case *ast.SwitchStmt:
case *ast.TypeSwitchStmt:
}

var kind ast.ObjKind
switch kind {
case ast.Bad:
case ast.Con:
case ast.Fun:
case ast.Lbl:
case ast.Pkg:
case ast.Typ:
case ast.Var:
}

after applying fillswitch for the (type) switch statements.

Usage:

% fillstruct [-modified] -file=<filename> -offset=<byte offset> -line=<line number>

Flags:

-file: filename

-modified: read an archive of modified files from stdin

-offset: byte offset of the (type) switch, optional if -line is present

-line: line number of the (type) switch, optional if -offset is present

If -offset as well as -line are present, then the tool first uses the more specific offset information. If there was no (type) switch found at the given offset, then the line information is used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL