Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with variants and named types #15

Open
rm-code opened this issue Apr 30, 2017 · 2 comments
Open

Problem with variants and named types #15

rm-code opened this issue Apr 30, 2017 · 2 comments

Comments

@rm-code
Copy link
Contributor

rm-code commented Apr 30, 2017

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

@dapetcu21
Copy link
Owner

Yup. This is not currently supported by this package. But this would be an interesting feature to have. I'll leave this issue open and maybe look into it at some point.

rm-code added a commit to rm-code/love-atom that referenced this issue Apr 30, 2017
Currently atom-autocomplete-lua doesn't support the definition of
returnTypes inside of function variants which caused the autocompletion
for some variables to fail.

This commit is a workaround until the issue has been resolved.

@see dapetcu21/atom-autocomplete-lua#15

Closes #9.
@rm-code
Copy link
Contributor Author

rm-code commented Apr 30, 2017

Thanks 👍

For now I just moved the returnTypes definition outside of the variants as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants