From 55b423dbeabb6f04dc5429b362c7cb1f770dac93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 7 Apr 2022 01:10:37 +0800 Subject: update --- test/crossfile/allreferences.lua | 216 ------------------------------------- test/crossfile/init.lua | 1 - test/crossfile/references.lua | 222 ++++++++++++++++++++++++++++++++++----- 3 files changed, 196 insertions(+), 243 deletions(-) delete mode 100644 test/crossfile/allreferences.lua (limited to 'test/crossfile') diff --git a/test/crossfile/allreferences.lua b/test/crossfile/allreferences.lua deleted file mode 100644 index 3507e094..00000000 --- a/test/crossfile/allreferences.lua +++ /dev/null @@ -1,216 +0,0 @@ -local config = require 'config' - -TEST { - { - path = 'a.lua', - content = [[ - local = require 'lib' - ]], - }, - { - path = 'lib.lua', - content = [[ - return () - end!> - ]], - }, -} - -TEST { - { - path = 'a.lua', - content = [[ - local m = {} - function m.<~func~>() - end - return m - ]], - }, - { - path = 'b.lua', - content = [[ - local t = require 'a' - t.() - ]], - }, -} - -TEST { - { - path = 'a.lua', - content = [[ - return <~function () end~> - ]], - }, - { - path = 'b.lua', - content = [[ - local t = require 'a' - ]], - }, - { - path = 'b.lua', - content = [[ - local t = require 'a' - ]], - }, - { - path = 'b.lua', - content = [[ - local t = require 'a' - ]], - }, - { - path = 'b.lua', - content = [[ - local = require 'a' - ]], - }, -} - -TEST { - { - path = 'a.lua', - content = [[ - local function <~f~>() - end - - return { - = , - } - ]] - }, - { - path = 'b.lua', - content = [[ - local t = require 'a' - local = t. - - () - - return { - = , - } - ]] - } -} - -TEST { - { - path = 'a.lua', - content = [[ - local function () - end - - return { - = , - } - ]] - }, - { - path = 'c.lua', - content = [[ - local t = require 'a' - local = t. - - () - - return { - = , - } - ]] - }, - { - path = 'b.lua', - content = [[ - local t = require 'a' - local = t. - - <~f~>() - - return { - = , - } - ]] - } -} - -TEST { - { - path = 'a.lua', - content = [[ - local function <~f~>() - end - - return { - = , - } - ]] - }, - { - path = 'b1.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, - { - path = 'b2.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, - { - path = 'b3.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, - { - path = 'b4.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, - { - path = 'b5.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, - { - path = 'b6.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, - { - path = 'b7.lua', - content = [[ - local t = require 'a' - t.() - ]] - }, -} - -TEST { - { - path = 'a.lua', - content = [[ - local <~t~> = require 'b' - return - ]] - }, - { - path = 'b.lua', - content = [[ - local = require 'a' - return - ]] - }, -} diff --git a/test/crossfile/init.lua b/test/crossfile/init.lua index 1ed2a943..aec9a044 100644 --- a/test/crossfile/init.lua +++ b/test/crossfile/init.lua @@ -1,6 +1,5 @@ require 'crossfile.definition' require 'crossfile.references' -require 'crossfile.allreferences' require 'crossfile.hover' require 'crossfile.completion' require 'crossfile.diagnostic' diff --git a/test/crossfile/references.lua b/test/crossfile/references.lua index 18e9c5f9..9e55c77a 100644 --- a/test/crossfile/references.lua +++ b/test/crossfile/references.lua @@ -68,7 +68,7 @@ function TEST(datas) } end end - if catched['?'] or catched['~'] then + if #catched['?'] > 0 or #catched['~'] > 0 then sourceList = catched['?'] + catched['~'] sourceUri = uri end @@ -100,16 +100,15 @@ end TEST { { - path = 'lib.lua', + path = 'a.lua', content = [[ - return + ROOT = 1 ]], }, { - path = 'a.lua', + path = 'b.lua', content = [[ - local <~f~> = require 'lib' + print(<~ROOT~>) ]], }, } @@ -118,13 +117,13 @@ TEST { { path = 'a.lua', content = [[ - = 1 + = 1 ]], }, { path = 'b.lua', content = [[ - print(<~ROOT~>) + print() ]], }, } @@ -133,15 +132,41 @@ TEST { { path = 'a.lua', content = [[ - <~ROOT~> = 1 - ]], + ---@type A + local t + + t.() + ]] }, { path = 'b.lua', content = [[ - print() - ]], + ---@class A + local mt + + function mt.() + end + ]] + } +} + +TEST { + { + path = 'a.lua', + content = [[ + local t = {} + t. = 1 + return t + ]] }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + + print(t.) + ]] + } } TEST { @@ -149,14 +174,13 @@ TEST { path = 'a.lua', content = [[ local f = require 'lib' - local <~o~> = f() + () ]], }, { path = 'lib.lua', content = [[ - return function () - return + return () end ]], }, @@ -166,20 +190,78 @@ TEST { { path = 'a.lua', content = [[ - ---@type A - local t + local m = {} + function m.() + end + return m + ]], + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + t.() + ]], + }, +} - t.() - ]] +TEST { + { + path = 'a.lua', + content = [[ + return () end + ]], }, { path = 'b.lua', content = [[ - ---@class A - local mt + local t = require 'a' + ]], + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + ]], + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + ]], + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + () + ]], + }, +} - function mt.<~f~>() +TEST { + { + path = 'a.lua', + content = [[ + local function () end + + return { + f = , + } + ]] + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + local f = t.f + + f() + + return { + f = f, + } ]] } } @@ -188,17 +270,105 @@ TEST { { path = 'a.lua', content = [[ - local t = {} - t.<~x~> = 1 - return t + local f() + end + + return { + f = f, + } ]] }, { path = 'b.lua', content = [[ local t = require 'a' + local f = t.f - print(t.) + () + + return { + f = f, + } ]] } } + +TEST { + { + path = 'a.lua', + content = [[ + local f() + end + + return { + f = f, + } + ]] + }, + { + path = 'b1.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, + { + path = 'b2.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, + { + path = 'b3.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, + { + path = 'b4.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, + { + path = 'b5.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, + { + path = 'b6.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, + { + path = 'b7.lua', + content = [[ + local t = require 'a' + t.() + ]] + }, +} + +TEST { + { + path = 'a.lua', + content = [[ + local = require 'b' + return + ]] + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + return t + ]] + }, +} -- cgit v1.2.3