简体   繁体   English

Nashorn在Visual Studio代码上

[英]Nashorn on Visual Studio Code

So, Java's Nashorn engine allows to embed javascript in a java application. 因此,Java的Nashorn引擎允许在javascript应用程序中嵌入javascript。 Nashorn's javascript has some non-vanilla javascript features, it is possible to write a function litteral like this : Nashorn的javascript有一些非vanilla javascript功能,可以写一个像这样的函数:

function add(x,y)x+y

Which is the same as function add(x,y){return x+y;} 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. 我想在Visual Studio代码中编辑javascript文件。 However, for the features above, since they are not vanilla javascript, VSCode detects an error. 但是,对于上述功能,由于它们不是vanilla javascript,VSCode会检测到错误。 I couldn't find an extension for visual studio to support Nashorn's javascript. 我找不到视觉工作室的扩展来支持Nashorn的javascript。

Is there any way to "extend" the javascript support on visual studio to allow the features above ? 有没有办法“扩展”Visual Studio上的javascript支持,以允许上述功能?

No. You'd need an extension that implements a Nashorn JS language server . 不需要。您需要一个实现Nashorn JS 语言服务器的扩展。 VS Code's built-in JS support cannot be extended easily this way VS Code的内置JS支持无法通过这种方式轻松扩展

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 如果没有适当的语言扩展,IntelliSense和其他语言支持仍然无效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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