Sarrus1 / sourcepawn-studio

VSCode extension for SourcePawn scripting
https://sarrus1.github.io/sourcepawn-studio/
MIT License
139 stars 21 forks source link

IntelliSense hints and wrong highlighting #358

Open MAGNAT2645 opened 6 months ago

MAGNAT2645 commented 6 months ago

Basic informations

Further Information

Some lines are colored wrong and the IntelliSense thingy shows wrong info when you hover your mouse. Looks like it's shifted or smth. изображение изображение

To Reproduce

I dont know actually, just open any workspace with multiple files.

Code to reproduce the behaviour

This one is in the main file.

public void PLS_OnPlayerLevelUpMenu(PLSPlayer player, int iAmount, SmartMenu hMenu)
{
    int iCurrentLVL = player.Level,
        iStartLVL   = ( iCurrentLVL - iAmount ) + 1,
        iRequiredLevel;
    char szBuffer[MAX_ITEM_NAME_LEN + 64];

    PLSPlayerRole playerRole = player.Role,
                  requiredRole;

    int x;
    LOOP_ITEMS( item )
    {
        iRequiredLevel = item.GetAttrValue( OVERRIDE_LVL_ATTR, item.RequiredLevel );
        requiredRole = item.RequiredRole;
        for ( x = iStartLVL; x <= iCurrentLVL; ++x )
        {
            if ( iRequiredLevel == x
                 && playerRole >= requiredRole
                 && !item.HasFlags( ITEMFLAG_LVLUPHIDDEN ) )
            {
                _GetItemName( item, _, szBuffer, MAX_ITEM_NAME_LEN, .nTranslateTo = player );
                Format( STR_OUT( szBuffer ), "[%T] %s", "MENU_UNLOCK_STORE_ITEM", player, szBuffer );
                hMenu.AddItem( "", szBuffer, ITEMDRAW_DISABLED );
            }
        }
    }
}

This one is in the separate .sp file.

// these are from separate inc file
#define cast(%0,%1) view_as<%0>(%1)
#define _INT(%0) view_as<int>(%0)

#define THIS_INDEX _INT( this )
#define ITEM(%0)    cast( IBaseItem, %0 )

methodmap IBaseItem
{
    public IBaseItem(int iIndex)
    {
        return ITEM( iIndex );
    }

    public static IBaseItem FindById(int id)
    {
        return ITEM( g_hItemsTable.FindValue( id, Item_t::Id ) );
    }
    public static IBaseItem FindByToken(const char[] szToken)
    {
        return ITEM( g_hItemsTable.FindStringEx( szToken, sizeof Item_t::Token, Item_t::Token ) );
    }

    property int Index
    {
        public get()
        {
            return THIS_INDEX;
        }
    }

    property int Id
    {
        public get()
        {
            return g_hItemsTable.Get( THIS_INDEX, Item_t::Id );
        }
    }

    // ...

Let me know if you need more code snippets.

Expected behaviour

IntelliSense should show info about what's your cursor is pointing to and colors shouldn't be like that mess.

Error messages

None.

Sarrus1 commented 5 months ago

This is caused by expanded macros. It is on the roadmap to be fixed in feat/salsa.