Comments (7)
Well doing so will probably result in an over-engineering of static analysis, since what you basically want is to execute the code to see if there are dependency loops, and global overrides and such, which would be nearly impossible to detect unless you actually run the code.
Also please remember that Java and C# are both Static, Typed languages, while Lua is Dynamic, non-typed language, which means that C# and Java can make assumptions about what will happen in the code and what is the order of execution, it also means that imports are generally static and can be analyzed without a full analysis being needed.
I suggest that you use an extra debugging mechanism, possibly live coding, watch expressions and step through code in order to debug your code in runtime, this will help catch errors that this plugin can't catch.
Regarding suggestions it would be really hard for the code to find this loops, floating globals, and such, so for this cases, it's better for the package to fail than to give a wrong answer.
PS: Sorry for writing in English when you speak Chinese, I'm relying on Google translator to understand the messages you both post (and have successfully understood them) but I would rather not do the same to translate mines from English to Chinese so that they don't look like garbage
from luacoderassist.
可以增加一个配置,声明全局加载的lua文件,并且这些文件中的符号是全局导出的,所有其他lua脚本都可以直接引用而无需require。
你说的这种思路,由于需要层层遍历解析所有LUA脚本,性能上可能会差一些,当前的实现是尽可能少地解析lua脚本,按require依赖进行解析,并且只解析一层require,防止递归导致的性能爆炸。
from luacoderassist.
This could potentially be fixed through a specific type of comment like --luacoder: require ./A.lua
or such.
Or maybe through a configuration file of pre-loaded modules which would be analyzed and stored in a cache which would then be used as the global scope for other files.
Also note that a similar behavior would be needed to implement #22 which would allow to aggregate the global scope through .luacompleterc
files.
from luacoderassist.
emmm...
可能我们对于依赖关系的侧重点不同
增加全局配置固然可以解决一些问题
但是这样子做并不能很好地检测出某些代码在运行时因为依赖文件没有加载而导致的问题(参考java相关的IDE会检测出import问题并且提供方便的辅助import功能)
并且对于开发本身来说,手动添加全局配置非常麻烦,看上去也不利于多人协作
此外有时候比如两个lua文件相互依赖,如果两个文件中都显式地require对方,那么运行时会遇到require嵌套的错误,这个时候除了配置全局参数,可能目前的解析方法也是不太合适的?
参考隔壁c#的$官方插件,
emmm,看上去c#只有在使用不同命名空间内的数据时需要声明下命名空间,
我没看过它的实现,但目测应该也是需要遍历整个项目的文件才能知道某个变量在整个项目中的引用情况吧?
性能我倒是觉得,层层遍历并不需要立刻得到结果,哪怕用VS打开c#工程,在机器性能不好的情况下也是要等半天才显示出对应的信息的
from luacoderassist.
WOW, I am surprised that you are not a Chinese user but have a good reading comprehension(though it depends on google)
But what I mean is not to focus on the whole execution of almost all the lua files, but to make a simple check of dependency of each lua file, even it can not be too precise due to the fact that lua is Dynamic
The situation I'm facing with while writing lua with this plugin is that too many invalid warnings about dependency showed in the screen ,and it makes me crazy to find thoese real problems.
Some of the invalid warnings are caused by thoese APIs provided in other lib or language, which is probably you've mentioned in another issue;
and others are caused by the current plugin design for how it finds required files.
To some extent, I can use the global config as you suggested to avoid the problem,
but I hold the point of view that it is NOT a pleasing idea because it seems I should to check whether to update some configs every time when I write a new lua script? Not to mention the usage in a team
from luacoderassist.
在我工作的环境里,我们编写的lua脚本并不能直接运行,需要在目标机器中才能跑起来,因此,在这样的环境下,很多问题都只能通过运行时发现。
from luacoderassist.
呃,我这边是做游戏开发,之前其实一直用c#,后来转的lua,因为有这个前后对比,本来很多问题原先编辑期就可以解决的,现在就不得不在运行中发现,而且使用下来感觉对于刚接触lua的人来说,什么样的奇葩问题都会遇到,并且不会报出显示并直接的错误警告,debug起来很心塞,感觉效率好低下:(
尤其是有些逻辑测试起来挺蛋疼的,比如要打赢X场战斗才能触发,结果死活打不赢哈哈,有时候就很讨厌运行中测试,因为测一次就得打一次,或者得花费时间额外写一下跳过战斗的代码
from luacoderassist.
Related Issues (20)
- 好期望能够早日开发出类似EmmyLua的注释标签推断类型的功能呀 HOT 1
- Crash when luacheck is not available HOT 1
- 代码提示失效 HOT 1
- LuaCoderAssist Crash HOT 1
- Extension can't find .luacheckrc in WSL HOT 3
- Crashes after VSCode update HOT 3
- [Feature Request] Ship UNIX luacheck binaries in addition to Windows ones HOT 1
- Luacheck: Automatic Option should be off by default HOT 1
- throw er; // Unhandled 'error' event HOT 1
- 请问后续会不会添加全局变量高亮之类的功能呢?
- ENABLE => Crash by "throw er; // Unhandled 'error' event" ( with VSC 1.57.1 on Windows, LuaCoderAssist v2.3.9 )
- The LuaCoderAssist server crashed 5 times in the last 3 minutes. The server will not be restarted. HOT 2
- Need help : Luacheck doesn't work HOT 3
- 这个报错有点问题: expected ‘=’ near end
- Luacheck continuation
- 请问有没有办法支持自定义的 require呢,这个插件非常好用,其他的都没办法支持metatable的跳转
- Wrong luacheck cwd is used with --config HOT 1
- Cannot find module 'supports-color' HOT 1
- 格式化代码问题 HOT 1
- Typing 'setmetatable' function gives error at console HOT 2
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.
from luacoderassist.