Made node traits file for semantic table nodes
This commit is contained in:
parent
67c94fb0e8
commit
cd670d05c5
47
analyzer/node-traits.go
Normal file
47
analyzer/node-traits.go
Normal file
@ -0,0 +1,47 @@
|
||||
package analyzer
|
||||
|
||||
import "path/filepath"
|
||||
import "git.tebibyte.media/arf/arf/types"
|
||||
|
||||
// sectionBase is a struct that all sections must embed.
|
||||
type sectionBase struct {
|
||||
where locator
|
||||
complete bool
|
||||
permission types.Permission
|
||||
}
|
||||
|
||||
// Name returns the name of the section.
|
||||
func (section sectionBase) Name () (name string) {
|
||||
name = section.where.name
|
||||
return
|
||||
}
|
||||
|
||||
// ModulePath returns the full path of the module the section came from.
|
||||
func (section sectionBase) ModulePath () (path string) {
|
||||
path = section.where.modulePath
|
||||
return
|
||||
}
|
||||
|
||||
// ModuleName returns the name of the module where the section came from.
|
||||
func (section sectionBase) ModuleName () (name string) {
|
||||
name = filepath.Base(section.where.modulePath)
|
||||
return
|
||||
}
|
||||
|
||||
// Complete returns wether the section has been completed.
|
||||
func (section sectionBase) Complete () (complete bool) {
|
||||
complete = section.complete
|
||||
return
|
||||
}
|
||||
|
||||
// Permission returns the permission of the section.
|
||||
func (section sectionBase) Permission () (permission types.Permission) {
|
||||
permission = section.permission
|
||||
return
|
||||
}
|
||||
|
||||
// locator returns the module path and name of the section.
|
||||
func (section sectionBase) locator () (where locator) {
|
||||
where = section.where
|
||||
return
|
||||
}
|
@ -84,46 +84,3 @@ type Section interface {
|
||||
// Must be implemented by each individual section
|
||||
ToString (indent int) (output string)
|
||||
}
|
||||
|
||||
// sectionBase is a struct that all sections must embed.
|
||||
type sectionBase struct {
|
||||
where locator
|
||||
complete bool
|
||||
permission types.Permission
|
||||
}
|
||||
|
||||
// Name returns the name of the section.
|
||||
func (section sectionBase) Name () (name string) {
|
||||
name = section.where.name
|
||||
return
|
||||
}
|
||||
|
||||
// ModulePath returns the full path of the module the section came from.
|
||||
func (section sectionBase) ModulePath () (path string) {
|
||||
path = section.where.modulePath
|
||||
return
|
||||
}
|
||||
|
||||
// ModuleName returns the name of the module where the section came from.
|
||||
func (section sectionBase) ModuleName () (name string) {
|
||||
name = filepath.Base(section.where.modulePath)
|
||||
return
|
||||
}
|
||||
|
||||
// Complete returns wether the section has been completed.
|
||||
func (section sectionBase) Complete () (complete bool) {
|
||||
complete = section.complete
|
||||
return
|
||||
}
|
||||
|
||||
// Permission returns the permission of the section.
|
||||
func (section sectionBase) Permission () (permission types.Permission) {
|
||||
permission = section.permission
|
||||
return
|
||||
}
|
||||
|
||||
// locator returns the module path and name of the section.
|
||||
func (section sectionBase) locator () (where locator) {
|
||||
where = section.where
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package analyzer
|
||||
|
||||
import "fmt"
|
||||
import "path/filepath"
|
||||
import "git.tebibyte.media/arf/arf/parser"
|
||||
import "git.tebibyte.media/arf/arf/infoerr"
|
||||
|
||||
@ -249,10 +248,7 @@ func (what Type) Describe () (description string) {
|
||||
panic("invalid state: Type.actual is nil")
|
||||
|
||||
default:
|
||||
locator := actual.locator()
|
||||
description +=
|
||||
filepath.Base(locator.modulePath) +
|
||||
"." + locator.name
|
||||
description += actual.ModuleName() + "." + actual.Name()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user