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.
Non-convertible declarations are consumed by transformer
The following code:
var a = 0, b = arr[0];
var c = arr[1];
will be converted into:
var [b, c] = arr;
Declaration of variable a
will disappear.
Usage of more than one analyzer leads to errors
Adding more than one analyzer to the following builder:
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.