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

Completion: list events from [Event] metadata for first argument of addEventListener() calls #362

Open
joshtynjala opened this issue May 7, 2019 · 2 comments

Comments

@joshtynjala
Copy link
Member

joshtynjala commented May 7, 2019

When completion is triggered here:

sprite.addEventListener(
------------------------^ 

The completion engine should recognize that it's an addEventListener() call and add items for each of the events defined with [Event] metadata in the class (and in all superclasses, of course).

Would also make sense for removeEventListener(), hasEventListener(), and willTrigger().

@joshtynjala
Copy link
Member Author

joshtynjala commented May 7, 2019

An event is defined like this:

/**
 * Description goes here.
 *
 * @eventType starling.events.Event.CHANGE
 */
[Event(name="change",type="starling.events.Event")]

@eventType gives us the exact constant to use, but developers are not required to define this asdoc tag. Additionally, the extension cannot currently parse asdoc from SWC files, so @eventType will only be available in raw source code. A more general solution is necessary.

Instead, we'll probably need to guess the constant's name based on the name value from the metadata. Generally, camel case should be turned into all uppercase with _ between words. For example, "addedToStage" becomes ADDED_TO_STAGE.

If the guessed constant name doesn't exist, we should probably just skip it so that completion does not include results that don't actually exist. So, we'll need to get the IClassDefinition from the type value of the metadata, and then check that class has a static constant (IConstantDefinition) with the expected name.

@joshtynjala joshtynjala added this to the v0.20 milestone May 16, 2019
@joshtynjala joshtynjala removed this from the v0.20 milestone Jun 7, 2019
@ylazy
Copy link

ylazy commented Oct 31, 2022

The current version (1.14.1) hasn't supported event listing yet :(

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

No branches or pull requests

2 participants