Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 11 for PackageClauseOnly (0.39 sec)

  1. src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/extractdoc.go

    	if content == "" {
    		return "", fmt.Errorf("empty Go source file")
    	}
    	fset := token.NewFileSet()
    	f, err := parser.ParseFile(fset, "", content, parser.ParseComments|parser.PackageClauseOnly)
    	if err != nil {
    		return "", fmt.Errorf("not a Go source file")
    	}
    	if f.Doc == nil {
    		return "", fmt.Errorf("Go source file has no package doc comment")
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 18 21:28:13 UTC 2023
    - 3.4K bytes
    - Viewed (0)
  2. src/go/ast/issues_test.go

    // Package comment.
    package p
    
    // Does match even though it's inside general comment (/*-style).
    `, true},
    	} {
    		fset := token.NewFileSet()
    		f, err := parser.ParseFile(fset, "", test.src, parser.PackageClauseOnly|parser.ParseComments)
    		if f == nil {
    			t.Fatalf("parse %d failed to return AST: %v", i, err)
    		}
    
    		got := ast.IsGenerated(f)
    		if got != test.want {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 25 13:57:33 UTC 2023
    - 3.5K bytes
    - Viewed (0)
  3. test/stress/parsego.go

    	return isGoFile(dir) &&
    		!strings.HasSuffix(dir.Name(), "_test.go") // ignore test files
    }
    
    func pkgName(filename string) string {
    	file, err := parser.ParseFile(token.NewFileSet(), filename, nil, parser.PackageClauseOnly)
    	if err != nil || file == nil {
    		return ""
    	}
    	return file.Name.Name
    }
    
    func parseDir(dirpath string) map[string]*ast.Package {
    	// the package name is the directory name within its parent.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 02 13:43:18 UTC 2016
    - 4.1K bytes
    - Viewed (0)
  4. src/go/parser/interface.go

    	}
    	return os.ReadFile(filename)
    }
    
    // A Mode value is a set of flags (or 0).
    // They control the amount of source code parsed and other optional
    // parser functionality.
    type Mode uint
    
    const (
    	PackageClauseOnly    Mode             = 1 << iota // stop parsing after package clause
    	ImportsOnly                                       // stop parsing after import declarations
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 12:02:03 UTC 2023
    - 7.5K bytes
    - Viewed (0)
  5. src/cmd/go/internal/generate/generate.go

    	src, err := os.ReadFile(absFile)
    	if err != nil {
    		log.Fatalf("generate: %s", err)
    	}
    
    	// Parse package clause
    	filePkg, err := parser.ParseFile(token.NewFileSet(), "", src, parser.PackageClauseOnly)
    	if err != nil {
    		// Invalid package clause - ignore file.
    		return true
    	}
    
    	g := &Generator{
    		r:        bytes.NewReader(src),
    		path:     absFile,
    		pkg:      filePkg.Name.String(),
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jan 29 19:39:24 UTC 2024
    - 14.5K bytes
    - Viewed (0)
  6. src/go/printer/testdata/parser.go

    	"go/scanner"
    	"go/token"
    )
    
    // The mode parameter to the Parse* functions is a set of flags (or 0).
    // They control the amount of source code parsed and other optional
    // parser functionality.
    const (
    	PackageClauseOnly uint = 1 << iota // parsing stops after package clause
    	ImportsOnly                        // parsing stops after import declarations
    	ParseComments                      // parse comments and add them to AST
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 20 20:19:51 UTC 2023
    - 50.5K bytes
    - Viewed (0)
  7. src/go/ast/ast.go

    //
    // The syntax tree must have been parsed with the [parser.ParseComments] flag.
    // Example:
    //
    //	f, err := parser.ParseFile(fset, filename, src, parser.ParseComments|parser.PackageClauseOnly)
    //	if err != nil { ... }
    //	gen := ast.IsGenerated(f)
    func IsGenerated(file *File) bool {
    	_, ok := generator(file)
    	return ok
    }
    
    func generator(file *File) (string, bool) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 28 21:32:41 UTC 2024
    - 35.6K bytes
    - Viewed (0)
  8. src/go/parser/parser.go

    	// Don't bother parsing the rest if we had errors parsing the package clause.
    	// Likely not a Go source file at all.
    	if p.errors.Len() != 0 {
    		return nil
    	}
    
    	var decls []ast.Decl
    	if p.mode&PackageClauseOnly == 0 {
    		// import decls
    		for p.tok == token.IMPORT {
    			decls = append(decls, p.parseGenDecl(token.IMPORT, p.parseImportSpec))
    		}
    
    		if p.mode&ImportsOnly == 0 {
    			// rest of package body
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Dec 08 20:07:50 UTC 2023
    - 72.2K bytes
    - Viewed (0)
  9. src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go

    		{"ForCompiler", Func, 12},
    		{"Lookup", Type, 5},
    	},
    	"go/parser": {
    		{"AllErrors", Const, 1},
    		{"DeclarationErrors", Const, 0},
    		{"ImportsOnly", Const, 0},
    		{"Mode", Type, 0},
    		{"PackageClauseOnly", Const, 0},
    		{"ParseComments", Const, 0},
    		{"ParseDir", Func, 0},
    		{"ParseExpr", Func, 0},
    		{"ParseExprFrom", Func, 5},
    		{"ParseFile", Func, 0},
    		{"SkipObjectResolution", Const, 17},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 534.2K bytes
    - Viewed (0)
  10. api/go1.txt

    pkg go/doc, type Value struct, Doc string
    pkg go/doc, type Value struct, Names []string
    pkg go/parser, const DeclarationErrors Mode
    pkg go/parser, const ImportsOnly Mode
    pkg go/parser, const PackageClauseOnly Mode
    pkg go/parser, const ParseComments Mode
    pkg go/parser, const SpuriousErrors Mode
    pkg go/parser, const Trace Mode
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Aug 14 18:58:28 UTC 2013
    - 1.7M bytes
    - Viewed (0)
Back to top