예제 #1
0
파일: pretty.go 프로젝트: vito/go-play
func (self *HTMLStyler) Ident(id *ast.Ident) ([]byte, printer.HTMLTag) {
	classes := "go-local"
	if id.IsExported() {
		classes = "go-exported"
	}

	switch id.String() {
	case "bool", "uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64", "float32", "float64", "byte", "uint", "int", "float", "uintptr", "string":
		classes += " go-prim-ident"
	default:
		if tok, ok := self.prev.(token.Token); ok && tok.String() == "func" || tok.String() == ")" {
			classes += " go-func-ident"
		}
	}

	self.prev = id

	return []byte(id.String()), printer.HTMLTag{
		Start: "<span class=\"go-ident " + classes + "\">",
		End:   "</span>",
	}
}
예제 #2
0
func (m *mDeclarations) kind(id *ast.Ident, k string) string {
	if id.IsExported() {
		return "+ " + k
	}
	return "- " + k
}