github.com/nevalang/neva@v0.23.1-0.20240507185603-7696a9bb8dda/internal/compiler/sourcecode/core/core.go (about) 1 // package core contains abstractions that are used by 2 // both source-code and type-system. 3 4 package core 5 6 import "fmt" 7 8 // EntityRef is a reference to an entity in the source code 9 type EntityRef struct { 10 Pkg string `json:"pkg,omitempty"` 11 Name string `json:"name,omitempty"` 12 Meta Meta `json:"meta,omitempty"` 13 } 14 15 func (e EntityRef) String() string { 16 if e.Pkg == "" { 17 return e.Name 18 } 19 return fmt.Sprintf("%s.%s", e.Pkg, e.Name) 20 } 21 22 // Meta contains meta information about the source code 23 type Meta struct { 24 Text string `json:"text,omitempty"` 25 Start Position `json:"start,omitempty"` 26 Stop Position `json:"stop,omitempty"` 27 } 28 29 // Position contains line and column numbers 30 type Position struct { 31 Line int `json:"line,omitempty"` 32 Column int `json:"column,omitempty"` 33 } 34 35 func (p Position) String() string { 36 return fmt.Sprintf("%v:%v", p.Line, p.Column) 37 }