github.com/nuvolaris/goja@v0.0.0-20230825100449-967811910c6d/file/README.markdown (about)

     1  # file
     2  --
     3      import "github.com/dop251/goja/file"
     4  
     5  Package file encapsulates the file abstractions used by the ast & parser.
     6  
     7  ## Usage
     8  
     9  #### type File
    10  
    11  ```go
    12  type File struct {
    13  }
    14  ```
    15  
    16  
    17  #### func  NewFile
    18  
    19  ```go
    20  func NewFile(filename, src string, base int) *File
    21  ```
    22  
    23  #### func (*File) Base
    24  
    25  ```go
    26  func (fl *File) Base() int
    27  ```
    28  
    29  #### func (*File) Name
    30  
    31  ```go
    32  func (fl *File) Name() string
    33  ```
    34  
    35  #### func (*File) Source
    36  
    37  ```go
    38  func (fl *File) Source() string
    39  ```
    40  
    41  #### type FileSet
    42  
    43  ```go
    44  type FileSet struct {
    45  }
    46  ```
    47  
    48  A FileSet represents a set of source files.
    49  
    50  #### func (*FileSet) AddFile
    51  
    52  ```go
    53  func (self *FileSet) AddFile(filename, src string) int
    54  ```
    55  AddFile adds a new file with the given filename and src.
    56  
    57  This an internal method, but exported for cross-package use.
    58  
    59  #### func (*FileSet) File
    60  
    61  ```go
    62  func (self *FileSet) File(idx Idx) *File
    63  ```
    64  
    65  #### func (*FileSet) Position
    66  
    67  ```go
    68  func (self *FileSet) Position(idx Idx) *Position
    69  ```
    70  Position converts an Idx in the FileSet into a Position.
    71  
    72  #### type Idx
    73  
    74  ```go
    75  type Idx int
    76  ```
    77  
    78  Idx is a compact encoding of a source position within a file set. It can be
    79  converted into a Position for a more convenient, but much larger,
    80  representation.
    81  
    82  #### type Position
    83  
    84  ```go
    85  type 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  
    94  Position describes an arbitrary source position including the filename, line,
    95  and column location.
    96  
    97  #### func (*Position) String
    98  
    99  ```go
   100  func (self *Position) String() string
   101  ```
   102  String 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