Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 11 for commentMap (0.52 sec)

  1. src/go/ast/commentmap.go

    	slices.SortFunc(list, func(a, b *CommentGroup) int {
    		return cmp.Compare(a.Pos(), b.Pos())
    	})
    }
    
    // A CommentMap maps an AST node to a list of comment groups
    // associated with it. See [NewCommentMap] for a description of
    // the association.
    type CommentMap map[Node][]*CommentGroup
    
    func (cmap CommentMap) addComment(n Node, c *CommentGroup) {
    	list := cmap[n]
    	if len(list) == 0 {
    		list = []*CommentGroup{c}
    	} else {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 8.9K bytes
    - Viewed (0)
  2. src/cmd/compile/internal/syntax/testing_test.go

    /* ERROR "5:24" */                 // position of ; on previous line
    	package /* ERROR "7:2" */  // indented with tab
            import  /* ERROR "8:9" */  // indented with blanks
    `
    	m := CommentMap(strings.NewReader(src), regexp.MustCompile("^ ERROR "))
    	found := 0 // number of errors found
    	for line, errlist := range m {
    		for _, err := range errlist {
    			if err.Pos.Line() != line {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 17 19:53:18 UTC 2023
    - 1.4K bytes
    - Viewed (0)
  3. src/go/types/commentMap_test.go

    	"go/scanner"
    	"go/token"
    	"regexp"
    	"strings"
    	"testing"
    )
    
    type comment struct {
    	line, col int    // comment position
    	text      string // comment text, excluding "//", "/*", or "*/"
    }
    
    // commentMap collects all comments in the given src with comment text
    // that matches the supplied regular expression rx and returns them as
    // []comment lists in a map indexed by line number. The comment text is
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 17 19:54:27 UTC 2023
    - 3K bytes
    - Viewed (0)
  4. src/cmd/compile/internal/syntax/testing.go

    func CommentsDo(src io.Reader, handler func(line, col uint, text string)) {
    	var s scanner
    	s.init(src, handler, comments)
    	for s.tok != _EOF {
    		s.next()
    	}
    }
    
    // CommentMap collects all comments in the given src with comment text
    // that matches the supplied regular expression rx and returns them as
    // []Error lists in a map indexed by line number. The comment text is
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 17 19:53:18 UTC 2023
    - 2.1K bytes
    - Viewed (0)
  5. src/go/ast/example_test.go

    	// x
    	// y
    	// int
    	// print
    	// x
    	// y
    }
    
    // This example illustrates how to remove a variable declaration
    // in a Go program while maintaining correct comment association
    // using an ast.CommentMap.
    func ExampleCommentMap() {
    	// src is the input for which we create the AST that we
    	// are going to manipulate.
    	src := `
    // This is the package comment.
    package main
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 15 21:44:50 UTC 2024
    - 6.1K bytes
    - Viewed (0)
  6. src/cmd/internal/dwarf/putvarabbrevgen_test.go

    }
    
    // pvacfgbody generates a simplified CFG for a slice of statements,
    // containing only calls to putattr and the if statements affecting them.
    func pvacfgbody(t *testing.T, fset *token.FileSet, cm ast.CommentMap, body []ast.Stmt) (start, end *pvacfgnode) {
    	add := func(n *pvacfgnode) {
    		if start == nil || end == nil {
    			start = n
    			end = n
    		} else {
    			end.then = n
    			end = n
    		}
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Feb 26 20:45:07 UTC 2024
    - 8.9K bytes
    - Viewed (0)
  7. src/go/types/check_test.go

    	conf.Check(pkgName, fset, files, &info)
    	if listErrors {
    		return
    	}
    
    	// collect expected errors
    	errmap := make(map[string]map[int][]comment)
    	for i, filename := range filenames {
    		if m := commentMap(srcs[i], regexp.MustCompile("^ ERRORx? ")); len(m) > 0 {
    			errmap[filename] = m
    		}
    	}
    
    	// match against found errors
    	var indices []int // list indices of matching errors, reused for each error
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 22 19:45:33 UTC 2024
    - 14.1K bytes
    - Viewed (0)
  8. src/cmd/compile/internal/types2/check_test.go

    	conf.Check(pkgName, files, &info)
    	if listErrors {
    		return
    	}
    
    	// collect expected errors
    	errmap := make(map[string]map[uint][]syntax.Error)
    	for i, filename := range filenames {
    		if m := syntax.CommentMap(bytes.NewReader(srcs[i]), regexp.MustCompile("^ ERRORx? ")); len(m) > 0 {
    			errmap[filename] = m
    		}
    	}
    
    	// match against found errors
    	var indices []int // list indices of matching errors, reused for each error
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 22 19:45:33 UTC 2024
    - 13.8K bytes
    - Viewed (0)
  9. src/go/ast/ast.go

    // removed or moved, relevant comments in their vicinity must also be removed
    // (from the [File.Comments] list) or moved accordingly (by updating their
    // positions). A [CommentMap] may be used to facilitate some of these operations.
    //
    // Whether and how a comment is associated with a node depends on the
    // interpretation of the syntax tree by the manipulating program: except for Doc
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 28 21:32:41 UTC 2024
    - 35.6K bytes
    - Viewed (0)
  10. src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go

    		{"(*UnaryExpr).End", Method, 0},
    		{"(*UnaryExpr).Pos", Method, 0},
    		{"(*ValueSpec).End", Method, 0},
    		{"(*ValueSpec).Pos", Method, 0},
    		{"(CommentMap).Comments", Method, 1},
    		{"(CommentMap).Filter", Method, 1},
    		{"(CommentMap).String", Method, 1},
    		{"(CommentMap).Update", Method, 1},
    		{"(ObjKind).String", Method, 0},
    		{"ArrayType", Type, 0},
    		{"ArrayType.Elt", Field, 0},
    		{"ArrayType.Lbrack", Field, 0},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 534.2K bytes
    - Viewed (0)
Back to top