Skip to content

Commit 8da3f5a

Browse files
committed
优化:新增showFunctionOnly配置,用来控制是否只显示函数符号列表,默认值为false;优化:对于前向声明的函数变量,跳转到函数实现的地方
1 parent 28d9179 commit 8da3f5a

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to the "luacoderassist" extension will be documented in this file.
44

5+
## 2.3.5 @ 2019-9-15
6+
7+
- 优化:新增`showFunctionOnly`配置,用来控制是否只显示函数符号列表,默认值为false
8+
- 优化:对于前向声明的函数变量,跳转到函数实现的地方
9+
510
## 2.3.3 @ 2019-8-11
611

712
- 修复:`pcall(function () ... end)`场景下,`function`函数体内无法提供局部符号表信息和自动补全功能

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "LuaCoderAssist",
44
"description": "lua编程助手,包括代码补全、符号预览&跳转、函数特征帮助、符号类型推导、静态检查、格式化、代码度量等功能",
55
"icon": "images/icon.png",
6-
"version": "2.3.3",
6+
"version": "2.3.5",
77
"publisher": "liwangqian",
88
"engines": {
99
"vscode": "^1.25.0"
@@ -127,6 +127,11 @@
127127
"default": true,
128128
"description": "Show anonymous function in document symbol list."
129129
},
130+
"LuaCoderAssist.symbol.showFunctionOnly": {
131+
"type": "boolean",
132+
"default": false,
133+
"description": "Only function is shown in document symbol list."
134+
},
130135
"LuaCoderAssist.luacheck.enable": {
131136
"type": "boolean",
132137
"default": true,

server/coder.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class Coder {
3232
preloads:[],
3333
useLove: false,
3434
useJit: false,
35+
symbol: {
36+
showAnonymousFunction: true,
37+
showFunctionOnly: false,
38+
},
3539
luaPath:"",
3640
luacheck: {
3741
enable: true,

server/lib/engine/core.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@ function analysis(code, uri) {
294294
const predict = (S) => S.name === name;
295295
let prevDeclare = rootStack.search(predict)
296296
if (prevDeclare) {
297-
// prevDeclare.location = fsymbol.location;
298-
// prevDeclare.range = fsymbol.range;
297+
// 跳到变量定义处
298+
prevDeclare.location = fsymbol.location;
299+
prevDeclare.range = fsymbol.range;
299300
prevDeclare.scope = fsymbol.scope;
300301
prevDeclare.children = fsymbol.children;
301302
prevDeclare.type = ftype;

server/providers/hover-provider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HoverProvider {
2020
let uri = params.textDocument.uri;
2121
let document = yield this.coder.document(uri);
2222
let ref = utils.symbolAtPosition(position, document, { backward: true, forward: true });
23-
if (ref === undefined) {
23+
if (ref === undefined || ref.name === "") {
2424
return undefined;
2525
}
2626

server/providers/symbol-provider.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ function mapSymbolKind(kind) {
2323
class SymbolProvider {
2424
constructor(coder) {
2525
this.coder = coder;
26-
this._isShow = (name) => {
27-
return coder.settings.symbol.showAnonymousFunction || !name.includes("@");
26+
this._isShow = (symbol) => {
27+
return (coder.settings.symbol.showAnonymousFunction || !symbol.name.includes("@"))
28+
&& ((!coder.settings.symbol.showFunctionOnly || is.luaFunction(symbol.type)));
2829
}
2930
}
3031

@@ -52,7 +53,8 @@ class SymbolProvider {
5253
return;
5354
}
5455

55-
if (!this._isShow(def.name)) {
56+
if (!this._isShow(def)) {
57+
depth--;
5658
return;
5759
}
5860

0 commit comments

Comments
 (0)