EmmyLua / VSCode-EmmyLua

Lua IDE/Debugger Plugin for VSCode
641 stars 95 forks source link

新版本一些问题 #147

Closed 37wjy closed 6 months ago

37wjy commented 6 months ago

项目的主要文件在 asset/lua 下, 有一些class的定义放在 .vscode 下, 其中根目录, asset/lua 被分别添加到同一工作区, 旧版本(v0.6.18)不会提示在 asset/lua 中的脚本中的某些被定义在 .vscode 中的变量不存在, 如 CS这个, 而新版本会

CppCXY commented 6 months ago

新版本再分析时会直接排除.vscode目录中的文件

37wjy commented 6 months ago

请问是加了分析文件大小的限制吗, 我把文件删小了后, 这个全局变量就不提示不存在了

CppCXY commented 6 months ago

文件大小限制是1mb, 以及如果在排除目录中会在手动打开文件时解析一次, 你可以通过配置设置这些, 具体看changelog

37wjy commented 6 months ago

解决了,

新加的注释功能感觉很好,

---@generic T
---@param classname `T`
---@return T

但是一般项目中也会用这种形式用于继承

Class("classname", base)

希望可以有类似的支持

---@generic T, B
---@param classname `T`
---@param base B
---@return T:B
function Class(classname, base) end
CppCXY commented 6 months ago

这个功能不是为了实现class函数而做的, 因为没有显式的定义类型会找不到类型定义, 类型补全也不会有他

37wjy commented 6 months ago

还有一些问题, 项目中lua的require路径不是从Asset开始的, 我在中配置了

        "workspaceRoots": [
            "Assets/LuaScripts"
        ],

但是提示依然会从 assets开始, 并且require 了省略这个路径的文件也无法被跳转了.

lua里支持小数用 .1 这种形式, 目前的插件会提示

截屏2024-05-22 16 36 31

还有, 有时候会crash

[Error - 16:33:41] Delivering pending changes failed
TypeError: this.task is not a function
    at /Users/wjy/.vscode/extensions/tangzx.emmylua-0.7.1-darwin-arm64/node_modules/vscode-languageclient/lib/common/utils/async.js:28:35
Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: LuaDocumentId { Id = 414, IsVirtual = False }
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at EmmyLua.CodeAnalysis.Workspace.Module.ModuleGraph.AddDocument(ModuleNode root, String workspace, LuaDocument document) in /Users/runner/work/EmmyLuaAnalyzer/EmmyLuaAnalyzer/EmmyLua/CodeAnalysis/Workspace/Module/ModuleGraph.cs:line 92
   at EmmyLua.CodeAnalysis.Workspace.Module.ModuleGraph.AddDocuments(List`1 documents) in /Users/runner/work/EmmyLuaAnalyzer/EmmyLuaAnalyzer/EmmyLua/CodeAnalysis/Workspace/Module/ModuleGraph.cs:line 63
   at EmmyLua.CodeAnalysis.Workspace.LuaWorkspace.LoadMainWorkspace(String workspace) in /Users/runner/work/EmmyLuaAnalyzer/EmmyLuaAnalyzer/EmmyLua/CodeAnalysis/Workspace/LuaWorkspace.cs:line 145
   at EmmyLua.LanguageServer.Server.ServerContext.StartServer(String workspacePath) in /Users/runner/work/EmmyLuaAnalyzer/EmmyLuaAnalyzer/EmmyLua.LanguageServer/Server/ServerContext.cs:line 43
   at Program.<>c__DisplayClass0_1.<<Main>$>b__4(ILanguageServer server, CancellationToken _) in /Users/runner/work/EmmyLuaAnalyzer/EmmyLuaAnalyzer/EmmyLua.LanguageServer/LanguageServer.cs:line 102
   at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.<Initialize>b__80_0(OnLanguageServerStartedDelegate handler, CancellationToken ct)
   at OmniSharp.Extensions.LanguageServer.Protocol.LanguageProtocolEventingHelper.<>c__DisplayClass0_1`2.<Run>b__2(CancellationToken ct)
   at System.Reactive.Linq.QueryLanguage.StartAsyncImpl(Func`2 actionAsync, Value& options)
--- End of stack trace from previous location ---
   at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.Initialize(CancellationToken token)
   at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.From(LanguageServerOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
   at Program.<Main>$(String[] args) in /Users/runner/work/EmmyLuaAnalyzer/EmmyLuaAnalyzer/EmmyLua.LanguageServer/LanguageServer.cs:line 37
   at Program.<Main>(String[] args)
[Error - 16:33:42] Server process exited with signal SIGABRT.
[Error - 16:33:42] The EmmyLua plugin for vscode. server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
CppCXY commented 6 months ago

崩溃的原因应该是library在项目内, 然后dictionary因为key重复异常了

CppCXY commented 6 months ago

image 我这样配置是有效的

37wjy commented 6 months ago

解决了, 我之前因为配了lib, crash了所以没成

希望配置文件后面可以放到.vscode下, 或者整合到setting里

37wjy commented 6 months ago

注释有点bug

    ---@type Transform
    self.transform = nil         --- aaa
    ---@type GameObject
    self.gameObject = nil          --- gameObject
    ---@type RectTransform
    self.rectTransform = nil  

这段代码会提示self.gameObject 的类型是RectTransform

    ---@type Transform
    self.transform = nil        
    ---@type GameObject
    self.gameObject = nil          --- gameObject
    ---@type RectTransform
    self.rectTransform = nil  

这个不会

    ---@type Transform
    self.transform = nil      ---aaa

    ---@type GameObject
    self.gameObject = nil          --- gameObject
    ---@type RectTransform
    self.rectTransform = nil     

这个也不会

截屏2024-05-22 18 54 26

v0.7.1

37wjy commented 6 months ago
截屏2024-05-23 10 37 40

这种提示刷新也有点问题, 就算改完,在git上提交了, 依旧会出现, 点了提示后会跳到git提交前的文件, 只有关了vscode, 重启服务才能解决

37wjy commented 6 months ago

旧版本 使用

---@class AAA
local AAA = Class("AAA")

local a = AAA()

可以将a识别为AAA这个类型, 新版本不行, 而且没发提示__call

CppCXY commented 6 months ago

https://github.com/CppCXY/EmmyLuaAnalyzer/issues 我建议你每个问题发一个issue到这里