• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..04-Aug-2021-

README.markdownH A D04-Aug-20212 KiB11176

file.goH A D04-Aug-20214.3 KiB216165

file_test.goH A D04-Aug-2021674 4640

README.markdown

1# file
2--
3    import "github.com/dop251/goja/file"
4
5Package file encapsulates the file abstractions used by the ast & parser.
6
7## Usage
8
9#### type File
10
11```go
12type File struct {
13}
14```
15
16
17#### func  NewFile
18
19```go
20func NewFile(filename, src string, base int) *File
21```
22
23#### func (*File) Base
24
25```go
26func (fl *File) Base() int
27```
28
29#### func (*File) Name
30
31```go
32func (fl *File) Name() string
33```
34
35#### func (*File) Source
36
37```go
38func (fl *File) Source() string
39```
40
41#### type FileSet
42
43```go
44type FileSet struct {
45}
46```
47
48A FileSet represents a set of source files.
49
50#### func (*FileSet) AddFile
51
52```go
53func (self *FileSet) AddFile(filename, src string) int
54```
55AddFile adds a new file with the given filename and src.
56
57This an internal method, but exported for cross-package use.
58
59#### func (*FileSet) File
60
61```go
62func (self *FileSet) File(idx Idx) *File
63```
64
65#### func (*FileSet) Position
66
67```go
68func (self *FileSet) Position(idx Idx) *Position
69```
70Position converts an Idx in the FileSet into a Position.
71
72#### type Idx
73
74```go
75type Idx int
76```
77
78Idx is a compact encoding of a source position within a file set. It can be
79converted into a Position for a more convenient, but much larger,
80representation.
81
82#### type Position
83
84```go
85type Position struct {
86	Filename string // The filename where the error occurred, if any
87	Offset   int    // The src offset
88	Line     int    // The line number, starting at 1
89	Column   int    // The column number, starting at 1 (The character count)
90
91}
92```
93
94Position describes an arbitrary source position including the filename, line,
95and column location.
96
97#### func (*Position) String
98
99```go
100func (self *Position) String() string
101```
102String returns a string in one of several forms:
103
104    file:line:column    A valid position with filename
105    line:column         A valid position without filename
106    file                An invalid position with filename
107    -                   An invalid position without filename
108
109--
110**godocdown** http://github.com/robertkrimen/godocdown
111