Skip to content

Problem with variants and named types #15

@rm-code

Description

@rm-code

Hi @dapetcu21,

I'm currently rewriting my love-atom package to work with atom-autocomplete-lua and I've run into a small into issue with the return types of function variants.

Below is an example of how my JSON file is formatted:

"newImageData":{
   "type":"function",
   "description":"Create a new ImageData object.",
   "link":"https://love2d.org/wiki/love.image.newImageData",
   "variants":[
      {
         "args":[
            {
               "name":"width"
            },
            {
               "name":"height"
            }
         ],
         "returnTypes":[
            {
               "type":"ref",
               "name":"ImageData"
            }
         ]
      },
      {
         "args":[
            {
               "name":"width"
            },
            {
               "name":"height"
            },
            {
               "name":"data"
            }
         ],
         "returnTypes":[
            {
               "type":"ref",
               "name":"ImageData"
            }
         ]
      },
      {
         "args":[
            {
               "name":"filename"
            }
         ],
         "returnTypes":[
            {
               "type":"ref",
               "name":"ImageData"
            }
         ]
      },
      {
         "args":[
            {
               "name":"filedata"
            }
         ],
         "returnTypes":[
            {
               "type":"ref",
               "name":"ImageData"
            }
         ]
      }
   ]
},

As you can see the returnTypes are inside of the variants table and atom-autocomplete-lua doesn't resolve them correctly.

When I write local foo = love.graphics.newImageData(), foo doesn't have any method suggestions.

It works fine for functions without variants:

"newText":{
   "type":"function",
   "description":"Creates a new Font.",
   "args":[
      {
         "name":"font"
      },
      {
         "displayName":"[textstring]",
         "name":"textstring"
      }
   ],
   "returnTypes":[
      {
         "type":"ref",
         "name":"Text"
      }
   ],
   "link":"https://love2d.org/wiki/love.graphics.newText"
},

In this case (local foo = love.graphics.newText()), foo is correctly marked as an object of type Text.

As far as I know there are some functions in the LÖVE API whose variants have different returnTypes so I can't simply move them outside of the variant definition.

Is there something I am missing, or is this not supported by your package?

Best wishes, Robert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions