1
0
mirror of https://github.com/golang/go synced 2024-10-04 17:21:20 -06:00
go/src/cmd/fix/imageycbcr.go
Rob Pike 71d83b72ef cmd/go: add go tools to rearrangement
fix, vet
yacc is also fixed (it was wrong before)
All that's left is the commands used during compilation
This looks like a huge CL, but it's almost all file renames.
The action is in cmd/go/pkg.go, the Makefiles, and .../doc.go.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5595044
2012-01-29 11:07:25 -08:00

65 lines
1.3 KiB
Go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"go/ast"
)
func init() {
register(imageycbcrFix)
}
var imageycbcrFix = fix{
"imageycbcr",
"2011-12-20",
imageycbcr,
`Adapt code to types moved from image/ycbcr to image and image/color.
http://codereview.appspot.com/5493084
`,
}
func imageycbcr(f *ast.File) (fixed bool) {
if !imports(f, "image/ycbcr") {
return
}
walk(f, func(n interface{}) {
s, ok := n.(*ast.SelectorExpr)
if !ok || !isTopName(s.X, "ycbcr") {
return
}
switch s.Sel.String() {
case "RGBToYCbCr", "YCbCrToRGB":
addImport(f, "image/color")
s.X.(*ast.Ident).Name = "color"
case "YCbCrColor":
addImport(f, "image/color")
s.X.(*ast.Ident).Name = "color"
s.Sel.Name = "YCbCr"
case "YCbCrColorModel":
addImport(f, "image/color")
s.X.(*ast.Ident).Name = "color"
s.Sel.Name = "YCbCrModel"
case "SubsampleRatio", "SubsampleRatio444", "SubsampleRatio422", "SubsampleRatio420":
addImport(f, "image")
s.X.(*ast.Ident).Name = "image"
s.Sel.Name = "YCbCr" + s.Sel.Name
case "YCbCr":
addImport(f, "image")
s.X.(*ast.Ident).Name = "image"
default:
return
}
fixed = true
})
deleteImport(f, "image/ycbcr")
return
}