file

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package file 供 AST 使用的文件操作抽象

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSourcemapURL

func ResolveSourcemapURL(basename, source string) *url.URL

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File 代表了一个具体的源文件

func NewFile

func NewFile(filename, src string, base int) *File

NewFile 新建一个文件

func (*File) Base

func (f *File) Base() int

func (*File) Name

func (f *File) Name() string

func (*File) Position

func (f *File) Position(offset int) Position

Position 根据文件指针的偏移量,计算出该指针所在的具体位置

func (*File) SetSourceMap

func (f *File) SetSourceMap(m *sourcemap.Consumer)

func (*File) Source

func (f *File) Source() string

type FileSet

type FileSet struct {
	// contains filtered or unexported fields
}

FileSet 代表了一组源文件

func (*FileSet) AddFile

func (fs *FileSet) AddFile(filename, src string) int

AddFile 将指定文件名和源文件路径的一个文件,添加到文件集合中

func (*FileSet) File

func (fs *FileSet) File(idx Idx) *File

File 根据下标获取具体的文件

func (*FileSet) Position

func (fs *FileSet) Position(idx Idx) Position

Position 将在文件集合中的 Idx 转换为 Position

type Idx

type Idx int

Idx 是在一个在文件集合内的。指出源码位置的一个紧凑型编码 它可以被转换为 Position,以获得一个更为全面的数据表达

type Position

type Position struct {
	Filename string // 产生了错误的文件名(有错误发生的情况才填充)
	Line     int    // 行号,以1为起始
	Column   int    // 列号,以1为起始
}

Position 用于描述一个任意的源码位置,包括文件名,行和列

func (*Position) String

func (p *Position) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL