graph

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: BSD-3-Clause, MIT, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package graph is a generated protocol buffer package.

It is generated from these files:

def.proto
doc.proto
output.proto
ref.proto

It has these top-level messages:

DefKey
Def
DefDoc

Index

Constants

View Source
const (
	// An Unqualified name is just the def's name.
	//
	// Examples:
	//
	//   Go method         `MyMethod`
	//   Python method     `my_method`
	//   JavaScript method `myMethod`
	Unqualified Qualification = ""

	// A ScopeQualified name is the language-specific description of the
	// def's defining scope plus the def's unqualified name. It should
	// uniquely describe the def among all other defs defined in the same
	// logical package (but this is not strictly defined or enforced).
	//
	// Examples:
	//
	//   Go method         `(*MyType).MyMethod`
	//   Python method     `MyClass.my_method`
	//   JavaScript method `MyConstructor.prototype.myMethod`
	ScopeQualified = "scope"

	// A DepQualified name is the package/module name (as seen by an external
	// library that imports/depends on the def's package/module) plus the
	// def's scope-qualified name. If there are nested packages, it should
	// describe enough of the package hierarchy to distinguish it from other
	// similarly named defs (but this is not strictly defined or enforced).
	//
	// Examples:
	//
	//   Go method       `(*mypkg.MyType).MyMethod`
	//   Python method   `mypkg.MyClass.my_method`
	//   CommonJS method `mymodule.MyConstructor.prototype.myMethod`
	DepQualified = "dep"

	// A RepositoryWideQualified name is the full package/module name(s) plus
	// the def's scope-qualified name. It should describe enough of the
	// package hierarchy so that it is unique in its repository.
	// RepositoryWideQualified differs from DepQualified in that the former
	// includes the full nested package/module path from the repository root
	// (e.g., 'a/b.C' for a Go func C in the repository 'github.com/user/a'
	// subdirectory 'b'), while DepQualified would only be the last directory
	// component (e.g., 'b.C' in that example).
	//
	// Examples:
	//
	//   Go method       `(*mypkg/subpkg.MyType).MyMethod`
	//   Python method   `mypkg.subpkg.MyClass.my_method` (unless mypkg =~ subpkg)
	//   CommonJS method `mypkg.mymodule.MyConstructor.prototype.myMethod` (unless mypkg =~ mymodule)
	RepositoryWideQualified = "repo-wide"

	// A LanguageWideQualified name is the library/repository name plus the
	// package-qualified def name. It should describe the def so that it
	// is logically unique among all defs that could reasonably exist for the
	// language that the def is written in (but this is not strictly defined
	// or enforced).
	//
	// Examples:
	//
	//   Go method       `(*github.com/user/repo/mypkg.MyType).MyMethod`
	//   Python method   `mylib.MyClass.my_method` (if mylib =~ mypkg, as for Django, etc.)
	//   CommonJS method `mylib.MyConstructor.prototype.myMethod` (if mylib =~ mymod, as for caolan/async, etc.)
	LanguageWideQualified = "lang-wide"
)
View Source
const (
	// StatXRefs is the number of external references to a def (i.e.,
	// references from other repositories). It is only computed for abstract
	// defs (see the docs for DefKey) because it is not easy to determine
	// which specific commit a ref references (for external refs).
	StatXRefs = "xrefs"

	// StatRRefs is the number of references to a def from the same
	// repository in which the def is defined. It is inclusive of the
	// StatURefs count. It is only computed for concrete defs (see the docs
	// for DefKey) because otherwise it would count 1 rref for each unique
	// revision of the repository that we have processed. (It is easy to
	// determine which specific commit an internal ref references; we just
	// assume it references a def in the same commit.)
	StatRRefs = "rrefs"

	// StatURefs is the number of references to a def from the same source
	// unit in which the def is defined. It is included in the StatRRefs
	// count. It is only computed for concrete defs (see the docs for
	// DefKey) because otherwise it would count 1 uref for each revision of
	// the repository that we have processed.
	StatURefs = "urefs"

	// StatAuthors is the number of distinct resolved people who contributed
	// code to a def's definition (according to a VCS "blame" of the
	// version). It is only computed for concrete defs (see the docs for
	// DefKey).
	StatAuthors = "authors"

	// StatClients is the number of distinct resolved people who have committed
	// refs that reference a def. It is only computed for abstract defs
	// (see the docs for DefKey) because it is not easy to determine which
	// specific commit a ref references.
	StatClients = "clients"

	// StatDependents is the number of distinct repositories that contain refs
	// that reference a def. It is only computed for abstract defs (see
	// the docs for DefKey) because it is not easy to determine which
	// specific commit a ref references.
	StatDependents = "dependents"

	// StatExportedElements is the number of exported defs whose path is a
	// descendant of this def's path (and that is in the same repository and
	// source unit). It is only computed for concrete defs (see the docs for
	// DefKey) because otherwise it would count 1 exported element for each
	// revision of the repository that we have processed.
	StatExportedElements = "exported_elements"
)

Variables

View Source
var ErrDefNotExist = errors.New("def does not exist")
View Source
var MakeDefFormatters = make(map[string]MakeDefFormatter)

MakeDefFormatter holds MakeDefFormatters that toolchains have registered with RegisterMakeDefFormatter.

QualLevels associates a number (the slice index) with each Qualification, for use in format strings (so that, e.g., "%.0n" means Unqualified name and "%.2n" means DepQualified name).

Functions

func IsNotExist

func IsNotExist(err error) bool

func IsValidTreePath

func IsValidTreePath(treePath string) bool

func MakeURI

func MakeURI(cloneURL string) string

MakeURI converts a repository clone URL, such as "git://github.com/user/repo.git", to a normalized URI string, such as "github.com/user/repo" lexically. MakeURI panics if there is an error, and should only be used if cloneURL is a correctly-formed URL. It is a wrapper around TryMakeURI.

func RegisterMakeDefFormatter

func RegisterMakeDefFormatter(unitType string, f MakeDefFormatter)

RegisterMakeDefFormatter makes a DefFormatter constructor function (MakeDefFormatter) available for defs with the specified unitType. If Register is called twice with the same unitType or if sf is nil, it panics

func TryMakeURI

func TryMakeURI(cloneURL string) (string, error)

TryMakeURI converts a repository clone URL, such as "git://github.com/user/repo.git", to a normalized URI string, such as "github.com/user/repo" lexically. TryMakeURI returns an error if cloneURL is empty or malformed.

func URIEqual

func URIEqual(a, b string) bool

URIEqual returns true if a and b are equal, based on a case insensitive comparison (strings.EqualFold).

func UniqueRefDefs

func UniqueRefDefs(refs []*Ref, m map[RefDefKey]int) map[RefDefKey]int

UniqueRefDefs groups refs by the RefDefKey field and returns a map of how often each RefDefKey appears. If m is non-nil, counts are incremented and a new map is not created.

Types

type Def

