Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 40 for CompositeLit (0.33 sec)

  1. src/cmd/gofmt/simplify.go

    package main
    
    import (
    	"go/ast"
    	"go/token"
    	"reflect"
    )
    
    type simplifier struct{}
    
    func (s simplifier) Visit(node ast.Node) ast.Visitor {
    	switch n := node.(type) {
    	case *ast.CompositeLit:
    		// array, slice, and map composite literals may be simplified
    		outer := n
    		var keyType, eltType ast.Expr
    		switch typ := outer.Type.(type) {
    		case *ast.ArrayType:
    			eltType = typ.Elt
    		case *ast.MapType:
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 19 20:06:14 UTC 2022
    - 4.8K bytes
    - Viewed (0)
  2. src/cmd/fix/netipv6zone.go

    https://codereview.appspot.com/6849045/
    `,
    }
    
    func netipv6zone(f *ast.File) bool {
    	if !imports(f, "net") {
    		return false
    	}
    
    	fixed := false
    	walk(f, func(n any) {
    		cl, ok := n.(*ast.CompositeLit)
    		if !ok {
    			return
    		}
    		se, ok := cl.Type.(*ast.SelectorExpr)
    		if !ok {
    			return
    		}
    		if !isTopName(se.X, "net") || se.Sel == nil {
    			return
    		}
    		switch ss := se.Sel.String(); ss {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 13 18:45:54 UTC 2021
    - 1.3K bytes
    - Viewed (0)
  3. src/cmd/compile/internal/syntax/nodes_test.go

    	{"BasicLit", `@0x123`},
    	{"BasicLit", `@3.1415`},
    	{"BasicLit", `@.2718`},
    	{"BasicLit", `@1i`},
    	{"BasicLit", `@'a'`},
    	{"BasicLit", `@"abc"`},
    	{"BasicLit", "@`abc`"},
    
    	{"CompositeLit", `@{}`},
    	{"CompositeLit", `T@{}`},
    	{"CompositeLit", `struct{x, y int}@{}`},
    
    	{"KeyValueExpr", `"foo"@: true`},
    	{"KeyValueExpr", `"a"@: b`},
    
    	{"FuncLit", `@func (){}`},
    	{"ParenExpr", `@(x)`},
    	{"SelectorExpr", `a@.b`},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Nov 02 18:45:06 UTC 2023
    - 8.7K bytes
    - Viewed (0)
  4. src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go

    }
    
    func run(pass *analysis.Pass) (interface{}, error) {
    	inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
    
    	nodeFilter := []ast.Node{
    		(*ast.AssignStmt)(nil),
    		(*ast.CallExpr)(nil),
    		(*ast.CompositeLit)(nil),
    		(*ast.FuncDecl)(nil),
    		(*ast.FuncLit)(nil),
    		(*ast.GenDecl)(nil),
    		(*ast.RangeStmt)(nil),
    		(*ast.ReturnStmt)(nil),
    	}
    	inspect.Preorder(nodeFilter, func(node ast.Node) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 04 16:19:04 UTC 2024
    - 9.9K bytes
    - Viewed (0)
  5. src/go/doc/exports.go

    func filterCompositeLit(lit *ast.CompositeLit, filter Filter, export bool) {
    	n := len(lit.Elts)
    	lit.Elts = filterExprList(lit.Elts, filter, export)
    	if len(lit.Elts) < n {
    		lit.Incomplete = true
    	}
    }
    
    func filterExprList(list []ast.Expr, filter Filter, export bool) []ast.Expr {
    	j := 0
    	for _, exp := range list {
    		switch x := exp.(type) {
    		case *ast.CompositeLit:
    			filterCompositeLit(x, filter, export)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Apr 01 18:18:07 UTC 2022
    - 8.5K bytes
    - Viewed (0)
  6. src/cmd/fix/printerconfig.go

    }
    
    func printerconfig(f *ast.File) bool {
    	if !imports(f, "go/printer") {
    		return false
    	}
    
    	fixed := false
    	walk(f, func(n any) {
    		cl, ok := n.(*ast.CompositeLit)
    		if !ok {
    			return
    		}
    		se, ok := cl.Type.(*ast.SelectorExpr)
    		if !ok {
    			return
    		}
    		if !isTopName(se.X, "printer") || se.Sel == nil {
    			return
    		}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 13 18:45:54 UTC 2021
    - 1.1K bytes
    - Viewed (0)
  7. src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go

    // unkeyed fields.
    func run(pass *analysis.Pass) (interface{}, error) {
    	inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
    
    	nodeFilter := []ast.Node{
    		(*ast.CompositeLit)(nil),
    	}
    	inspect.Preorder(nodeFilter, func(n ast.Node) {
    		cl := n.(*ast.CompositeLit)
    
    		typ := pass.TypesInfo.Types[cl].Type
    		if typ == nil {
    			// cannot determine composite literals' type, skip it
    			return
    		}
    		typeName := typ.String()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 4.4K bytes
    - Viewed (0)
  8. src/cmd/compile/internal/syntax/positions.go

    		// case *ImportDecl:
    		// case *ConstDecl:
    		// case *TypeDecl:
    		// case *VarDecl:
    		// case *FuncDecl:
    
    		// expressions
    		// case *BadExpr:
    		// case *Name:
    		// case *BasicLit:
    		case *CompositeLit:
    			if n.Type != nil {
    				m = n.Type
    				continue
    			}
    			return n.Pos()
    		case *KeyValueExpr:
    			m = n.Key
    		// case *FuncLit:
    		// case *ParenExpr:
    		case *SelectorExpr:
    			m = n.X
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jun 10 17:49:19 UTC 2024
    - 6.5K bytes
    - Viewed (0)
  9. src/go/ast/filter.go

    	return
    }
    
    func filterCompositeLit(lit *CompositeLit, filter Filter, export bool) {
    	n := len(lit.Elts)
    	lit.Elts = filterExprList(lit.Elts, filter, export)
    	if len(lit.Elts) < n {
    		lit.Incomplete = true
    	}
    }
    
    func filterExprList(list []Expr, filter Filter, export bool) []Expr {
    	j := 0
    	for _, exp := range list {
    		switch x := exp.(type) {
    		case *CompositeLit:
    			filterCompositeLit(x, filter, export)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 13.3K bytes
    - Viewed (0)
  10. src/go/types/exprstring.go

    		}
    
    	case *ast.BasicLit:
    		buf.WriteString(x.Value)
    
    	case *ast.FuncLit:
    		buf.WriteByte('(')
    		WriteExpr(buf, x.Type)
    		buf.WriteString(" literal)") // shortened
    
    	case *ast.CompositeLit:
    		WriteExpr(buf, x.Type)
    		buf.WriteByte('{')
    		if len(x.Elts) > 0 {
    			buf.WriteString("…")
    		}
    		buf.WriteByte('}')
    
    	case *ast.ParenExpr:
    		buf.WriteByte('(')
    		WriteExpr(buf, x.X)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 08 19:31:44 UTC 2024
    - 4.8K bytes
    - Viewed (0)
Back to top