protocol

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version represnets the current LSIF version of implementation.
	Version = "0.4.3"
	// PositionEncoding is the encoding used to compute line and character values in positions and ranges.
	PositionEncoding = "utf-16"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Contains

type Contains struct {
	Edge
	OutV string   `json:"outV"`
	InVs []string `json:"inVs"`
}

Contains is an edge object that represents 1:n "contains" relation.

func NewContains

func NewContains(id, outV string, inVs []string) *Contains

NewContains returns a new Contains object with given ID and vertices information.

type DefinitionResult

type DefinitionResult struct {
	Vertex
}

DefinitionResult connects a definition that is spread over multiple ranges or multiple documents.

func NewDefinitionResult

func NewDefinitionResult(id string) *DefinitionResult

NewDefinitionResult returns a new DefinitionResult object with given ID.

type Document

type Document struct {
	Vertex
	// The URI indicates the location of the document.
	URI string `json:"uri"`
	// The language identifier of the document.
	LanguageID string `json:"languageId"`
	// The contents of the the document.
	Contents string `json:"contents,omitempty"`
}

Document is a vertex of document in the project.

func NewDocument

func NewDocument(id, languageID, uri string, contents []byte) *Document

NewDocument returns a new Document object with given ID, URI and contents.

type Edge

type Edge struct {
	Element
	// The kind of edge in the graph.
	Label EdgeLabel `json:"label"`
}

Edge contains information of an edge in the graph.

type EdgeLabel

type EdgeLabel string

EdgeLabel represents the purpose of an edge.

const (
	EdgeContains                   EdgeLabel = "contains"
	EdgeItem                       EdgeLabel = "item"
	EdgeNext                       EdgeLabel = "next"
	EdgeMoniker                    EdgeLabel = "moniker"
	EdgeNextMoniker                EdgeLabel = "nextMoniker"
	EdgePackageInformation         EdgeLabel = "packageInformation"
	EdgeTextDocumentDocumentSymbol EdgeLabel = "textDocument/documentSymbol"
	EdgeTextDocumentFoldingRange   EdgeLabel = "textDocument/foldingRange"
	EdgeTextDocumentDocumentLink   EdgeLabel = "textDocument/documentLink"
	EdgeTextDocumentDiagnostic     EdgeLabel = "textDocument/diagnostic"
	EdgeTextDocumentDefinition     EdgeLabel = "textDocument/definition"
	EdgeTextDocumentDeclaration    EdgeLabel = "textDocument/declaration"
	EdgeTextDocumentTypeDefinition EdgeLabel = "textDocument/typeDefinition"
	EdgeTextDocumentHover          EdgeLabel = "textDocument/hover"
	EdgeTextDocumentReferences     EdgeLabel = "textDocument/references"
	EdgeTextDocumentImplementation EdgeLabel = "textDocument/implementation"
)

type Element

type Element struct {
	// The unique identifier of this element within the scope of project.
	ID string `json:"id"`
	// The kind of element in the graph.
	Type ElementType `json:"type"`
}

Element contains basic information of an element in the graph.

type ElementType

type ElementType string

ElementType represents the kind of element.

const (
	ElementVertex ElementType = "vertex"
	ElementEdge   ElementType = "edge"
)

type Event

type Event struct {
	Vertex
	// The kind of event (begin or end).
	Kind string `json:"kind"`
	// The type of element this event describes (project or document).
	Scope string `json:"scope"`
	// The identifier of the data beginning or ending.
	Data string `json:"data"`
}

Event is optional metadata emitted to give hints to consumers about the beginning and ending of new "socpes" (e.g. a project or document).

func NewEvent

func NewEvent(id, kind, scope, data string) *Event

NewEvent returns a new Event object with the given ID, kind, scope, and data information.

type HoverResult

type HoverResult struct {
	Vertex
	// The result contents as the hover information.
	Result hoverResult `json:"result"`
}

HoverResult connects a hover that is spread over multiple ranges or multiple documents.

func NewHoverResult

func NewHoverResult(id string, contents []MarkedString) *HoverResult