type Def struct {
	// DefKey is the natural unique key for a def. It is stable
	// (subsequent runs of a grapher will emit the same defs with the same
	// DefKeys).
	DefKey `protobuf:"bytes,1,req,name=key,embedded=key" json:""`
	// Name of the definition. This need not be unique.
	Name string `protobuf:"bytes,2,opt,name=name" json:"Name"`
	// Kind is the kind of thing this definition is. This is
	// language-specific. Possible values include "type", "func",
	// "var", etc.
	Kind     string `protobuf:"bytes,3,opt,name=kind" json:"Kind,omitempty"`
	File     string `protobuf:"bytes,4,opt,name=file" json:"File"`
	DefStart uint32 `protobuf:"varint,5,opt,name=start" json:"DefStart"`
	DefEnd   uint32 `protobuf:"varint,6,opt,name=end" json:"DefEnd"`
	// Exported is whether this def is part of a source unit's
	// public API. For example, in Java a "public" field is
	// Exported.
	Exported bool `protobuf:"varint,7,opt,name=exported" json:"Exported,omitempty"`
	// Local is whether this def is local to a function or some
	// other inner scope. Local defs do *not* have module,
	// package, or file scope. For example, in Java a function's
	// args are Local, but fields with "private" scope are not
	// Local.
	Local bool `protobuf:"varint,8,opt,name=local" json:"Local,omitempty"`
	// Test is whether this def is defined in test code (as opposed to main
	// code). For example, definitions in Go *_test.go files have Test = true.
	Test bool `protobuf:"varint,9,opt,name=test" json:"Test,omitempty"`
	// Data contains additional language- and toolchain-specific information
	// about the def. Data is used to construct function signatures,
	// import/require statements, language-specific type descriptions, etc.
	//
	// To use json.RawMessage:
	// optional bytes data = 10 [(gogoproto.nullable) = false, (gogoproto.customtype) = "encoding/json.RawMessage", (gogoproto.jsontag) = "Data,omitempty"];
	Data json.RawMessage `protobuf:"bytes,10,opt,name=data" json:"Data,omitempty"`
	// Docs are docstrings for this Def. This field is not set in the
	// Defs produced by graphers; they should emit docs in the
	// separate Docs field on the graph.Output struct.
	Docs []DefDoc `protobuf:"bytes,11,rep,name=docs" json:"Docs,omitempty"`
	// TreePath is a structurally significant path descriptor for a def. For
	// many languages, it may be identical or similar to DefKey.Path.
	// However, it has the following constraints, which allow it to define a
	// def tree.
	//
	// A tree-path is a chain of '/'-delimited components. A component is either a
	// def name or a ghost component.
	// - A def name satifies the regex [^/-][^/]*
	// - A ghost component satisfies the regex -[^/]*
	// Any prefix of a tree-path that terminates in a def name must be a valid
	// tree-path for some def.
	// The following regex captures the children of a tree-path X: X(/-[^/]*)*(/[^/-][^/]*)
	TreePath string `protobuf:"bytes,17,opt,name=tree_path" json:"TreePath,omitempty"`
}

START Def OMIT Def is a definition in code.

func (*Def) Fmt

func (s *Def) Fmt() DefPrintFormatter

func (*Def) GoString

func (this *Def) GoString() string

func (*Def) Marshal

func (m *Def) Marshal() (data []byte, err error)

func (*Def) MarshalTo

func (m *Def) MarshalTo(data []byte) (n int, err error)

func (*Def) ProtoMessage

func (*Def) ProtoMessage()

func (*Def) Reset

func (m *Def) Reset()

func (*Def) Size

func (m *Def) Size() (n int)

func (*Def) String

func (m *Def) String() string

func (*Def) Unmarshal

func (m *Def) Unmarshal(data []byte) error

type DefDoc

type DefDoc struct {
	// Format is the the MIME-type that the documentation is stored
	// in. Valid formats include 'text/html', 'text/plain',
	// 'text/x-markdown', text/x-rst'.
	Format string `protobuf:"bytes,1,req,name=format" json:"Format"`
	// Data is the actual documentation text.
	Data string `protobuf:"bytes,2,opt,name=data" json:"Data"`
}

DefDoc is documentation on a Def.

func (*DefDoc) GoString

func (this *DefDoc) GoString() string

func (*DefDoc) Marshal

func (m *DefDoc) Marshal() (data []byte, err error)

func (*DefDoc) MarshalTo

func (m *DefDoc) MarshalTo(data []byte) (n int, err error)

func (*DefDoc) ProtoMessage

func (*DefDoc) ProtoMessage()

func (*DefDoc) Reset

func (m *DefDoc) Reset()

func (*DefDoc) Size

func (m *DefDoc) Size() (n int)

func (*DefDoc) String

func (m *DefDoc) String() string

func (*DefDoc) Unmarshal

func (m *DefDoc) Unmarshal(data []byte) error

type DefFormatter

type DefFormatter interface {
	// Name formats the def's name with the specified level of qualification.
	Name(qual Qualification) string

	// Type is the type of the def s, if s is not itself a type. If s is
	// itself a type, then Type returns its underlying type.
	//
	// Outputs:
	//
	//   TYPE OF s          RESULT
	//   ------------   -----------------------------------------------------------------
	//   named type     the named type's name
	//   primitive      the primitive's name
	//   function       `(arg1, arg2, ..., argN)` with language-specific type annotations
	//   package        empty
	//   anon. type     the leading keyword (or similar) of the anonymous type definition
	//
	// These rules are not strictly defined or enforced. Language toolchains
	// should freely bend the rules (after noting important exceptions here) to
	// produce sensible output.
	Type(qual Qualification) string

	// NameAndTypeSeparator is the string that should be inserted between the
	// def's name and type. This is typically empty for functions (so that
	// they are formatted with the left paren immediately following the name,
	// like `F(a)`) and a single space for other defs (e.g., `MyVar string`).
	NameAndTypeSeparator() string

	// Language is the name of the programming language that s is in; e.g.,
	// "Python" or "Go".
	Language() string

	// DefKeyword is the language keyword used to define the def (e.g.,
	// 'class', 'type', 'func').
	DefKeyword() string

	// Kind is the language-specific kind of this def (e.g., 'package', 'field', 'CommonJS module').
	Kind() string
}

