-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add originating function info to onLocalDeclaration #49
base: master
Are you sure you want to change the base?
Conversation
I was meaning to do this PR myself when I got time, but I didn't do it yet because I wasn't fully happy with the semantics. For example, I'm not completely happy about the fact that the (Also, there should be tests/docs for this) |
I understand what you mean, I just wanted to start discussion on it! the The other cases where this function is being called:
So I don't see any meaning in passing the Maybe we could use what kind of identifier we are talking about like EDIT: Another thing that could be useful is the location (line, column) of the identifier for that declaration, which is currently not found anywhere |
@@ -1846,7 +1848,10 @@ | |||
if (Identifier === token.type) { | |||
var parameter = parseIdentifier(); | |||
// Function parameters are local. | |||
if (options.scope) scopeIdentifier(parameter); | |||
if (options.scope) scopeIdentifier(parameter, { | |||
parameterOf: name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
contains either a node with the function name or null
(for function expressions); function names, even if present, are themselves subject to scoping and therefore potentially ambiguous. For the originally given use case of code completion, it would be useful to distinguish a local function foo()
defined on line 15 from a function foo()
defined on line 75.
Given that identifiers are always added to the current scope, how about passing metadata identifying the scope to the Labels are already distinguished from variables, by the way; their names are passed with the surrounding |
@fstirlitz That could work. If |
8022c30
to
365842c
Compare
24840d1
to
5015784
Compare
This commit is related to the pull request #38 which added
onLocalDeclaration
, both target the specific use case of dapetcu21/atom-autocomplete-lua.This pull request adds information about the function where the local value is being used, this allows Autocomplete-Lua to check whether the value's type is the expected for said function.
This is of course only necessary for functions so other elements don't pass the optional
data
object.This commit was actually made by @dapetcu21 at dapetcu21/luaparse@5a1fd28 I have only rebased it