Giter Club home page Giter Club logo

Comments (7)

pablomayobre avatar pablomayobre commented on September 26, 2024 1

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.

liwangqian avatar liwangqian commented on September 26, 2024

可以增加一个配置,声明全局加载的lua文件,并且这些文件中的符号是全局导出的,所有其他lua脚本都可以直接引用而无需require。

你说的这种思路,由于需要层层遍历解析所有LUA脚本,性能上可能会差一些,当前的实现是尽可能少地解析lua脚本,按require依赖进行解析,并且只解析一层require,防止递归导致的性能爆炸。

from luacoderassist.

pablomayobre avatar pablomayobre commented on September 26, 2024

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.

ltccss avatar ltccss commented on September 26, 2024

emmm...
可能我们对于依赖关系的侧重点不同
增加全局配置固然可以解决一些问题
但是这样子做并不能很好地检测出某些代码在运行时因为依赖文件没有加载而导致的问题(参考java相关的IDE会检测出import问题并且提供方便的辅助import功能)
并且对于开发本身来说,手动添加全局配置非常麻烦,看上去也不利于多人协作
此外有时候比如两个lua文件相互依赖,如果两个文件中都显式地require对方,那么运行时会遇到require嵌套的错误,这个时候除了配置全局参数,可能目前的解析方法也是不太合适的?
参考隔壁c#的$官方插件,
emmm,看上去c#只有在使用不同命名空间内的数据时需要声明下命名空间,
我没看过它的实现,但目测应该也是需要遍历整个项目的文件才能知道某个变量在整个项目中的引用情况吧?
性能我倒是觉得,层层遍历并不需要立刻得到结果,哪怕用VS打开c#工程,在机器性能不好的情况下也是要等半天才显示出对应的信息的

from luacoderassist.

ltccss avatar ltccss commented on September 26, 2024

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.

liwangqian avatar liwangqian commented on September 26, 2024

在我工作的环境里,我们编写的lua脚本并不能直接运行,需要在目标机器中才能跑起来,因此,在这样的环境下,很多问题都只能通过运行时发现。

from luacoderassist.

ltccss avatar ltccss commented on September 26, 2024

呃,我这边是做游戏开发,之前其实一直用c#,后来转的lua,因为有这个前后对比,本来很多问题原先编辑期就可以解决的,现在就不得不在运行中发现,而且使用下来感觉对于刚接触lua的人来说,什么样的奇葩问题都会遇到,并且不会报出显示并直接的错误警告,debug起来很心塞,感觉效率好低下:(
尤其是有些逻辑测试起来挺蛋疼的,比如要打赢X场战斗才能触发,结果死活打不赢哈哈,有时候就很讨厌运行中测试,因为测一次就得打一次,或者得花费时间额外写一下跳过战斗的代码

from luacoderassist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.