DefFormatter formats a def.

type DefKey

type DefKey struct {
	// Repo is the VCS repository that defines this definition.
	Repo string `protobuf:"bytes,1,opt,name=repo" json:"Repo,omitempty"`
	// CommitID is the ID of the VCS commit that this definition was defined in. The
	// CommitID is always a full commit ID (40 hexadecimal characters for git
	// and hg), never a branch or tag name.
	CommitID string `protobuf:"bytes,2,opt,name=commit_id" json:"CommitID,omitempty"`
	// UnitType is the type name of the source unit (obtained from unit.Type(u))
	// that this definition was defined in.
	UnitType string `protobuf:"bytes,3,opt,name=unit_type" json:"UnitType,omitempty"`
	// Unit is the name of the source unit (obtained from u.Name()) that this
	// definition was defined in.
	Unit string `protobuf:"bytes,4,opt,name=unit" json:"Unit,omitempty"`
	// Path is a unique identifier for the def, relative to the source unit.
	// It should remain stable across commits as long as the def is the
	// "same" def. Its Elasticsearch mapping is defined separately (because
	// it is a multi_field, which the struct tag can't currently represent).
	//
	// Path encodes no structural semantics. Its only meaning is to be a stable
	// unique identifier within a given source unit. In many languages, it is
	// convenient to use the namespace hierarchy (with some modifications) as
	// the Path, but this may not always be the case. I.e., don't rely on Path
	// to find parents or children or any other structural propreties of the
	// def hierarchy). See Def.TreePath instead.
	Path string `protobuf:"bytes,5,opt,name=path" json:"Path"`
}

START DefKey OMIT DefKey specifies a definition, either concretely or abstractly. A concrete definition key has a non-empty CommitID and refers to a definition defined in a specific commit. An abstract definition key has an empty CommitID and is considered to refer to definitions from any number of commits (so long as the Repo, UnitType, Unit, and Path match).

You can think of CommitID as the time dimension. With an empty CommitID, you are referring to a definition that may or may not exist at various times. With a non-empty CommitID, you are referring to a specific definition of a definition at the time specified by the CommitID.

func (*DefKey) GoString

func (this *DefKey) GoString() string

func (*DefKey) Marshal

func (m *DefKey) Marshal() (data []byte, err error)

func (*DefKey) MarshalTo

func (m *DefKey) MarshalTo(data []byte) (n int, err error)

func (*DefKey) ProtoMessage

func (*DefKey) ProtoMessage()

func (*DefKey) Reset

func (m *DefKey) Reset()

func (*DefKey) Size

func (m *DefKey) Size() (n int)

func (*DefKey) String

func (m *DefKey) String() string

func (*DefKey) Unmarshal

func (m *DefKey) Unmarshal(data []byte) error

type DefPrintFormatter

type DefPrintFormatter interface {
	DefFormatter
	fmt.Formatter
}

func PrintFormatter

func PrintFormatter(s *Def) DefPrintFormatter

Formatter creates a string formatter for a def.

The verbs:

%n     qualified name
%w     language keyword used to define the def (e.g., 'class', 'type', 'func')
%k     language-specific kind of this def (e.g., 'package', 'field', 'CommonJS module')
%t     type

The flags:

' '    (in `% t`) prepend the language-specific delimiter between a def's name and type

See DefFormatter for more information.

type Defs

type Defs []*Def

func (Defs) KeySet

func (defs Defs) KeySet() (keys map[DefKey]struct{}, err error)

func (Defs) Keys

func (defs Defs) Keys() (keys []DefKey)

func (Defs) Len

