Skip to content

[CLOSED] JSUtils modification to handle es6 constructs #11458

Open
@core-ai-bot

Description

@core-ai-bot

Issue by swmitra
Wednesday Aug 23, 2017 at 19:02 GMT
Originally opened as adobe/brackets#13635


This PR will replace the existing regex based function def extraction with Acorn and also adds the capability to identify classes and methods (es6). Our current implementations is having some limitations and issues. One issue which is noticed during my dev test is wrong location information for function definition. Consider the following snippet -

Handsome.prototype.some = function () {
}

From the function/type list when we select some, instead of highlighting the member "some" , "some" from Handsome gets highlighted. With the new implementation, this issue is resolved as we get location information from the AST generated by Acorn.

Couple of other observations which are actually open questions to all reviewers, there are some odd syntax which is considered valid in our current regex based implementation. Consider the following snippets -

something: function () {
}
function hello() {
     something: function () {
     }
}   

It has been handled in the new implementation to let the existing tests pass, should we consider this to be valid?

Second observation is regarding a broken syntax for which we have a negative test case(this single test fails in the new implementation), but in the new implementation, Acorn parses it successfully. The snippet in consideration is -

function invalid name () {
}

How do we handle this case?

@zaggino@petetnt@ficristo@MarcelGerber Can you please have a look at this PR?


swmitra included the following code: https://github.com/adobe/brackets/pull/13635/commits

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions