Closed ssatguru closed 8 years ago
Hello ssatguru, I will take a look at it. Do you use the Eclipse plugin or the maven plugin?
Thanks for your help
I finally fixed this issue, see PR https://github.com/cincheo/jsweet/pull/77
I installed my branch of jsweet locally and the following example runs without any problem :) https://github.com/lgrignon/jsweet-jqueryui-example
Now we juste have to wait for @renaudpawlak to integrate the PR and deploy the Jar on maven ;)
Regards.
Hi Igrignon,
Thanks for fixing this. I will check it out when it is available. As a workaround I am doing the following now :)
Object obj = $("#myMenu");
JQuery jq = (JQuery) obj;
jq.menu();
As far as Eclipse or Maven Plugin , I normally use Maven Plugin. I do use eclipse as my IDE though.
Thanks
Hi! I have merged the PR. Thanks a lot. Tell us if it works now.
Is the fix available in the maven repo?
Hi Satguru,
I think that we have not been clear enough about the issue. In theory, the candies are fine, so the fix was only in the transpiler (version 1.1.0-SNAPSHOT), not in the candies.
JSweet defines the notion of a mixin. Your case is typically a mixin. The class def,jqueryui,JQuery
actually mixins to def.jquery.JQuery
(see the annotation in the source code), which means that the transpiler processes the bytecode to mix together the two JQuery
classes with a bytecode manipulation tool called Javassist (created by Chiba).
There was a bug in mixins in the case of JQuery plugins. In theory, it was fixed by Louis. That said, I am in vacation and did not have the occasion to actually test it. If you don't really have time to test it, just proceed with your workaround, and I will test it ASAP.
1.1.0-SNAPSHOT did not work for me. I also tested by building the transpiler myself but that didn't help either. But that's fine. The workaround is pretty straightforward. So I will continue using that for now. Apart from this issue both jquery and jqueryui are working out great :)
Thanks @renaudpawlak for the explanation.
@ssatguru
1) Are you sure you forced the transpiler artifact to be updated?
You could check the version and build time with verbose option enabled, search for
INFO JSweetTranspiler:206 - creating transpiler version
in your logs. Your build date should be something like today :)
2) Are you sure your candies where properly cleaned?
Indeed, candies are not reevaluated if neither the artifact list nor their versions change between two build. I recommand that you use mvn jsweet:clean
before building.
Please tell us if the problem persists. It could reveal something wrong. I hope it will work.
Ok, I see what's happening. The Transpiler does not complain. It is the Eclipse Editor which complains. If marks "$("#myMenu).menu();" in red with error message "The method menu() is undefined for the type JQuery(). The Java compiler doesnot like it.
I am still working on some side effects of this issue, but it actually should be already working for your case.
Since you are not using the Eclipse plugin (well, it is not that stable yet ;)), it means that you have to manually tell Eclipse where to find the processed mixins so that it can compile your project right. It is fairly easy to do.
.jsweet/candies/processed
directory to you build path..jsweet/candies/processed
appears at the top of the list (or at least before the Maven dependencies)This should solve your compilation problem in Eclipse (and it would be similar for other IDEs).
To configure the build path: right-click on the project > Build path > Configure build path... > Libraries (tab) > Add class folder (button)
Yes, that did the trick :) I think we should be able to accomplish this with maven pom, using the maven , eclipse m2e, lifecycle-mapping artifact. I will look into that and report if I find something.
That would be a good trick indeed. Tell us if you find something. For information, I enhanced the documentation thanks to your feedback: https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md#bridging-to-external-javascript-elements.
Thanks :D
That's great. Documentation always welcome. One correction might be required Per document "Note that ambient classes constructors cannot have a body." But int the example you provided the constructor has a body. Also I was able to transpile successfully with an empty constructor body.
Trying to use the jquery and jqueryui candy
I haven;t been able to get it working.
Something like $("#myMenu).menu(); does not work
Might have something to do with the way JQuery class has been defined
In JQuery candy, class "JQuery" has been defined as def.jquery.JQuery
in JQueryUi candy it has been defined as def,jqueryui,JQuery