-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2c2cc3
commit 1ca64ac
Showing
17 changed files
with
354 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
src/** | ||
/example/** | ||
.gitignore | ||
.yarnrc | ||
vsc-extension-quickstart.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<!-- | ||
* @Author: xuranXYS | ||
* @LastEditTime: 2024-03-19 18:15:29 | ||
* @LastEditTime: 2024-03-20 17:04:51 | ||
* @GitHub: www.github.com/xiaoxustudio | ||
* @WebSite: www.xiaoxustudio.top | ||
* @Description: By xuranXYS | ||
|
@@ -71,4 +71,4 @@ | |
|
||
联系方式:[[email protected]](emailto://[email protected]) | ||
|
||
欢迎提您提出**issue** | ||
欢迎提出您宝贵的 **issue**,我们将会处理。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
callScene: start.txt; | ||
|
||
|
||
; 颜色测试 | ||
#FA0099 | ||
rgba(255,255,120,255) | ||
rgba(240,255,200) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
intro:测试 -name=测试 -name=测试; | ||
callScene:start.txt -name=测试; | ||
callScene:start.txt; | ||
callScene:start.txt; | ||
callScene:start.txt; | ||
callScene:start.txt; | ||
callScene:start.txt; | ||
callScene: -name=测试; | ||
|
||
callScene:start.txt; | ||
callScene:start.txt; | ||
callScene:start.txt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
setVar:a=123; | ||
|
||
|
||
|
||
|
||
setVar:b=123; | ||
|
||
|
||
|
||
|
||
|
||
|
||
{b} | ||
|
||
{a} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; 警告测试 | ||
{ a} | ||
{a } | ||
{ a } | ||
|
||
; 指令:前无空格 | ||
intro:测试; | ||
|
||
; 变量名称前导数字 | ||
setVar:00test=123; | ||
|
||
; 参数前面包含一个以上的空格 | ||
intro: 测试 -name; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* @Author: xuranXYS | ||
* @LastEditTime: 2024-03-20 23:01:22 | ||
* @GitHub: www.github.com/xiaoxustudio | ||
* @WebSite: www.xiaoxustudio.top | ||
* @Description: By xuranXYS | ||
*/ | ||
import * as vscode from "vscode"; | ||
import { selector } from "./utils"; | ||
import { | ||
CancellationToken, | ||
Definition, | ||
DefinitionProvider, | ||
Position, | ||
TextDocument, | ||
} from "vscode"; | ||
import { _find_variable_type, _VToken } from "./HoverProvider"; | ||
|
||
export class XRDefinitionProvider implements DefinitionProvider { | ||
provideDefinition( | ||
document: TextDocument, | ||
position: Position, | ||
token: CancellationToken | ||
) { | ||
const _arr: { [key: string]: _VToken } = {}; | ||
const ALL_ARR = document.getText().split("\n"); | ||
const _ALL_ARR_cache = []; | ||
const _arrType = []; | ||
for (let _d_index = 0; _d_index < ALL_ARR.length; _d_index++) { | ||
const _data = ALL_ARR[_d_index]; | ||
let m = /setVar:\s*(\w+)\s*=\s*([^;]*\S+);?/g.exec(_data); | ||
if (m) { | ||
_arr[m[1]] = { | ||
word: m[1], | ||
input: m.input, | ||
position: position.with(_d_index, 7), | ||
} as _VToken; | ||
_arrType.push(_find_variable_type(m.input, m[1], _arr)); | ||
} else { | ||
_ALL_ARR_cache.push(_data); | ||
} | ||
} | ||
const editor = vscode.window.activeTextEditor; | ||
if (editor) { | ||
const position_select = editor.selection.active; | ||
const wordRange = editor.document.getWordRangeAtPosition(position_select); | ||
if (wordRange) { | ||
const _range = wordRange.with( | ||
wordRange.start.with( | ||
wordRange.start.line, | ||
wordRange.start.character - 1 | ||
), | ||
wordRange.end.with(wordRange.end.line, wordRange.end.character + 1) | ||
); | ||
const word = editor.document.getText(_range); | ||
const _length = word.length; | ||
const _word_no = word.substring(word.indexOf("{") + 1, _length - 1); | ||
// 判断是否是有效word | ||
if (/{\S+}/.test(word) && _arr[_word_no]) { | ||
return [ | ||
{ | ||
uri: document.uri, | ||
range: wordRange.with( | ||
_arr[_word_no].position, | ||
_arr[_word_no].position?.with( | ||
_arr[_word_no].position?.line, | ||
_arr[_word_no].input?.indexOf("=") | ||
) | ||
), | ||
}, | ||
] as Definition; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.