func (vs Defs) Len() int

func (Defs) Less

func (vs Defs) Less(i, j int) bool

func (Defs) Swap

func (vs Defs) Swap(i, j int)

type Doc

type Doc struct {
	// DefKey points to the Def that this documentation pertains to.
	DefKey `protobuf:"bytes,1,req,name=key,embedded=key" json:""`
	// Format is the the MIME-type that the documentation is stored
	// in. Valid formats include 'text/html', 'text/plain',
	// 'text/x-markdown', text/x-rst'.
	Format string `protobuf:"bytes,2,opt,name=format" json:"Format"`
	// Data is the actual documentation text.
	Data string `protobuf:"bytes,3,opt,name=data" json:"Data"`
	// File is the filename where this Doc exists.
	File string `protobuf:"bytes,4,opt,name=file" json:"File,omitempty"`
	// Start is the byte offset of this Doc's first byte in File.
	Start uint32 `protobuf:"varint,5,opt,name=start" json:"Start,omitempty"`
	// End is the byte offset of this Doc's last byte in File.
	End uint32 `protobuf:"varint,6,opt,name=end" json:"End,omitempty"`
}

START Doc OMIT Doc is documentation on a Def.

func (*Doc) GoString

func (this *Doc) GoString() string

func (*Doc) Key

func (d *Doc) Key() DocKey

Key returns the unique key for the doc.

func (*Doc) Marshal

func (m *Doc) Marshal() (data []byte, err error)

func (*Doc) MarshalTo

func (m *Doc) MarshalTo(data []byte) (n int, err error)

func (*Doc) ProtoMessage

func (*Doc) ProtoMessage()

func (*Doc) Reset

func (m *Doc) Reset()

func (*Doc) Size

func (m *Doc) Size() (n int)

func (*Doc) String

func (m *Doc) String() string

func (*Doc) Unmarshal

func (m *Doc) Unmarshal(data []byte) error

type DocKey

type DocKey struct {
	DefKey
	Format string
	File   string
	Start  uint32
}

DocKey is the unique key for a doc. Each doc within a source unit must have a unique DocKey.

Freestanding comments will not have an associated DefKey, but they *must* provide 'Start' and 'File'.

func (DocKey) String

func (d DocKey) String() string

type Docs

type Docs []*Doc

func (Docs) Len

func (vs Docs) Len() int

func (Docs) Less

func (vs Docs) Less(i, j int) bool

func (Docs) Swap

func (vs Docs) Swap(i, j int)

type MakeDefFormatter

type MakeDefFormatter func(*Def) DefFormatter

A MakeDefFormatter is a function, typically implemented by toolchains, that creates a DefFormatter for a def.

type Output

type Output struct {
	Defs []*Def     `protobuf:"bytes,1,rep,name=defs" json:"Defs,omitempty"`
	Refs []*Ref     `protobuf:"bytes,2,rep,name=refs" json:"Refs,omitempty"`
	Docs []*Doc     `protobuf:"bytes,3,rep,name=docs" json:"Docs,omitempty"`
	Anns []*ann.Ann `protobuf:"bytes,4,rep,name=anns,customtype=sourcegraph.com/sourcegraph/srclib/ann.Ann" json:"Anns,omitempty"`
}

START Output OMIT

func (*Output) Marshal

func (m *Output) Marshal() (data []byte, err error)

func (*Output) MarshalTo

func (m *Output) MarshalTo(data []byte) (n int, err error)

func (*Output) ProtoMessage

func (*Output) ProtoMessage()

func (*Output) Reset

func (m *Output) Reset()

func (*Output) Size

func (m *Output) Size() (n int)

func (*Output) String

func (m *Output) String() string

func (*Output) Unmarshal

func (m *Output) Unmarshal(data []byte) error

type Propagate

type Propagate struct {
	// Src is the def whose type/value is being propagated to the dst def.
	SrcRepo     string
	SrcPath     string
	SrcUnit     string
	SrcUnitType string

	// Dst is the def that is receiving a propagated type/value from the src def.
	DstRepo     string
	DstPath     string
	DstUnit     string
	DstUnitType string
}

