dart

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dart implements methods for manipulating Dart code.

Package dart implements methods for manipulating Dart code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BraceLevel

type BraceLevel int

BraceLevel represents the current brace level the cursor is within.

const (
	BraceUnknown BraceLevel = iota

	BraceNormal       // Most recent unmatched '{' was not string literal related.
	BraceSingle       // Most recent unmatched '{' was `'...${`.
	BraceDouble       // Most recent unmatched '{' was `"...${`.
	BraceTripleSingle // Most recent unmatched '{' was `”'...${`.
	BraceTripleDouble // Most recent unmatched '{' was `"""...${`.
)

type Class

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

Class represents a Dart class.

func NewClass

func NewClass(editor *Editor, classType, className string,
	openCurlyOffset, closeCurlyOffset int,
	groupAndSortGetterMethods, separatePrivateMethods bool) *Class

NewClass returns a new Dart Class.

editor is the editor used to parse the class. className is the name of the class. openCurlyOffset is the position of the "{" for that class. closeCurlyOffset is the position of the "}" for that class. groupAndSortGetterMethods determines how getter methods are processed.

func (*Class) FindFeatures

func (c *Class) FindFeatures() error

type Client

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

Client represents a Dart processor.

func New

func New(e *Editor, opts Options) *Client

New returns a new Dart processor.

func (*Client) StylizeFile

func (c *Client) StylizeFile(filename string) (bool, error)

StylizeFile sylizes a single Dart file using the provided options. If any differences were found, true is returned.

type Cursor

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

Cursor represents an editor cursor and is used to advance through the Dart source code.

func (*Cursor) CloseMatchingPair added in v0.1.3

func (c *Cursor) CloseMatchingPair(close string, matchingPairStack []*MatchingPair) []*MatchingPair

CloseMatchingPair closes the last open matching pair on the stack.

func (*Cursor) NewMatchingPair added in v0.1.3

func (c *Cursor) NewMatchingPair(open string, matchingPairs MatchingPairsMap, matchingPairStack []*MatchingPair) []*MatchingPair

NewMatchingPair adds the start of a new matching pair onto the stack.

func (*Cursor) String

func (c *Cursor) String() string

type Edit

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

Edit represents an edit of an editor buffer.

type Editor

type Editor struct {
	Verbose bool
	// contains filtered or unexported fields
}

Editor represents a text editor that understands Dart syntax.

func NewEditor

func NewEditor(buf string, processEnumsLikeClasses, verbose bool) (*Editor, error)

NewEditor returns a new Editor.

func (*Editor) GetClasses added in v0.1.3

func (e *Editor) GetClasses(groupAndSortGetterMethods, separatePrivateMethods bool) ([]*Class, error)

type Entity

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

Entity represents a single, independent feature of a Dart.Class.

type EntityType

type EntityType int

EntityType represents a type of Dart Line.

const (
	Unknown EntityType = iota
	BlankLine
	SingleLineComment
	MultiLineComment
	MainConstructor
	NamedConstructor
	StaticVariable
	InstanceVariable
	OverrideVariable
	StaticPrivateVariable
	PrivateInstanceVariable
	OverrideMethod
	OtherMethod
	BuildMethod
	GetterMethod
	LeaveUnmodified // for everything else, like enum values.
)

func (EntityType) String

func (e EntityType) String() string

type Line

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

Line represents a line of Dart code.

func NewLine

func NewLine(line string, startOffset, originalIndex int) *Line

NewLine returns a new Line.

type MatchingPair added in v0.1.3

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

MatchingPair represents a matching pair of features in the Dart source code, such as r”'=>”', (=>), {=>}, etc.

type MatchingPairsMap added in v0.1.3

type MatchingPairsMap map[int]*MatchingPair

MatchingPairsMap represents a map of matching pairs keyed by the openAbsOffset value.

type Options

type Options struct {
	Debug   bool
	Diff    bool
	List    bool
	Quiet   bool
	Verbose bool
	Write   bool

	GroupAndSortGetterMethods bool
	GroupAndSortVariableTypes bool

	MemberOrdering          []string
	ProcessEnumsLikeClasses bool
	SortClassesWithinFile   bool
	SortOtherMethods        bool
	SeparatePrivateMethods  bool
}

Options represents the configuration options for the Dart processor.

Jump to

Keyboard shortcuts

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