sourcemapper

package
v0.0.0-...-937ad84 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotIno = InoLine{"/not-ino", 0}

NotIno are lines that do not belongs to an .ino file

View Source
var NotInoURI, _ = lsp.NewDocumentURIFromURL("file:///not-ino")

NotInoURI is the DocumentURI that do not belongs to an .ino file

Functions

This section is empty.

Types

type AdjustedRangeErr

type AdjustedRangeErr struct{}

AdjustedRangeErr is returned if the range overlaps with a non-ino section by just the last newline character.

func (AdjustedRangeErr) Error

func (e AdjustedRangeErr) Error() string

type InoLine

type InoLine struct {
	File string
	Line int
}

InoLine is a line number into an .ino file

type SketchMapper

type SketchMapper struct {
	CppText *SourceRevision
	// contains filtered or unexported fields
}

SketchMapper is a mapping between the .ino sketch and the preprocessed .cpp file

func CreateInoMapper

func CreateInoMapper(targetFile []byte) *SketchMapper

CreateInoMapper create a InoMapper from the given target file

func (*SketchMapper) ApplyTextChange

func (s *SketchMapper) ApplyTextChange(inoURI lsp.DocumentURI, inoChange lsp.TextDocumentContentChangeEvent) (dirty bool)

ApplyTextChange performs the text change and updates both .ino and .cpp files. It returns true if the change is "dirty", this happens when the change alters preprocessed lines and a new preprocessing may be probably required.

func (*SketchMapper) CppToInoLine

func (s *SketchMapper) CppToInoLine(targetLine int) (string, int)

CppToInoLine converts a target (.cpp) line into a source.ino:line

func (*SketchMapper) CppToInoLineOk

func (s *SketchMapper) CppToInoLineOk(targetLine int) (string, int, bool)

CppToInoLineOk converts a target (.cpp) line into a source (.ino) line and returns true if the conversion is successful

func (*SketchMapper) CppToInoRange

func (s *SketchMapper) CppToInoRange(cppRange lsp.Range) (string, lsp.Range)

CppToInoRange converts a target (.cpp) lsp.Range into a source.ino:lsp.Range. It will panic if the range spans across multiple ino files.

func (*SketchMapper) CppToInoRangeOk

func (s *SketchMapper) CppToInoRangeOk(cppRange lsp.Range) (string, lsp.Range, error)

CppToInoRangeOk converts a target (.cpp) lsp.Range into a source.ino:lsp.Range. It returns an error if the range spans across multiple ino files. If the range ends on the beginning of a new line in another .ino file, the range is adjusted and AdjustedRangeErr is reported as err: the range may be still valid.

func (*SketchMapper) DebugLogAll

func (s *SketchMapper) DebugLogAll()

DebugLogAll dumps the internal status of the mapper

func (*SketchMapper) InoToCppLSPRange

func (s *SketchMapper) InoToCppLSPRange(sourceURI lsp.DocumentURI, r lsp.Range) lsp.Range

InoToCppLSPRange convert a lsp.Range reference to a .ino into a lsp.Range to .cpp

func (*SketchMapper) InoToCppLSPRangeOk

func (s *SketchMapper) InoToCppLSPRangeOk(sourceURI lsp.DocumentURI, r lsp.Range) (lsp.Range, bool)

InoToCppLSPRangeOk convert a lsp.Range reference to a .ino into a lsp.Range to .cpp and returns true if the conversion is successful or false if the conversion is invalid.

func (*SketchMapper) InoToCppLine

func (s *SketchMapper) InoToCppLine(sourceURI lsp.DocumentURI, line int) int

InoToCppLine converts a source (.ino) line into a target (.cpp) line

func (*SketchMapper) InoToCppLineOk

func (s *SketchMapper) InoToCppLineOk(sourceURI lsp.DocumentURI, line int) (int, bool)

InoToCppLineOk converts a source (.ino) line into a target (.cpp) line

func (*SketchMapper) IsPreprocessedCppLine

func (s *SketchMapper) IsPreprocessedCppLine(cppLine int) bool

IsPreprocessedCppLine returns true if the given .cpp line is part of the section added by the arduino preprocessor.

type SourceRevision

type SourceRevision struct {
	Version int
	Text    string
}

SourceRevision is a source code tagged with a version number

Jump to

Keyboard shortcuts

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