简体   繁体   中英

Nashorn on Visual Studio Code

So, Java's Nashorn engine allows to embed javascript in a java application. Nashorn's javascript has some non-vanilla javascript features, it is possible to write a function litteral like this :

function add(x,y)x+y

Which is the same as function add(x,y){return x+y;}

There is also the for each loop :

for each(var i in myArray) print(i)

I would like to edit the javascript files in Visual studio code. However, for the features above, since they are not vanilla javascript, VSCode detects an error. I couldn't find an extension for visual studio to support Nashorn's javascript.

Is there any way to "extend" the javascript support on visual studio to allow the features above ?

No. You'd need an extension that implements a Nashorn JS language server . VS Code's built-in JS support cannot be extended easily this way

You can suppress these error messages by setting:

 "javascript.validate.enable": false

IntelliSense and other language support will still not work however without a proper language extension

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM