Lua code parsing

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
tbayne
Posts: 4
Joined: Wed Nov 03, 2010 9:09 pm

Lua code parsing

Post by tbayne »

Good evening,

I have created a workspace that contains a single project, and that project contains a single .lua file.

The "functions" list appears to be empty, while the classes list contains a mixed list of variables and function names.

Any idea why this is happening?

Thanks
Terry
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi Terry,
The "functions" list appears to be empty, while the classes list contains a mixed list of variables and function names.

It appears you have found a bug :(

Just FYI This is how the functions list works.

If the current file is in the current workspace the tag information is used to populate the function list, other wise the function regular expression in the document type is used.
Any idea why this is happening?

In this case the file is in the workspace, but what has gone wrong is the tagger has incorrectly marked the functions as variables and hence the error.

Hopefully I suspect this should be fairly easy to fix so watch this space for patch ;)

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

There is a new xtags.dll that should fix this issue. Just download the this zip file and replace the current dll with the one from the zip file.

Cheers Jussi
tbayne
Posts: 4
Joined: Wed Nov 03, 2010 9:09 pm

re: new xtags.dll

Post by tbayne »

Jussi,

That fixed the problem. Thank you for the quick turnaround!

Have a great day/evening!

Terry
JWJB
Posts: 2
Joined: Mon Jan 09, 2012 9:15 am

Lua Code Completion

Post by JWJB »

jussij wrote:There is a new xtags.dll that should fix this issue. Just download the this zip file and replace the current dll with the one from the zip file.

Cheers Jussi
Hello jussij,

I am having a similar problem to what tbayne was having except, replacing the xtags.dll file did not seem to resolve the issue.

That is, I created a single workspace with a single project with a single .lua file for the API excerpted below for your reference.

Code: Select all

crypto.sha512
display.captureScreen ( <#saveToAlbumBool#> )
display.contentCenterX
display.contentCenterY
display.contentHeight
display.contentScaleX
display.contentScaleY
display.contentWidth
display.getCurrentStage ( )
display.loadRemoteImage ( <#url#>, <#method#>, <#listener#> <#[, params]#>, <#destFilename#> <#[, baseDir]#> <#[, x, y]#> )
display.newCircle( <#xCenter#>, <#yCenter#>, <#radius#> )
But when I start typing for example, "dis" it will autocomplete "display", but not give me a drop-down autocomplete wordlist for all of display. objects.

Further, the Functions list appears to be empty.

Thanks in advance.

John
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi John,

Correct me if I am wrong, but in your code below you are using the functions that make up the display table:

Code: Select all

display.captureScreen ( <#saveToAlbumBool#> )
display.contentCenterX
Why this is not working is because nowhere in your code is there a definition of the display table.

Without somesort of definition, there is no ctags information, hence Zeus knows nothing about the object and as such it can't show any of it's functions.

But luckily there is quite an easy to fix this :)

Can you try doing the following:
  1. I am assuming you are running Windows XP (see below if this is not the case)
  2. Create a new workspace called Lua in the following folder location.

    Code: Select all

    c:\Program Files\Zeus\zTags\
  3. Remove the Header and Resource folders.
  4. Add this file (which should already exist) to the Source folder of that workspace:

    Code: Select all

    c:\Program Files\Zeus\zTags\Templates\Lua.js
  5. Append this code to the end of that file:

    Code: Select all

    // Created using http://developer.anscamobile.com/reference/display-objects
    class display
    {
        // Common Methods
        remove();
    
        // Content Size Properties
        contentCenterX;
        contentCenterY;
        contentHeight;
        contentScaleX;
        contentScaleY;
        contentWidth;
        screenOriginX;
        screenOriginY;
        statusBarHeight;
        viewableContentHeight;
        viewableContentWidth;
    
        //Factory Functions
        loadRemoteImage( );
        newCircle();
        newEmbossedText();
        newGroup();
        newImage( );
        newImageRect();
        newLine( );
        newRect();
        newRetinaText();
        newRoundedRect();
        newText();
    
        //Other Display Functions
        captureScreen( );
        save( );
        setDefault( );
        setStatusBar( );
    
        //Stage Display Objects
        getCurrentStage( );
    }
    Now if you create a new Lua file and type in this code:
  6. Code: Select all

    display.
    You should get the correct intellisense as expected.
If you are running on Windows 7 then the location of these files will be different.

To find the corrent location just use the Macro, Load menu and in the resulting dialog move up one folder level to help the correct zTags folder location.

So how does this all work :?:

Well the steps above do nothing more than create a very simple definition of the display object.

This display object definition has also been saved to the Lua tag database that is attached to this Lua workspace.

Also the default definition of the Lua document type has been pre-defined to use this Lua tag database.

So this means any time you edit any Lua file, Zeus will go looking into this tag database for any object definitions.

But you will notice one final trick ;)

The object definition has been put into a Java Script file and not an Lua file.

This has to be done because the ctag.exe does not fullly support modern day Lua code.

But since we only require a very simple skeleton of the object definition we can get away with just a little bit of Java Script to provide the definition ;)

Cheers Jussi
Last edited by jussij on Wed Jan 11, 2012 2:19 am, edited 1 time in total.
JWJB
Posts: 2
Joined: Mon Jan 09, 2012 9:15 am

Lua Code Completion

Post by JWJB »

Hello Jussi,

Thanks for your prompt reply and detailed set of instructions and explanation for my issue.

I will work through your set of steps and report back to you on the results.

Again, thanks for your help.

John
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi John,

I found a better reference page for the Corona SDK API and have create a better reference file.

See details here: http://www.zeusedit.com/zforum/viewtopic.php?t=6528

This is just a very quick, first cut so I am sure it will have a few bugs.

Cheers Jussi
Post Reply