NewHoverResult returns a new HoverResult object with given ID, signature and extra contents.

type Item

type Item struct {
	Edge
	OutV string   `json:"outV"`
	InVs []string `json:"inVs"`
	// The document the item belongs to.
	Document string `json:"document"`
	// The relationship property of the item.
	Property string `json:"property,omitempty"`
}

Item is an edge object that represents "item" relation.

func NewItem

func NewItem(id, outV string, inVs []string, document string) *Item

NewItem returns a new Item object with given ID and vertices information.

func NewItemOfDefinitions

func NewItemOfDefinitions(id, outV string, inVs []string, document string) *Item

NewItemOfDefinitions returns a new Item object with given ID, vertices and document informationand in "definitions" relationship.

func NewItemOfReferences

func NewItemOfReferences(id, outV string, inVs []string, document string) *Item

NewItemOfReferences returns a new Item object with given ID, vertices and document informationand in "references" relationship.

func NewItemWithProperty

func NewItemWithProperty(id, outV string, inVs []string, document, property string) *Item

NewItemWithProperty returns a new Item object with given ID, vertices, document and property information.

type JSONWriter added in v0.10.0

type JSONWriter interface {
	Write(v interface{}) error
}

func NewJSONWriter added in v0.10.0

func NewJSONWriter(w io.Writer) JSONWriter

type MarkedString

type MarkedString markedString

MarkedString is the object to describe marked string.

func NewMarkedString

func NewMarkedString(s, languageID string) MarkedString

NewMarkedString returns a MarkedString with given string in language "go".

func RawMarkedString

func RawMarkedString(s string) MarkedString

RawMarkedString returns a MarkedString consisting of only a raw string (i.e., "foo" instead of {"value":"foo", "language":"bar"}).

func (MarkedString) MarshalJSON

func (m MarkedString) MarshalJSON() ([]byte, error)

func (*MarkedString) UnmarshalJSON

func (m *MarkedString) UnmarshalJSON(data []byte) error

type MetaData

type MetaData struct {
	Vertex
	// The version of the LSIF format using semver notation.
	Version string `json:"version"`
	// The project root (in form of an URI) used to compute this dump.
	ProjectRoot string `json:"projectRoot"`
	// The string encoding used to compute line and character values in
	// positions and ranges. Currently only 'utf-16' is support due to the
	// limitations in LSP.
	PositionEncoding string `json:"positionEncoding"`
	// The information about the tool that created the dump.
	ToolInfo ToolInfo `json:"toolInfo"`
}

MetaData contains basic information about the dump.

func NewMetaData

func NewMetaData(id, root string, info ToolInfo) *MetaData

NewMetaData returns a new MetaData object with given ID, project root and tool information.

type Moniker

type Moniker struct {
	Vertex
	// The kind of moniker (e.g. local, export, import).
	Kind string `json:"kind"`
	// The kind of moniker, usually a language or package manager.
	Scheme string `json:"scheme"`
	// The unique moniker identifier.
	Identifier string `json:"identifier"`
}

Moniker describes a unique name for a result set or range.

func NewMoniker

func NewMoniker(id, kind, scheme, identifier string) *Moniker

NewMoniker returns a new Moniker wtih the given ID, kind, scheme, and identifier.

type MonikerEdge

type MonikerEdge struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

MonikerEdge connects a moniker to a range or result set.

func NewMonikerEdge

func NewMonikerEdge(id, outV, inV string) *MonikerEdge

NewMonikerEdge returns a new MonikerEdge with the given ID and vertices.

type Next

type Next struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

Next is an edge object that represents "next" relation.

func NewNext

func NewNext(id, outV, inV string) *Next

NewNext returns a new Next object with given ID and vertices information.

type NextMonikerEdge

type NextMonikerEdge struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

NextMonikerEdge connects a moniker to another moniker.

func NewNextMonikerEdge

func NewNextMonikerEdge(id, outV, inV string) *NextMonikerEdge

NewNextMonikerEdge returns a new NextMonikerEdge with the given ID and vertices.

