Implemented ModuleName and added to Section interface
This commit is contained in:
parent
3a5086ad33
commit
55a1490c18
@ -1,5 +1,7 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
|
import "path/filepath"
|
||||||
|
|
||||||
// locator uniquely identifies a section in the section table.
|
// locator uniquely identifies a section in the section table.
|
||||||
type locator struct {
|
type locator struct {
|
||||||
modulePath string
|
modulePath string
|
||||||
@ -38,10 +40,15 @@ const (
|
|||||||
|
|
||||||
// Section is a semantically analyzed section.
|
// Section is a semantically analyzed section.
|
||||||
type Section interface {
|
type Section interface {
|
||||||
|
// Provided by sectionBase
|
||||||
|
Name () (name string)
|
||||||
|
Complete () (complete bool)
|
||||||
|
ModulePath () (path string)
|
||||||
|
ModuleName () (path string)
|
||||||
|
|
||||||
|
// Must be implemented by each individual section
|
||||||
Kind () (kind SectionKind)
|
Kind () (kind SectionKind)
|
||||||
Name () (name string)
|
|
||||||
ToString (indent int) (output string)
|
ToString (indent int) (output string)
|
||||||
Complete () (complete bool)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sectionBase is a struct that all sections must embed.
|
// sectionBase is a struct that all sections must embed.
|
||||||
@ -57,12 +64,16 @@ func (section sectionBase) Name () (name string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ModulePath returns the full path of the module the section came from.
|
// ModulePath returns the full path of the module the section came from.
|
||||||
func (section sectionBase) ModulePath () (name string) {
|
func (section sectionBase) ModulePath () (path string) {
|
||||||
name = section.where.modulePath
|
path = section.where.modulePath
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ModuleName returns the name of the module where the section came from.
|
// 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.
|
// Complete returns wether the section has been completed.
|
||||||
func (section sectionBase) Complete () (complete bool) {
|
func (section sectionBase) Complete () (complete bool) {
|
||||||
|
Reference in New Issue
Block a user