Propagate describes type/value propagation in code. A Propagate entry from A (src) to B (dst) indicates that the type/value of A propagates to B. In Tern, this is indicated by A having a "fwd" property whose value is an array that includes B.

## Motivation & example

For example, consider the following JavaScript code:

var a = Foo;
var b = a;

Foo, a, and b are each their own def. We could resolve all of them to the def of their original type (perhaps Foo), but there are occasions when you do want to see only the definition of a or b and examples thereof. Therefore, we need to represent them as distinct defs.

Even though Foo, a, and b are distinct defs, there are propagation relationships between them that are important to represent. The type of Foo propagates to both a and b, and the type of a propagates to b. In this case, we would have 3 Propagates: Propagate{Src: "Foo", Dst: "a"}, Propagate{Src: "Foo", Dst: "b"}, and Propagate{Src: "a", Dst: "b"}. (The propagation relationships could be described by just the first and last Propagates, but we explicitly include all paths as a denormalization optimization to avoid requiring an unbounded number of DB queries to determine which defs a type propagates to or from.)

## Directionality

Propagation is unidirectional, in the general case. In the example above, if Foo referred to a JavaScript object and if the code were evaluated, any *runtime* type changes (e.g., setting a property) on Foo, a, and b would be reflected on all of the others. But this doesn't hold for static analysis; it's not always true that if a property "a.x" or "b.x" exists, then "Foo.x" exists. The simplest example is when Foo is an external definition. Perhaps this example file (which uses Foo as a library) modifies Foo to add a new property, but other libraries that use Foo would never see that property because they wouldn't be executed in the same context as this example file. So, in general, we cannot say that Foo receives all types applied to defs that Foo propagates to.

## Hypothetical Python example

Consider the following 2 Python files:

"""file1.py"""
class Foo(object): end

"""file2.py"""
from .file1 import Foo
Foo2 = Foo

