summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/code-action.lua5
-rw-r--r--script/core/command/autoRequire.lua2
-rw-r--r--script/core/command/removeSpace.lua2
-rw-r--r--script/core/command/solve.lua2
-rw-r--r--script/core/completion/completion.lua3
-rw-r--r--script/core/diagnostics/ambiguity-1.lua4
-rw-r--r--script/core/diagnostics/newfield-call.lua8
-rw-r--r--script/core/diagnostics/newline-call.lua2
-rw-r--r--script/core/diagnostics/trailing-space.lua4
-rw-r--r--script/core/rename.lua3
-rw-r--r--script/core/signature.lua3
-rw-r--r--script/core/type-formatting.lua8
12 files changed, 32 insertions, 14 deletions
diff --git a/script/core/code-action.lua b/script/core/code-action.lua
index f9926b64..4eb21ff8 100644
--- a/script/core/code-action.lua
+++ b/script/core/code-action.lua
@@ -451,7 +451,7 @@ end
local function checkSwapParams(results, uri, start, finish)
local state = files.getState(uri)
local text = files.getText(uri)
- if not state then
+ if not state or not text then
return
end
local args = {}
@@ -619,6 +619,9 @@ end
local function checkJsonToLua(results, uri, start, finish)
local text = files.getText(uri)
local state = files.getState(uri)
+ if not state or not text then
+ return
+ end
local startOffset = guide.positionToOffset(state, start)
local finishOffset = guide.positionToOffset(state, finish)
local jsonStart = text:match('()[%{%[]', startOffset + 1)
diff --git a/script/core/command/autoRequire.lua b/script/core/command/autoRequire.lua
index 923c6f11..020cacae 100644
--- a/script/core/command/autoRequire.lua
+++ b/script/core/command/autoRequire.lua
@@ -21,7 +21,7 @@ end
local function findInsertRow(uri)
local text = files.getText(uri)
local state = files.getState(uri)
- if not state then
+ if not state or not text then
return
end
local lines = state.lines
diff --git a/script/core/command/removeSpace.lua b/script/core/command/removeSpace.lua
index aa565f7f..69a01b53 100644
--- a/script/core/command/removeSpace.lua
+++ b/script/core/command/removeSpace.lua
@@ -17,7 +17,7 @@ return function (data)
local uri = data.uri
local text = files.getText(uri)
local state = files.getState(uri)
- if not state then
+ if not state or not text then
return
end
diff --git a/script/core/command/solve.lua b/script/core/command/solve.lua
index 8065aa9d..98ceaa58 100644
--- a/script/core/command/solve.lua
+++ b/script/core/command/solve.lua
@@ -32,7 +32,7 @@ return function (data)
local uri = data.uri
local text = files.getText(uri)
local state = files.getState(uri)
- if not state then
+ if not state or not text then
return
end
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 4fc63962..2f0180d2 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -66,6 +66,9 @@ end
local function findNearestTableField(state, position)
local uri = state.uri
local text = files.getText(uri)
+ if not text then
+ return nil
+ end
local offset = guide.positionToOffset(state, position)
local soffset = lookBackward.findAnyOffset(text, offset)
if not soffset then
diff --git a/script/core/diagnostics/ambiguity-1.lua b/script/core/diagnostics/ambiguity-1.lua
index f03f4361..830b2f2f 100644
--- a/script/core/diagnostics/ambiguity-1.lua
+++ b/script/core/diagnostics/ambiguity-1.lua
@@ -27,10 +27,10 @@ local literalMap = {
return function (uri, callback)
local state = files.getState(uri)
- if not state then
+ local text = files.getText(uri)
+ if not state or not text then
return
end
- local text = files.getText(uri)
guide.eachSourceType(state.ast, 'binary', function (source)
if source.op.type ~= 'or' then
return
diff --git a/script/core/diagnostics/newfield-call.lua b/script/core/diagnostics/newfield-call.lua
index 669ed2bb..b81d8c0a 100644
--- a/script/core/diagnostics/newfield-call.lua
+++ b/script/core/diagnostics/newfield-call.lua
@@ -3,14 +3,14 @@ local guide = require 'parser.guide'
local lang = require 'language'
return function (uri, callback)
- local ast = files.getState(uri)
- if not ast then
+ local state = files.getState(uri)
+ local text = files.getText(uri)
+ if not state or not text then
return
end
- local text = files.getText(uri)
- guide.eachSourceType(ast.ast, 'table', function (source)
+ guide.eachSourceType(state.ast, 'table', function (source)
for i = 1, #source do
local field = source[i]
if field.type ~= 'tableexp' then
diff --git a/script/core/diagnostics/newline-call.lua b/script/core/diagnostics/newline-call.lua
index 3f2d5ca5..9c526980 100644
--- a/script/core/diagnostics/newline-call.lua
+++ b/script/core/diagnostics/newline-call.lua
@@ -5,7 +5,7 @@ local lang = require 'language'
return function (uri, callback)
local state = files.getState(uri)
local text = files.getText(uri)
- if not state then
+ if not state or not text then
return
end
diff --git a/script/core/diagnostics/trailing-space.lua b/script/core/diagnostics/trailing-space.lua
index cc51cf77..d23b0692 100644
--- a/script/core/diagnostics/trailing-space.lua
+++ b/script/core/diagnostics/trailing-space.lua
@@ -14,10 +14,10 @@ end
return function (uri, callback)
local state = files.getState(uri)
- if not state then
+ local text = files.getText(uri)
+ if not state or not text then
return
end
- local text = files.getText(uri)
local lines = state.lines
for i = 0, #lines do
local startOffset = lines[i]
diff --git a/script/core/rename.lua b/script/core/rename.lua
index c3325b7e..85cbab52 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -81,6 +81,9 @@ local function renameField(source, newname, callback)
local uri = guide.getUri(source)
local text = files.getText(uri)
local state = files.getState(uri)
+ if not state or not text then
+ return false
+ end
local func = parent.value
-- function mt:name () end --> mt['newname'] = function (self) end
local startOffset = guide.positionToOffset(state, parent.start) + 1
diff --git a/script/core/signature.lua b/script/core/signature.lua
index 025e70b7..f5de90d5 100644
--- a/script/core/signature.lua
+++ b/script/core/signature.lua
@@ -8,6 +8,9 @@ local lookback = require 'core.look-backward'
local function findNearCall(uri, ast, pos)
local text = files.getText(uri)
local state = files.getState(uri)
+ if not state or not text then
+ return nil
+ end
local nearCall
guide.eachSourceContain(ast.ast, pos, function (src)
if src.type == 'call'
diff --git a/script/core/type-formatting.lua b/script/core/type-formatting.lua
index 7005af26..0c326b8b 100644
--- a/script/core/type-formatting.lua
+++ b/script/core/type-formatting.lua
@@ -6,7 +6,7 @@ local function insertIndentation(uri, position, edits)
local text = files.getText(uri)
local state = files.getState(uri)
local row = guide.rowColOf(position)
- if not state then
+ if not state or not text then
return
end
local offset = state.lines[row]
@@ -19,6 +19,9 @@ end
local function findForward(uri, position, ...)
local text = files.getText(uri)
local state = files.getState(uri)
+ if not state or not text then
+ return nil
+ end
local offset = guide.positionToOffset(state, position)
local firstOffset = text:match('^[ \t]*()', offset + 1)
if not firstOffset then
@@ -35,6 +38,9 @@ end
local function findBackward(uri, position, ...)
local text = files.getText(uri)
local state = files.getState(uri)
+ if not state or not text then
+ return nil
+ end
local offset = guide.positionToOffset(state, position)
local lastOffset = lookBackward.findAnyOffset(text, offset)
for _, symbol in ipairs { ... } do