Internal Lua Model

This model come as an extension of the lua external api model. This model is an internal view of a lua file. This model is used by IDE to do :

  • auto-completion
  • go to definition
  • highlight occurences
  • show documentation

The code relative to this model is based on lua and metalua, it is accessible here.

internal content

This is the internal view of a lua file

internalcontent
.list(item) unknownglobalvars
.block content

block

A block is a container of "node". It also hold a list of variable declarations.

block
.list (Item,scope) localvars 
.list (node) content
.(offsetmin, offsetmax) sourcerange

a scope is the offsetmin and the offsetmax which define the visibility range

node

A node is ast element which have a representation in the source code. Now, we only need Identifier, Index, Call and Invoke element.

node:expr

expr:identifier|index|call|invoke|block 

identifier
.(offsetmin, offsetmax) sourcerange
.item definition

index
.(offsetmin, offsetmax) sourcerange
.expr left 
.string right

call
.(offsetmin, offsetmax) sourcerange
.expr function

Invoke
.(offsetmin, offsetmax) sourcerange
. expr record
. string functioname
 

The definition of an identifier is an item which could be :

  • a local declaration of a block of this file
  • a global var declared in the external api
  • an unresolvedglobalvar stored at the root of the internal view.

External API Model Extension

Item

To implements highlight occurences, item needs be modified

item
.string name
.string description
.typeref type
.list(Identifier) occurrences

TypeRef

We also need more typeref.

ModuleTypeRef

When a variable is initialized with require "my.module", the type ref is a moduletyperef which will be resolved later.

moduletyperef 
.string modulename
.int returnposition

ExprTypeRef

When a variable is initialized with a complex expression like mymodule.newObject(), the type ref is a exprtyperef which will be resolved later.

exprtyperef 
.expr expression
.int returnposition