Lines Matching refs:file

4 // you may not use this file except in compliance with the License.
31 // TokenConverter is a Converter backed by a token file set and file.
32 // It uses the file set methods to work out the conversions, which
33 // makes it fast and does not require the file contents.
36 file *token.File
52 return &TokenConverter{fset: fset, file: f}
56 // given file content.
61 return &TokenConverter{fset: fset, file: f}
75 return Span{}, fmt.Errorf("file not found in FileSet")
112 // go/token will panic if the offset is larger than the file's size,
114 if s.Start().Offset() > converter.file.Size() {
115 return Range{}, fmt.Errorf("start offset %v is past the end of the file %v", s.Start(), converter.file.Size())
117 if s.End().Offset() > converter.file.Size() {
118 return Range{}, fmt.Errorf("end offset %v is past the end of the file %v", s.End(), converter.file.Size())
122 Start: converter.file.Pos(s.Start().Offset()),
123 End: converter.file.Pos(s.End().Offset()),
128 if offset > l.file.Size() {
129 return 0, 0, fmt.Errorf("offset %v is past the end of the file %v", offset, l.file.Size())
131 pos := l.file.Pos(offset)
133 if offset == l.file.Size() {
143 lineMax := l.file.LineCount() + 1
145 return -1, fmt.Errorf("line is beyond end of file %v", lineMax)
148 return -1, fmt.Errorf("column is beyond end of file")
150 // at the end of the file, allowing for a trailing eol
151 return l.file.Size(), nil
153 pos := lineStart(l.file, line)
155 return -1, fmt.Errorf("line is not in file")
160 return offset(l.file, pos)