summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-07 00:35:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-07 00:35:24 +0800
commit7c9503e0f1d2566a9a6df9f5c309af48972cabb3 (patch)
treee5d6c5bf2fa9491218fa84fd5dcb78906d5e2742 /script
parent01a09c66af04ab3e37d02782721c20bff8092e15 (diff)
downloadlua-language-server-7c9503e0f1d2566a9a6df9f5c309af48972cabb3.zip
add meta file for `bee.filesystem`
Diffstat (limited to 'script')
-rw-r--r--script/fs-utility.lua10
-rw-r--r--script/library.lua7
-rw-r--r--script/meta/bee/filesystem.lua28
-rw-r--r--script/version.lua2
4 files changed, 38 insertions, 9 deletions
diff --git a/script/fs-utility.lua b/script/fs-utility.lua
index 3581bd50..fec862e2 100644
--- a/script/fs-utility.lua
+++ b/script/fs-utility.lua
@@ -13,9 +13,6 @@ local tableSort = table.sort
_ENV = nil
----@class fspath
----@field string fun(self):string
-
---@class fs-utility
local m = {}
--- 读取文件
@@ -465,7 +462,7 @@ local function fileCopy(source, target, option)
if isDir2 or fsCreateDirectories(target, option) then
for filePath in fsPairs(source) do
local name = filePath:filename():string()
- fileCopy(filePath, target / name--[[@as fspath]], option)
+ fileCopy(filePath, target / name, option)
end
end
else
@@ -487,6 +484,9 @@ local function fileCopy(source, target, option)
end
end
+---@param source fspath?
+---@param target fspath?
+---@param option table
local function fileSync(source, target, option)
if not source or not target then
return
@@ -516,7 +516,7 @@ local function fileSync(source, target, option)
if fsCreateDirectories(target) then
for filePath in fsPairs(source) do
local name = filePath:filename():string()
- fileCopy(filePath, target / name--[[@as fspath]], option)
+ fileCopy(filePath, target / name, option)
end
end
end
diff --git a/script/library.lua b/script/library.lua
index a2a1bb87..d0294650 100644
--- a/script/library.lua
+++ b/script/library.lua
@@ -214,7 +214,7 @@ local function initBuiltIn(uri)
version = version,
language = langID,
encoding = encoding,
- })--[[@as fspath]]
+ })
local metaLang = loadMetaLocale('en-US')
if langID ~= 'en-US' then
@@ -245,7 +245,7 @@ local function initBuiltIn(uri)
end
libName = libName .. '.lua'
---@type fspath
- local libPath = templateDir / libName--[[@as fspath]]
+ local libPath = templateDir / libName
local metaDoc = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status)
if metaDoc then
metaDoc = encoder.encode(encoding, metaDoc, 'auto')
@@ -262,8 +262,9 @@ local function initBuiltIn(uri)
end
end
+---@param libraryDir fspath
local function loadSingle3rdConfig(libraryDir)
- local configText = fsu.loadFile(libraryDir / 'config.lua'--[[@as fspath]])
+ local configText = fsu.loadFile(libraryDir / 'config.lua')
if not configText then
return nil
end
diff --git a/script/meta/bee/filesystem.lua b/script/meta/bee/filesystem.lua
new file mode 100644
index 00000000..54c17c37
--- /dev/null
+++ b/script/meta/bee/filesystem.lua
@@ -0,0 +1,28 @@
+---@class fspath
+---@operator div: fspath
+local fsPath = {}
+
+---@return string
+function fsPath:string()
+end
+
+---@return fspath
+function fsPath:parent_path()
+end
+
+---@return boolean
+function fsPath:is_relative()
+end
+
+---@return fspath
+function fsPath:filename()
+end
+
+local fs = {}
+
+---@param path string
+---@return fspath
+function fs.path(path)
+end
+
+return fs
diff --git a/script/version.lua b/script/version.lua
index f5cf5304..fa178564 100644
--- a/script/version.lua
+++ b/script/version.lua
@@ -1,7 +1,7 @@
local fsu = require 'fs-utility'
local function loadVersion()
- local changelog = fsu.loadFile(ROOT / 'changelog.md'--[[@as fspath]])
+ local changelog = fsu.loadFile(ROOT / 'changelog.md')
if not changelog then
return
end