source

package
v0.0.0-...-6c789bd Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package source provides source info for client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	URI() uri.URI
	View() View
	FileSystem() FileSystem
	Read(ctx context.Context) ([]byte, string, error)

	Saved() bool
	// TODO: Fix appropriate function name.
	SetSaved(saved bool)
}

File represents a source file of any type.

type FileSystem

type FileSystem interface {
	// GetFile returns a file whose the given uri.
	GetFile(uri uri.URI) (File, error)
}

FileSystem is the interface to something that provides file contents.

type ProtoFile

type ProtoFile interface {
	File
	Proto() registry.Proto
	SetProto(proto registry.Proto)
}

type Session

type Session interface {
	// View returns a view with a matching name, if the session has one.
	View(name string) (View, bool)

	// ViewOf returns a view corresponding to the given URI.
	ViewOf(uri uri.URI) View

	// Views returns the set of active views built by this session.
	Views() []View

	// AddView creates a new View, adds it to the Session and returns it.
	AddView(ctx context.Context, view View)

	// RemoveView removes a View with a matching name.
	RemoveView(ctx context.Context, view View) error

	// Shutdown the session and all views it has created.
	Shutdown(ctx context.Context)
}

Session represents a single connection from a client. A session just manages views and does not access files directly.

func NewSession

func NewSession() Session

NewSession returns Session.

type View

type View interface {
	FileSystem

	// Session returns the session that created this view.
	Session() Session

	// Name returns the name this view was constructed with.
	Name() string

	// Folder returns the root folder for this view.
	Folder() uri.URI

	// Called to set the effective contents of a file from this view.
	SetContent(ctx context.Context, uri uri.URI, content []byte)

	// Ignore returns true if this file should be ignored by this view.
	Ignore(uri.URI) bool

	// Shutdown closes this view, and detaches it from it's session.
	Shutdown(ctx context.Context) error

	// DidOpen is invoked each time a file is opened in the editor.
	DidOpen(uri uri.URI, text []byte)

	// DidSave is invoked each time an open file is saved in the editor.
	DidSave(uri uri.URI)

	// DidClose is invoked each time an open file is closed in the editor.
	DidClose(uri uri.URI)

	// IsOpen can be called to check if the editor has a file currently open.
	IsOpen(uri uri.URI) bool
}

View represents a single workspace. Views are managed by a session. A view accesses files.

func NewView

func NewView(session Session, name string, folder uri.URI) View

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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