如何将一些已知对象添加到ace编辑器语法检查器中? [英] How to add some known objects to ace editors syntax checker?

查看:111
本文介绍了如何将一些已知对象添加到ace编辑器语法检查器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用ACE编辑器来编写在服务器端解释的javascript代码.因此,服务器具有JavaScript接口,并且可以执行提交的代码以从外部完成某些任务.

we're using the ACE editor to write javascript code that's interpreted on the server side. So the server has a JavaScript interface and can execute submitted code to accomplish some task from the outside.

服务器实现ACE未知的一些新对象.因此,如果在代码中使用了其中一个未知对象,那么ACE将显示警告.

The server implements some new objects that are not known by ACE. So ACE shows a warning, if one of this unknown objects is used in code.

告诉ACE某些新对象,变量和函数的正确方法是什么?我已经研究了worker-javascript.js,但是我不想重新实现整个过程(更新ACE会比这困难得多).我可以使用任何界面吗?

What is the correct way to tell ACE, that there are some new objects, variables und functions? I already took a look into worker-javascript.js, but I DON'T want to reimplement this whole stuff (updating ACE would get harder than). Is there any interface I can use?

推荐答案

Ace使用jshint,后者具有设置全局变量列表的选项. Ace支持对worker的changeOptions调用,以修改传递给jshint的默认选项,但没有方法来传递全球标语列表

Ace uses jshint, which have an option to set a list of global variables. Ace supports changeOptions call on worker to modify default options it passes to jshint, but doesn't have a way to pass list of gloabals

您可以通过更改并通过您的代码调用

editor.session.$worker.call("changeOptions", [{
   globals: {foo: false, bar: false...},
   undef: true, // enable warnings on undefined variables
   // other jshint options go here check jshint site for more info
}]);

对worker.js#L130的更改非常简单,如果您向ace请求请求,则应该接受

the change to worker.js#L130 is simple enough and should be accepted if you make a pull request to ace

这篇关于如何将一些已知对象添加到ace编辑器语法检查器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