type PackageInformation

type PackageInformation struct {
	Vertex
	// The name of the package.
	Name string `json:"name"`
	// The package manager.
	Manager string `json:"manager"`
	// The version of the package.
	Version string `json:"version"`
}

PackageInformation describes a package for a moniker.

func NewPackageInformation

func NewPackageInformation(id, name, manager, version string) *PackageInformation

NewPackageInformation returns a new PackageInformation with the given ID, name, manager, and version.

type PackageInformationEdge

type PackageInformationEdge struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

PackageInformationEdge connects a moniker and a package information vertex.

func NewPackageInformationEdge

func NewPackageInformationEdge(id, outV, inV string) *PackageInformationEdge

NewPackageInformationEdge returns a new PackageInformationEdge with the given ID and vertices.

type Pos

type Pos struct {
	// The line number (0-based index)
	Line int `json:"line"`
	// The column of the character (0-based index)
	Character int `json:"character"`
}

Pos contains the precise position information.

type Project

type Project struct {
	Vertex
	// The kind of language of the dump.
	Kind string `json:"kind"`
}

Project declares the language of the dump.

func NewProject

func NewProject(id string, languageID string) *Project

NewProject returns a new Project object with given ID.

type Range

type Range struct {
	Vertex
	// The start position of the range.
	Start Pos `json:"start"`
	// The end position of the range.
	End Pos `json:"end"`
}

Range contains range information of a vertex object.

func NewRange

func NewRange(id string, start, end Pos) *Range

NewRange returns a new Range object with given ID and position information.

type ReferenceResult

type ReferenceResult struct {
	Vertex
}

ReferenceResult acts as a hub to be able to store reference information common to a set of ranges.

type ResultSet

type ResultSet struct {
	Vertex
}

ResultSet acts as a hub to be able to store information common to a set of ranges.

func NewReferenceResult

func NewReferenceResult(id string) *ResultSet

NewReferenceResult returns a new ReferenceResult object with given ID.

func NewResultSet

func NewResultSet(id string) *ResultSet

NewResultSet returns a new ResultSet object with given ID.

type TextDocumentDefinition

type TextDocumentDefinition struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

TextDocumentDefinition is an edge object that represents "textDocument/definition" relation.

func NewTextDocumentDefinition

func NewTextDocumentDefinition(id, outV, inV string) *TextDocumentDefinition

NewTextDocumentDefinition returns a new TextDocumentDefinition object with given ID and vertices information.

type TextDocumentHover

type TextDocumentHover struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

TextDocumentHover is an edge object that represents "textDocument/hover" relation.

func NewTextDocumentHover

func NewTextDocumentHover(id, outV, inV string) *TextDocumentHover

NewTextDocumentHover returns a new TextDocumentHover object with given ID and vertices information.

type TextDocumentReferences

type TextDocumentReferences struct {
	Edge
	OutV string `json:"outV"`
	InV  string `json:"inV"`
}

TextDocumentReferences is an edge object that represents "textDocument/references" relation.

func NewTextDocumentReferences

func NewTextDocumentReferences(id, outV, inV string) *TextDocumentReferences

NewTextDocumentReferences returns a new TextDocumentReferences object with given ID and vertices information.

type ToolInfo

type ToolInfo struct {
	// The name of the tool.
	Name string `json:"name"`
	// The version of the tool.
	Version string `json:"version,omitempty"`
	// The arguments passed to the tool.
	Args []string `json:"args,omitempty"`
}

ToolInfo contains information about the tool that created the dump.

type Vertex

type Vertex struct {
	Element
	// The kind of vertex in the graph.
	Label VertexLabel `json:"label"`
}

Vertex contains information of a vertex in the graph.

type VertexLabel

type VertexLabel string

VertexLabel represents the purpose of vertex.

const (
	VertexMetaData             VertexLabel = "metaData"
	VertexEvent                VertexLabel = "$event"
	VertexProject              VertexLabel = "project"
	VertexRange                VertexLabel = "range"
	VertexLocation             VertexLabel = "location"
	VertexDocument             VertexLabel = "document"
	VertexMoniker              VertexLabel = "moniker"
	VertexPackageInformation   VertexLabel = "packageInformation"
	VertexResultSet            VertexLabel = "resultSet"
	VertexDocumentSymbolResult VertexLabel = "documentSymbolResult"
	VertexFoldingRangeResult   VertexLabel = "foldingRangeResult"
	VertexDocumentLinkResult   VertexLabel = "documentLinkResult"
	VertexDianosticResult      VertexLabel = "diagnosticResult"
	VertexDeclarationResult    VertexLabel = "declarationResult"
	VertexDefinitionResult     VertexLabel = "definitionResult"
	VertexTypeDefinitionResult VertexLabel = "typeDefinitionResult"
	VertexHoverResult          VertexLabel = "hoverResult"
	VertexReferenceResult      VertexLabel = "referenceResult"
	VertexImplementationResult VertexLabel = "implementationResult"
)

type Writer

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

Writer emits vertices and edges to the underlying writer. This struct will guarantee that unique identifiers are generated for each element.

func NewWriter

func NewWriter(w JSONWriter, addContents bool) *Writer

NewWriter creates a new Writer.

func (*Writer) EmitBeginEvent

func (w *Writer) EmitBeginEvent(scope string, data string) (string, error)

func (*Writer) EmitContains

func (w *Writer) EmitContains(outV string, inVs []string) (string, error)

func (*Writer) EmitDefinitionResult

func (w *Writer) EmitDefinitionResult() (string, error)

func (*Writer) EmitDocument

func (w *Writer) EmitDocument(languageID, path string) (string, error)

func (*Writer) EmitEndEvent

func (w *Writer) EmitEndEvent(scope string, data string) (string, error)

func (*Writer) EmitHoverResult

func (w *Writer) EmitHoverResult(contents []MarkedString) (string, error)

func (*Writer) EmitItem

func (w *Writer) EmitItem(outV string, inVs []string, docID string) (string, error)

func (*Writer) EmitItemOfDefinitions

func (w *Writer) EmitItemOfDefinitions(outV string, inVs []string, docID string) (string, error)

func (*Writer) EmitItemOfReferences

func (w *Writer) EmitItemOfReferences(outV string, inVs []string, docID string) (string, error)

func (*Writer) EmitMetaData

func (w *Writer) EmitMetaData(root string, info ToolInfo) (string, error)

func (*Writer) EmitMoniker

func (w *Writer) EmitMoniker(kind, scheme, identifier string) (string, error)

func (*Writer) EmitMonikerEdge

func (w *Writer) EmitMonikerEdge(outV, inV string) (string, error)

func (*Writer) EmitNext

func (w *Writer) EmitNext(outV, inV string) (string, error)

func (*Writer) EmitPackageInformation

func (w *Writer) EmitPackageInformation(packageName, scheme, version string) (string, error)

func (*Writer) EmitPackageInformationEdge

func (w *Writer) EmitPackageInformationEdge(outV, inV string) (string, error)

func (*Writer) EmitProject

func (w *Writer) EmitProject(languageID string) (string, error)

func (*Writer) EmitRange

func (w *Writer) EmitRange(start, end Pos) (string, error)

func (*Writer) EmitReferenceResult

func (w *Writer) EmitReferenceResult() (string, error)

func (*Writer) EmitResultSet

func (w *Writer) EmitResultSet() (string, error)

func (*Writer) EmitTextDocumentDefinition

func (w *Writer) EmitTextDocumentDefinition(outV, inV string) (string, error)

func (*Writer) EmitTextDocumentHover

func (w *Writer) EmitTextDocumentHover(outV, inV string) (string, error)

func (*Writer) EmitTextDocumentReferences

func (w *Writer) EmitTextDocumentReferences(outV, inV string) (string, error)

func (*Writer) NextID

func (w *Writer) NextID() string

func (*Writer) NumElements

func (w *Writer) NumElements() int

Jump to

Keyboard shortcuts

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