In this example, there would be one Propagate: Propagate{Src: "file1/Foo", Dst: "file2/Foo2}.

type Qualification

type Qualification string

A Qualification specifies how much to qualify names when formatting defs and their type information.

type Ref

type Ref struct {
	// DefRepo is the repository URI of the Def that this Ref refers
	// to.
	DefRepo string `protobuf:"bytes,1,opt,name=def_repo" json:"DefRepo,omitempty"`
	// DefUnitType is the source unit type of the Def that this Ref refers to.
	DefUnitType string `protobuf:"bytes,3,opt,name=def_unit_type" json:"DefUnitType,omitempty"`
	// DefUnit is the name of the source unit that this ref exists in.
	DefUnit string `protobuf:"bytes,4,opt,name=def_unit" json:"DefUnit,omitempty"`
	// Path is the path of the Def that this ref refers to.
	DefPath string `protobuf:"bytes,5,opt,name=def_path" json:"DefPath"`
	// Repo is the VCS repository in which this ref exists.
	Repo string `protobuf:"bytes,6,opt,name=repo" json:"Repo,omitempty"`
	// CommitID is the ID of the VCS commit that this ref exists
	// in. The CommitID is always a full commit ID (40 hexadecimal
	// characters for git and hg), never a branch or tag name.
	CommitID string `protobuf:"bytes,7,opt,name=commit_id" json:"CommitID,omitempty"`
	// UnitType is the type name of the source unit that this ref
	// exists in.
	UnitType string `protobuf:"bytes,8,opt,name=unit_type" json:"UnitType,omitempty"`
	// Unit is the name of the source unit that this ref exists in.
	Unit string `protobuf:"bytes,9,opt,name=unit" json:"Unit,omitempty"`
	// Def is true if this Ref spans the name of the Def it points to.
	Def bool `protobuf:"varint,17,opt,name=def" json:"Def,omitempty"`
	// File is the filename in which this Ref exists.
	File string `protobuf:"bytes,10,opt,name=file" json:"File,omitempty"`
	// Start is the byte offset of this ref's first byte in File.
	Start uint32 `protobuf:"varint,11,opt,name=start" json:"Start"`
	// End is the byte offset of this ref's last byte in File.
	End uint32 `protobuf:"varint,12,opt,name=end" json:"End"`
}

START Ref OMIT Ref represents a reference from source code to a Def.

func (*Ref) DefKey

func (r *Ref) DefKey() DefKey

func (*Ref) GoString

func (this *Ref) GoString() string

func (*Ref) Marshal

func (m *Ref) Marshal() (data []byte, err error)

func (*Ref) MarshalTo

func (m *Ref) MarshalTo(data []byte) (n int, err error)

func (*Ref) ProtoMessage

func (*Ref) ProtoMessage()

func (*Ref) RefDefKey

func (r *Ref) RefDefKey() RefDefKey

func (*Ref) RefKey

func (r *Ref) RefKey() RefKey

func (*Ref) Reset

func (m *Ref) Reset()

func (*Ref) SetFromDefKey

func (r *Ref) SetFromDefKey(k DefKey)

func (*Ref) Size

func (m *Ref) Size() (n int)

func (*Ref) String

func (m *Ref) String() string

func (*Ref) Unmarshal

func (m *Ref) Unmarshal(data []byte) error

type RefDefKey

type RefDefKey struct {
	DefRepo     string `protobuf:"bytes,1,opt,name=def_repo" json:"DefRepo,omitempty"`
	DefUnitType string `protobuf:"bytes,3,opt,name=def_unit_type" json:"DefUnitType,omitempty"`
	DefUnit     string `protobuf:"bytes,4,opt,name=def_unit" json:"DefUnit,omitempty"`
	DefPath     string `protobuf:"bytes,5,opt,name=def_path" json:"DefPath"`
}

func (*RefDefKey) GoString

func (this *RefDefKey) GoString() string

func (*RefDefKey) Marshal

func (m *RefDefKey) Marshal() (data []byte, err error)

func (*RefDefKey) MarshalTo

func (m *RefDefKey) MarshalTo(data []byte) (n int, err error)

func (*RefDefKey) ProtoMessage

func (*RefDefKey) ProtoMessage()

func (*RefDefKey) Reset

func (m *RefDefKey) Reset()

func (*RefDefKey) Size

func (m *RefDefKey) Size() (n int)

func (*RefDefKey) String

func (m *RefDefKey) String() string

func (*RefDefKey) Unmarshal

func (m *RefDefKey) Unmarshal(data []byte) error

type RefKey

type RefKey struct {
	DefRepo     string `json:",omitempty"`
	DefUnitType string `json:",omitempty"`
	DefUnit     string `json:",omitempty"`
	DefPath     string `json:",omitempty"`
	Def         bool   `json:",omitempty"`
	Repo        string `json:",omitempty"`
	UnitType    string `json:",omitempty"`
	Unit        string `json:",omitempty"`
	File        string `json:",omitempty"`
	CommitID    string `json:",omitempty"`
	Start       uint32 `json:",omitempty"`
	End         uint32 `json:",omitempty"`
}

func (*RefKey) RefDefKey

func (r *RefKey) RefDefKey() RefDefKey

type RefSet

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

RefSet is a set of Refs. It can used to determine whether a grapher emits duplicate refs.

func NewRefSet

func NewRefSet() *RefSet

func (*RefSet) AddAndCheckUnique

func (c *RefSet) AddAndCheckUnique(ref Ref) (duplicate bool)

AddAndCheckUnique adds ref to the set of seen refs, and returns whether the ref already existed in the set.

type Refs

type Refs []*Ref

func (Refs) Len

func (vs Refs) Len() int

func (Refs) Less

func (vs Refs) Less(i, j int) bool

func (Refs) Swap

func (vs Refs) Swap(i, j int)

type RepositoryListingDef

type RepositoryListingDef struct {
	// Name is the full name shown on the page.
	Name string

	// NameLabel is a label displayed next to the Name, such as "(main package)"
	// to denote that a package is a Go main package.
	NameLabel string

	// Language is the source language of the def, with any additional
	// specifiers, such as "JavaScript (node.js)".
	Language string

	// SortKey is the key used to lexicographically sort all of the defs on
	// the page.
	SortKey string
}

RepositoryListingDef holds rendered display text to show on the "package" listing page of a repository.

type StatType

type StatType string

StatType is the name of a def statistic (see below for a listing).

func (StatType) IsAbstract

func (x StatType) IsAbstract() bool

type Stats

type Stats map[StatType]int

Stats holds statistics for a def.

Jump to

Keyboard shortcuts

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