Coder Social home page Coder Social logo

js-destrukt's People

Contributors

alexvangogen avatar

Watchers

 avatar

js-destrukt's Issues

Add some metrics to determine is it worth to combine assignments or not

If we try to pass the following code to the input:

function foo(arr) {
    var a = arr[0];
    var b = arr[101];
}

we will get:

function foo(arr) {
  var [a, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , b] = arr;
}

So it would be cool to add the feature that will evaluate the adequacy of certain conversion.

Usage of more than one analyzer leads to errors

Adding more than one analyzer to the following builder:

analyzer.addStrategy(JsAssignArrayElementsStrategy())

can cause uncaught exception.

For example, if we add JsAssignArrayElementsStrategy() twice, then we get an error

Exception in thread "main" java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SCRIPT): assigns.js:1:0
[source unknown]
  Parent: NULL
        at com.google.javascript.rhino.Node.replaceWith(Node.java:982)
        at edu.avgogen.destrukt.JsAstTransformer.transform(JsAstTransformer.kt:14)
        at edu.avgogen.destrukt.JsFindDestructiblePattern.runTransformerAndGetResult(JsFindDestructiblePattern.kt:75)
        at edu.avgogen.destrukt.JsFindDestructiblePattern.endSearch(JsFindDestructiblePattern.kt:64)
        at edu.avgogen.destrukt.JsFindDestructiblePattern.exitScope(JsFindDestructiblePattern.kt:57)
        at com.google.javascript.jscomp.NodeTraversal.popScope(NodeTraversal.java:1045)
        at com.google.javascript.jscomp.NodeTraversal.popScope(NodeTraversal.java:1036)
        at com.google.javascript.jscomp.NodeTraversal.traverse(NodeTraversal.java:372)
        at com.google.javascript.jscomp.NodeTraversal.traverse(NodeTraversal.java:381)
        at edu.avgogen.destrukt.JsFindDestructiblePattern.traverse(JsFindDestructiblePattern.kt:25)
        at edu.avgogen.destrukt.cli.CliKt.run(Cli.kt:43)
        at edu.avgogen.destrukt.cli.CliKt.main(Cli.kt:20)
Caused by: java.lang.NullPointerException
        ... 12 more

The reason is that information about nodes detached from AST during previous analysis does not pass to the next analyses, and therefore all of them work with exactly the same set of node references, but different ASTs (AST changes in the end of every analysis), what leads to working with irrelevant nodes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.