project

package
v0.0.0-...-e49a3f0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCompletionResults = errors.New("No completion results found for symbol at given position")
View Source
var (
	ErrNoDefinitionFound = errors.New(
		"No definition found for symbol at given position",
	)
)
View Source
var KeywordItems = functional.Map(Keywords, func(keyword string) protocol.CompletionItem {
	return protocol.CompletionItem{Label: keyword, Kind: protocol.KeywordCompletion}
})
View Source
var Keywords = []string{
	"abstract",
	"and",
	"as",
	"break",
	"callable",
	"case",
	"catch",
	"class",
	"clone",
	"const",
	"continue",
	"declare",
	"default",
	"die",
	"do",
	"echo",
	"else",
	"elseif",
	"enddeclare",
	"endfor",
	"endforeach",
	"endif",
	"endswitch",
	"endwhile",
	"exit",
	"extends",
	"final",
	"finally",
	"fn",
	"for",
	"foreach",
	"function",
	"global",
	"goto",
	"if",
	"implements",
	"include",
	"include_once",
	"instanceof",
	"insteadof",
	"interface",
	"match",
	"namespace",
	"new",
	"or",
	"print",
	"private",
	"protected",
	"public",
	"readonly",
	"require",
	"require_once",
	"return",
	"static",
	"switch",
	"throw",
	"trait",
	"try",
	"use",
	"var",
	"while",
	"xor",
	"yield",
	"yield from",
}

Source: https://www.php.net/manual/en/reserved.keywords.php

Functions

func AddExprCompletions

func AddExprCompletions(
	list *protocol.CompletionList,
	comp CompletionContext,
	ctx *context.Ctx,
	lastValue string,
	additionalFilters ...symbol.FilterFunc[symbol.Member],
)

func AddFromIndex

func AddFromIndex(
	list *protocol.CompletionList,
	pos *position.Position,
	prefix string,
	types ...ast.Type,
)

func AddKeywordsWithPrefix

func AddKeywordsWithPrefix(list *protocol.CompletionList, prefix string)

func AddScopeVars

func AddScopeVars(
	list *protocol.CompletionList,
	ctx *context.Ctx,
	prefix string,
)

func Complete

func Complete(pos *position.Position, comp CompletionContext) (list protocol.CompletionList)

func CompletionData

func CompletionData(pos *position.Position, n *index.INode) string

func NodeCompletionKind

func NodeCompletionKind(kind ast.Type) protocol.CompletionItemKind

func NodeSignature

func NodeSignature(node ast.Vertex) string

func PredictNamespace

func PredictNamespace(pos *position.Position) string

1. Check if there are other sibling files, parse for their namespace. 2. Keep going up a dir, trying the files for their namespace, camel case the directory names. 3. TODO: If we find the root of the project, return.

func Reconstruct

func Reconstruct(tokens []*token.Token) ast.Vertex

Reconstruct tries to construct an AST node from the given tokens. It closes any open constructs and tries to turn the tokens into parse-able PHP. That PHP is then parsed and the resulting nodes have their position set to that of the tokens.

Types

type CompletionAction

type CompletionAction int
const (
	None               CompletionAction = iota // Not doing anything special, should complete global stuff, available variables in the scope.
	NamingFunction                             // A function is being named, probably nothing to complete.
	NamingClassLike                            // A class, interface or trait is being named, probably nothing to complete.
	NamingNamespace                            // Typing after 'namespace', complete with possible namespaces based on directory structure.
	StartingVariable                           // A '$' has been typed, should complete available variables in scope.
	Variable                                   // A '$' with some characters (variable being typed), should complete available variables in scope, starting with the currently typed prefix.
	ObjectOp                                   // Last op was a '->', should resolve up to before '->' and complete available stuff on that variable.
	StaticOp                                   // Last op was '::', should resolve up to before '::' and complete available static stuff on that variable, can also complete 'class' to make $obj::class.
	Implements                                 // Typing after 'implements', should complete any interfaces.
	Extends                                    // Typing after 'extends', should complete any classes.
	Use                                        // Typing after 'use', should complete any traits.
	AddingFile                                 // Typing after include, include once, require or require once. Should complete file paths.
	Newing                                     // Typing after 'new'. Should complete classes.
	Name                                       // Typing a bare name, complete any classes that match it.
	NameRelative                               // Typing 'namespace\foo'. Should complete classes relative to current namespace.
	NameFullyQualified                         // Typing a name starting with '\'. Should complete any FQN starting with what has been typed.
)

func (CompletionAction) String

func (i CompletionAction) String() string

type CompletionContext

type CompletionContext struct {
	Action CompletionAction
	Tokens []*token.Token // The last of these is the place the cursor is at.
}

func GetCompletionQuery

func GetCompletionQuery(pos *position.Position) CompletionContext

type CompletionItemData

type CompletionItemData struct {
	CurrPos   *position.Position
	TargetPos *position.Position
}

type DefinitionProvider

type DefinitionProvider interface {
	CanDefine(ctx *context.Ctx, kind ast.Type) bool
	Define(ctx *context.Ctx) ([]*definition.Definition, error)
}

type Project

type Project struct{}

func New

func New() *Project

func (*Project) Complete

func (p *Project) Complete(
	pos *position.Position,
) []*index.INode

func (*Project) Definition

func (p *Project) Definition(pos *position.Position) ([]*position.Position, error)

func (*Project) Hover

func (p *Project) Hover(currpos *position.Position) string

func (*Project) Parse

func (p *Project) Parse(done *atomic.Uint64, total *atomic.Uint64, totalDone chan<- bool) error

This should only be called once at the beginning of the connection with a client.

func (*Project) ParseFileUpdate

func (p *Project) ParseFileUpdate(path string, content string) error

func (*Project) ParseWithoutProgress

func (p *Project) ParseWithoutProgress() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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