Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for NewCommentMap (1.06 sec)

  1. src/go/ast/commentmap_test.go

    	return buf.String()
    }
    
    func TestCommentMap(t *testing.T) {
    	fset := token.NewFileSet()
    	f, err := parser.ParseFile(fset, "", src, parser.ParseComments)
    	if err != nil {
    		t.Fatal(err)
    	}
    	cmap := NewCommentMap(fset, f, f.Comments)
    
    	// very correct association of comments
    	for n, list := range cmap {
    		key := fmt.Sprintf("%2d: %T", fset.Position(n.Pos()).Line, n)
    		got := ctext(list)
    		want := res[key]
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Sep 09 15:35:30 UTC 2022
    - 3.9K bytes
    - Viewed (0)
  2. src/go/ast/commentmap.go

    //     via the previous rules
    //
    // NewCommentMap tries to associate a comment group to the "largest"
    // node possible: For instance, if the comment is a line comment
    // trailing an assignment, the comment is associated with the entire
    // assignment rather than just the last operand in the assignment.
    func NewCommentMap(fset *token.FileSet, node Node, comments []*CommentGroup) CommentMap {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 8.9K bytes
    - Viewed (0)
  3. src/go/ast/example_test.go

    	if err != nil {
    		panic(err)
    	}
    
    	// Create an ast.CommentMap from the ast.File's comments.
    	// This helps keeping the association between comments
    	// and AST nodes.
    	cmap := ast.NewCommentMap(fset, f, f.Comments)
    
    	// Remove the first variable declaration from the list of declarations.
    	for i, decl := range f.Decls {
    		if gen, ok := decl.(*ast.GenDecl); ok && gen.Tok == token.VAR {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 15 21:44:50 UTC 2024
    - 6.1K bytes
    - Viewed (0)
  4. src/cmd/internal/dwarf/putvarabbrevgen_test.go

    	}
    
    }
    
    func pvagenerate(t *testing.T) string {
    	var fset token.FileSet
    	f, err := parser.ParseFile(&fset, "./dwarf.go", nil, parser.ParseComments)
    	if err != nil {
    		t.Fatal(err)
    	}
    	cm := ast.NewCommentMap(&fset, f, f.Comments)
    	abbrevs := make(map[string]int)
    	funcs := map[string]ast.Stmt{}
    	for _, decl := range f.Decls {
    		decl, ok := decl.(*ast.FuncDecl)
    		if !ok || decl.Body == nil {
    			continue
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Feb 26 20:45:07 UTC 2024
    - 8.9K bytes
    - Viewed (0)
  5. src/cmd/gofmt/rewrite.go

    	fmt.Println()
    }
    */
    
    // rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file.
    func rewriteFile(fileSet *token.FileSet, pattern, replace ast.Expr, p *ast.File) *ast.File {
    	cmap := ast.NewCommentMap(fileSet, p, p.Comments)
    	m := make(map[string]reflect.Value)
    	pat := reflect.ValueOf(pattern)
    	repl := reflect.ValueOf(replace)
    
    	var rewriteVal func(val reflect.Value) reflect.Value
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 27 22:07:13 UTC 2023
    - 8.1K bytes
    - Viewed (0)
Back to top