types

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EOL = byte('\n')

Variables

This section is empty.

Functions

func Examiners

func Examiners() map[string]DialectExaminer

Examiners returns a map of DialectExaminer

func Processors

func Processors() map[string]DialectFrameworkProcessor

Processors returns a map of DialectFrameworkProcessor

func RegisterDialectImplementation added in v0.0.4

func RegisterDialectImplementation(impl Dialect)

RegisterDialectImplementation is used by an implementation to register itself

func RegisterExaminer

func RegisterExaminer(language string, examiner DialectExaminer)

RegisterExaminer is used to register an implementation of the DialectExaminer interface

func RegisterFrameworkProcessor

func RegisterFrameworkProcessor(name string, processor DialectFrameworkProcessor)

RegisterFrameworkProcessor is used to register an implementation of the DialectFrameworkProcessor interface

Types

type Dialect added in v0.0.4

type Dialect interface {
	CreateLineByLineExaminer(language string, filename string, config *DialectConfiguration) (*DialectContext, error)
	Examine(language string, filename string, reader io.Reader, config *DialectConfiguration) (*DialectResult, error)
	DetectFrameworks(directory string) ([]*DialectFramework, error)
}

interface that the implementation will implement

type DialectConfiguration

type DialectConfiguration struct {
	Callback         DialectResultCallback
	DetectCopyrights bool
}

DialectConfiguration is a struct which is used for specifying configuration

func CreateConfigurationWithCallback added in v0.0.4

func CreateConfigurationWithCallback(callback DialectResultCallback) *DialectConfiguration

CreateConfigurationWithCallback returns a default configuration with a callback

func CreateDefaultConfiguration added in v0.0.4

func CreateDefaultConfiguration() *DialectConfiguration

CreateDefaultConfiguration will return a default configuration

type DialectContext

type DialectContext struct {
	Language   string
	Filename   string
	Config     *DialectConfiguration
	Examiner   DialectExaminer
	LineNumber int
	Result     *DialectResult
	Buffer     bytes.Buffer
}

func CreateLineByLineExaminer added in v0.0.4

func CreateLineByLineExaminer(language string, filename string, config *DialectConfiguration) (*DialectContext, error)

func (*DialectContext) ProcessLine

func (ctx *DialectContext) ProcessLine(buf []byte, eof bool) (*DialectLine, error)

type DialectExaminer

type DialectExaminer interface {
	NewExaminer() DialectExaminer
	Examine(language string, filename string, line *DialectLine) error
}

DialectExaminer is the interface that language processors must implement to handle details about a specific language

func ExaminerForLanguage

func ExaminerForLanguage(language string) (DialectExaminer, error)

ExaminerForLanguage returns the implementation of DialectExaminer for language

type DialectFramework

type DialectFramework struct {
	Name string               `json:"name"`
	Type DialectFrameworkType `json:"type"`
}

DialectFramework is details about a framework that the project supports

func DetectFrameworks added in v0.0.4

func DetectFrameworks(directory string) ([]*DialectFramework, error)

type DialectFrameworkProcessor

type DialectFrameworkProcessor interface {
	Detect(directory string) ([]*DialectFramework, error)
}

DialectFramework is the interface that framework processors must implement to handle details about a specific framework

type DialectFrameworkType

type DialectFrameworkType string
const (
	DialectFrameworkBuild     DialectFrameworkType = "build"
	DialectFrameworkLanguage  DialectFrameworkType = "language"
	DialectFrameworkContainer DialectFrameworkType = "container"
)

type DialectLine

type DialectLine struct {
	LineNumber int
	IsComment  bool
	IsCode     bool
	IsBlank    bool
	IsTest     bool
	Contents   string
	EOF        bool
	Buffer     string
	Config     *DialectConfiguration
}

DialectLine is internally used by the dialect framework to communicate results per line by a DialectExaminer implementation

type DialectResult

type DialectResult struct {
	Blanks     int
	Comments   int
	Loc        int
	Sloc       int
	IsTest     bool
	Copyrights []*copyright.CopyrightResult
}

DialectResult is returned from Examine to describe the code

func Examine added in v0.0.4

func Examine(language string, filename string, reader io.Reader, config *DialectConfiguration) (*DialectResult, error)

func (*DialectResult) String

func (r *DialectResult) String() string

type DialectResultCallback

type DialectResultCallback func(language string, line *DialectLine) error

DialectResultCallback is a callback function for receiving per line results as the code is being examined

Jump to

Keyboard shortcuts

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