@void2610/tyranoscript-lsp 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +307 -42
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -3371,8 +3371,8 @@ var require_main2 = __commonJS({
|
|
|
3371
3371
|
}
|
|
3372
3372
|
uinteger2.is = is;
|
|
3373
3373
|
})(uinteger || (exports3.uinteger = uinteger = {}));
|
|
3374
|
-
var
|
|
3375
|
-
(function(
|
|
3374
|
+
var Position2;
|
|
3375
|
+
(function(Position3) {
|
|
3376
3376
|
function create(line, character) {
|
|
3377
3377
|
if (line === Number.MAX_VALUE) {
|
|
3378
3378
|
line = uinteger.MAX_VALUE;
|
|
@@ -3382,43 +3382,43 @@ var require_main2 = __commonJS({
|
|
|
3382
3382
|
}
|
|
3383
3383
|
return { line, character };
|
|
3384
3384
|
}
|
|
3385
|
-
|
|
3385
|
+
Position3.create = create;
|
|
3386
3386
|
function is(value) {
|
|
3387
3387
|
var candidate = value;
|
|
3388
3388
|
return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
|
|
3389
3389
|
}
|
|
3390
|
-
|
|
3391
|
-
})(
|
|
3392
|
-
var
|
|
3393
|
-
(function(
|
|
3390
|
+
Position3.is = is;
|
|
3391
|
+
})(Position2 || (exports3.Position = Position2 = {}));
|
|
3392
|
+
var Range2;
|
|
3393
|
+
(function(Range3) {
|
|
3394
3394
|
function create(one, two, three, four) {
|
|
3395
3395
|
if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
|
|
3396
|
-
return { start:
|
|
3397
|
-
} else if (
|
|
3396
|
+
return { start: Position2.create(one, two), end: Position2.create(three, four) };
|
|
3397
|
+
} else if (Position2.is(one) && Position2.is(two)) {
|
|
3398
3398
|
return { start: one, end: two };
|
|
3399
3399
|
} else {
|
|
3400
3400
|
throw new Error("Range#create called with invalid arguments[".concat(one, ", ").concat(two, ", ").concat(three, ", ").concat(four, "]"));
|
|
3401
3401
|
}
|
|
3402
3402
|
}
|
|
3403
|
-
|
|
3403
|
+
Range3.create = create;
|
|
3404
3404
|
function is(value) {
|
|
3405
3405
|
var candidate = value;
|
|
3406
|
-
return Is.objectLiteral(candidate) &&
|
|
3406
|
+
return Is.objectLiteral(candidate) && Position2.is(candidate.start) && Position2.is(candidate.end);
|
|
3407
3407
|
}
|
|
3408
|
-
|
|
3409
|
-
})(
|
|
3410
|
-
var
|
|
3411
|
-
(function(
|
|
3408
|
+
Range3.is = is;
|
|
3409
|
+
})(Range2 || (exports3.Range = Range2 = {}));
|
|
3410
|
+
var Location2;
|
|
3411
|
+
(function(Location3) {
|
|
3412
3412
|
function create(uri, range) {
|
|
3413
3413
|
return { uri, range };
|
|
3414
3414
|
}
|
|
3415
|
-
|
|
3415
|
+
Location3.create = create;
|
|
3416
3416
|
function is(value) {
|
|
3417
3417
|
var candidate = value;
|
|
3418
|
-
return Is.objectLiteral(candidate) &&
|
|
3418
|
+
return Is.objectLiteral(candidate) && Range2.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
|
|
3419
3419
|
}
|
|
3420
|
-
|
|
3421
|
-
})(
|
|
3420
|
+
Location3.is = is;
|
|
3421
|
+
})(Location2 || (exports3.Location = Location2 = {}));
|
|
3422
3422
|
var LocationLink;
|
|
3423
3423
|
(function(LocationLink2) {
|
|
3424
3424
|
function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
|
|
@@ -3427,7 +3427,7 @@ var require_main2 = __commonJS({
|
|
|
3427
3427
|
LocationLink2.create = create;
|
|
3428
3428
|
function is(value) {
|
|
3429
3429
|
var candidate = value;
|
|
3430
|
-
return Is.objectLiteral(candidate) &&
|
|
3430
|
+
return Is.objectLiteral(candidate) && Range2.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range2.is(candidate.targetSelectionRange) && (Range2.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
|
|
3431
3431
|
}
|
|
3432
3432
|
LocationLink2.is = is;
|
|
3433
3433
|
})(LocationLink || (exports3.LocationLink = LocationLink = {}));
|
|
@@ -3459,7 +3459,7 @@ var require_main2 = __commonJS({
|
|
|
3459
3459
|
ColorInformation2.create = create;
|
|
3460
3460
|
function is(value) {
|
|
3461
3461
|
var candidate = value;
|
|
3462
|
-
return Is.objectLiteral(candidate) &&
|
|
3462
|
+
return Is.objectLiteral(candidate) && Range2.is(candidate.range) && Color.is(candidate.color);
|
|
3463
3463
|
}
|
|
3464
3464
|
ColorInformation2.is = is;
|
|
3465
3465
|
})(ColorInformation || (exports3.ColorInformation = ColorInformation = {}));
|
|
@@ -3524,7 +3524,7 @@ var require_main2 = __commonJS({
|
|
|
3524
3524
|
DiagnosticRelatedInformation2.create = create;
|
|
3525
3525
|
function is(value) {
|
|
3526
3526
|
var candidate = value;
|
|
3527
|
-
return Is.defined(candidate) &&
|
|
3527
|
+
return Is.defined(candidate) && Location2.is(candidate.location) && Is.string(candidate.message);
|
|
3528
3528
|
}
|
|
3529
3529
|
DiagnosticRelatedInformation2.is = is;
|
|
3530
3530
|
})(DiagnosticRelatedInformation || (exports3.DiagnosticRelatedInformation = DiagnosticRelatedInformation = {}));
|
|
@@ -3570,7 +3570,7 @@ var require_main2 = __commonJS({
|
|
|
3570
3570
|
function is(value) {
|
|
3571
3571
|
var _a;
|
|
3572
3572
|
var candidate = value;
|
|
3573
|
-
return Is.defined(candidate) &&
|
|
3573
|
+
return Is.defined(candidate) && Range2.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
|
|
3574
3574
|
}
|
|
3575
3575
|
Diagnostic2.is = is;
|
|
3576
3576
|
})(Diagnostic || (exports3.Diagnostic = Diagnostic = {}));
|
|
@@ -3610,7 +3610,7 @@ var require_main2 = __commonJS({
|
|
|
3610
3610
|
TextEdit2.del = del;
|
|
3611
3611
|
function is(value) {
|
|
3612
3612
|
var candidate = value;
|
|
3613
|
-
return Is.objectLiteral(candidate) && Is.string(candidate.newText) &&
|
|
3613
|
+
return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range2.is(candidate.range);
|
|
3614
3614
|
}
|
|
3615
3615
|
TextEdit2.is = is;
|
|
3616
3616
|
})(TextEdit || (exports3.TextEdit = TextEdit = {}));
|
|
@@ -4154,7 +4154,7 @@ var require_main2 = __commonJS({
|
|
|
4154
4154
|
InsertReplaceEdit2.create = create;
|
|
4155
4155
|
function is(value) {
|
|
4156
4156
|
var candidate = value;
|
|
4157
|
-
return candidate && Is.string(candidate.newText) &&
|
|
4157
|
+
return candidate && Is.string(candidate.newText) && Range2.is(candidate.insert) && Range2.is(candidate.replace);
|
|
4158
4158
|
}
|
|
4159
4159
|
InsertReplaceEdit2.is = is;
|
|
4160
4160
|
})(InsertReplaceEdit || (exports3.InsertReplaceEdit = InsertReplaceEdit = {}));
|
|
@@ -4201,7 +4201,7 @@ var require_main2 = __commonJS({
|
|
|
4201
4201
|
(function(Hover3) {
|
|
4202
4202
|
function is(value) {
|
|
4203
4203
|
var candidate = value;
|
|
4204
|
-
return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 ||
|
|
4204
|
+
return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range2.is(value.range));
|
|
4205
4205
|
}
|
|
4206
4206
|
Hover3.is = is;
|
|
4207
4207
|
})(Hover2 || (exports3.Hover = Hover2 = {}));
|
|
@@ -4322,7 +4322,7 @@ var require_main2 = __commonJS({
|
|
|
4322
4322
|
DocumentSymbol2.create = create;
|
|
4323
4323
|
function is(value) {
|
|
4324
4324
|
var candidate = value;
|
|
4325
|
-
return candidate && Is.string(candidate.name) && Is.number(candidate.kind) &&
|
|
4325
|
+
return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range2.is(candidate.range) && Range2.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
|
|
4326
4326
|
}
|
|
4327
4327
|
DocumentSymbol2.is = is;
|
|
4328
4328
|
})(DocumentSymbol || (exports3.DocumentSymbol = DocumentSymbol = {}));
|
|
@@ -4399,7 +4399,7 @@ var require_main2 = __commonJS({
|
|
|
4399
4399
|
CodeLens2.create = create;
|
|
4400
4400
|
function is(value) {
|
|
4401
4401
|
var candidate = value;
|
|
4402
|
-
return Is.defined(candidate) &&
|
|
4402
|
+
return Is.defined(candidate) && Range2.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
|
|
4403
4403
|
}
|
|
4404
4404
|
CodeLens2.is = is;
|
|
4405
4405
|
})(CodeLens || (exports3.CodeLens = CodeLens = {}));
|
|
@@ -4423,7 +4423,7 @@ var require_main2 = __commonJS({
|
|
|
4423
4423
|
DocumentLink2.create = create;
|
|
4424
4424
|
function is(value) {
|
|
4425
4425
|
var candidate = value;
|
|
4426
|
-
return Is.defined(candidate) &&
|
|
4426
|
+
return Is.defined(candidate) && Range2.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
|
|
4427
4427
|
}
|
|
4428
4428
|
DocumentLink2.is = is;
|
|
4429
4429
|
})(DocumentLink || (exports3.DocumentLink = DocumentLink = {}));
|
|
@@ -4435,7 +4435,7 @@ var require_main2 = __commonJS({
|
|
|
4435
4435
|
SelectionRange2.create = create;
|
|
4436
4436
|
function is(value) {
|
|
4437
4437
|
var candidate = value;
|
|
4438
|
-
return Is.objectLiteral(candidate) &&
|
|
4438
|
+
return Is.objectLiteral(candidate) && Range2.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
|
|
4439
4439
|
}
|
|
4440
4440
|
SelectionRange2.is = is;
|
|
4441
4441
|
})(SelectionRange || (exports3.SelectionRange = SelectionRange = {}));
|
|
@@ -4494,7 +4494,7 @@ var require_main2 = __commonJS({
|
|
|
4494
4494
|
InlineValueText2.create = create;
|
|
4495
4495
|
function is(value) {
|
|
4496
4496
|
var candidate = value;
|
|
4497
|
-
return candidate !== void 0 && candidate !== null &&
|
|
4497
|
+
return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && Is.string(candidate.text);
|
|
4498
4498
|
}
|
|
4499
4499
|
InlineValueText2.is = is;
|
|
4500
4500
|
})(InlineValueText || (exports3.InlineValueText = InlineValueText = {}));
|
|
@@ -4506,7 +4506,7 @@ var require_main2 = __commonJS({
|
|
|
4506
4506
|
InlineValueVariableLookup2.create = create;
|
|
4507
4507
|
function is(value) {
|
|
4508
4508
|
var candidate = value;
|
|
4509
|
-
return candidate !== void 0 && candidate !== null &&
|
|
4509
|
+
return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
|
|
4510
4510
|
}
|
|
4511
4511
|
InlineValueVariableLookup2.is = is;
|
|
4512
4512
|
})(InlineValueVariableLookup || (exports3.InlineValueVariableLookup = InlineValueVariableLookup = {}));
|
|
@@ -4518,7 +4518,7 @@ var require_main2 = __commonJS({
|
|
|
4518
4518
|
InlineValueEvaluatableExpression2.create = create;
|
|
4519
4519
|
function is(value) {
|
|
4520
4520
|
var candidate = value;
|
|
4521
|
-
return candidate !== void 0 && candidate !== null &&
|
|
4521
|
+
return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
|
|
4522
4522
|
}
|
|
4523
4523
|
InlineValueEvaluatableExpression2.is = is;
|
|
4524
4524
|
})(InlineValueEvaluatableExpression || (exports3.InlineValueEvaluatableExpression = InlineValueEvaluatableExpression = {}));
|
|
@@ -4530,7 +4530,7 @@ var require_main2 = __commonJS({
|
|
|
4530
4530
|
InlineValueContext2.create = create;
|
|
4531
4531
|
function is(value) {
|
|
4532
4532
|
var candidate = value;
|
|
4533
|
-
return Is.defined(candidate) &&
|
|
4533
|
+
return Is.defined(candidate) && Range2.is(value.stoppedLocation);
|
|
4534
4534
|
}
|
|
4535
4535
|
InlineValueContext2.is = is;
|
|
4536
4536
|
})(InlineValueContext || (exports3.InlineValueContext = InlineValueContext = {}));
|
|
@@ -4551,7 +4551,7 @@ var require_main2 = __commonJS({
|
|
|
4551
4551
|
InlayHintLabelPart2.create = create;
|
|
4552
4552
|
function is(value) {
|
|
4553
4553
|
var candidate = value;
|
|
4554
|
-
return Is.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.location === void 0 ||
|
|
4554
|
+
return Is.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.location === void 0 || Location2.is(candidate.location)) && (candidate.command === void 0 || Command.is(candidate.command));
|
|
4555
4555
|
}
|
|
4556
4556
|
InlayHintLabelPart2.is = is;
|
|
4557
4557
|
})(InlayHintLabelPart || (exports3.InlayHintLabelPart = InlayHintLabelPart = {}));
|
|
@@ -4567,7 +4567,7 @@ var require_main2 = __commonJS({
|
|
|
4567
4567
|
InlayHint2.create = create;
|
|
4568
4568
|
function is(value) {
|
|
4569
4569
|
var candidate = value;
|
|
4570
|
-
return Is.objectLiteral(candidate) &&
|
|
4570
|
+
return Is.objectLiteral(candidate) && Position2.is(candidate.position) && (Is.string(candidate.label) || Is.typedArray(candidate.label, InlayHintLabelPart.is)) && (candidate.kind === void 0 || InlayHintKind.is(candidate.kind)) && candidate.textEdits === void 0 || Is.typedArray(candidate.textEdits, TextEdit.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
|
|
4571
4571
|
}
|
|
4572
4572
|
InlayHint2.is = is;
|
|
4573
4573
|
})(InlayHint || (exports3.InlayHint = InlayHint = {}));
|
|
@@ -4756,7 +4756,7 @@ var require_main2 = __commonJS({
|
|
|
4756
4756
|
var lineOffsets = this.getLineOffsets();
|
|
4757
4757
|
var low = 0, high = lineOffsets.length;
|
|
4758
4758
|
if (high === 0) {
|
|
4759
|
-
return
|
|
4759
|
+
return Position2.create(0, offset);
|
|
4760
4760
|
}
|
|
4761
4761
|
while (low < high) {
|
|
4762
4762
|
var mid = Math.floor((low + high) / 2);
|
|
@@ -4767,7 +4767,7 @@ var require_main2 = __commonJS({
|
|
|
4767
4767
|
}
|
|
4768
4768
|
}
|
|
4769
4769
|
var line = low - 1;
|
|
4770
|
-
return
|
|
4770
|
+
return Position2.create(line, offset - lineOffsets[line]);
|
|
4771
4771
|
};
|
|
4772
4772
|
FullTextDocument3.prototype.offsetAt = function(position) {
|
|
4773
4773
|
var lineOffsets = this.getLineOffsets();
|
|
@@ -12230,10 +12230,20 @@ var WorkspaceScanner = class {
|
|
|
12230
12230
|
}
|
|
12231
12231
|
const macroMatch = line.match(/\[macro\s+name\s*=\s*"(\w+)"\s*\]/i);
|
|
12232
12232
|
if (macroMatch) {
|
|
12233
|
+
const commentLines = [];
|
|
12234
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
12235
|
+
const commentMatch = lines[j].match(/^;\s?(.*)/);
|
|
12236
|
+
if (commentMatch) {
|
|
12237
|
+
commentLines.unshift(commentMatch[1]);
|
|
12238
|
+
} else {
|
|
12239
|
+
break;
|
|
12240
|
+
}
|
|
12241
|
+
}
|
|
12233
12242
|
macros.push({
|
|
12234
12243
|
name: macroMatch[1],
|
|
12235
12244
|
file: relativePath,
|
|
12236
|
-
line: i
|
|
12245
|
+
line: i,
|
|
12246
|
+
description: commentLines.join("\n")
|
|
12237
12247
|
});
|
|
12238
12248
|
}
|
|
12239
12249
|
}
|
|
@@ -12299,6 +12309,113 @@ var WorkspaceScanner = class {
|
|
|
12299
12309
|
isInitialized() {
|
|
12300
12310
|
return this.initialized;
|
|
12301
12311
|
}
|
|
12312
|
+
/**
|
|
12313
|
+
* 全 .ks ファイルから target="*labelName" の参照箇所を検索する
|
|
12314
|
+
*/
|
|
12315
|
+
findLabelReferences(labelName) {
|
|
12316
|
+
if (!this.initialized) return [];
|
|
12317
|
+
const results = [];
|
|
12318
|
+
const scenarioPath = path.join(this.dataPath, "scenario");
|
|
12319
|
+
if (!fs.existsSync(scenarioPath)) return results;
|
|
12320
|
+
const ksFiles = this.findKsFiles(scenarioPath);
|
|
12321
|
+
const regex = new RegExp(
|
|
12322
|
+
`target\\s*=\\s*"\\*${this.escapeRegExp(labelName)}"`,
|
|
12323
|
+
"g"
|
|
12324
|
+
);
|
|
12325
|
+
for (const filePath of ksFiles) {
|
|
12326
|
+
try {
|
|
12327
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
12328
|
+
const lines = content.split("\n");
|
|
12329
|
+
const relativePath = path.relative(this.dataPath, filePath);
|
|
12330
|
+
for (let i = 0; i < lines.length; i++) {
|
|
12331
|
+
let match;
|
|
12332
|
+
regex.lastIndex = 0;
|
|
12333
|
+
while ((match = regex.exec(lines[i])) !== null) {
|
|
12334
|
+
const valueStart = lines[i].indexOf(`*${labelName}`, match.index);
|
|
12335
|
+
results.push({
|
|
12336
|
+
file: relativePath,
|
|
12337
|
+
line: i,
|
|
12338
|
+
startChar: valueStart,
|
|
12339
|
+
endChar: valueStart + labelName.length + 1
|
|
12340
|
+
// +1 は "*" の分
|
|
12341
|
+
});
|
|
12342
|
+
}
|
|
12343
|
+
}
|
|
12344
|
+
} catch {
|
|
12345
|
+
}
|
|
12346
|
+
}
|
|
12347
|
+
return results;
|
|
12348
|
+
}
|
|
12349
|
+
/**
|
|
12350
|
+
* 全 .ks ファイルからマクロの使用箇所を検索する
|
|
12351
|
+
* [macroName ...] または @macroName 形式にマッチし、定義行 [macro name="..."] は除外する
|
|
12352
|
+
*/
|
|
12353
|
+
findMacroReferences(macroName) {
|
|
12354
|
+
if (!this.initialized) return [];
|
|
12355
|
+
const results = [];
|
|
12356
|
+
const scenarioPath = path.join(this.dataPath, "scenario");
|
|
12357
|
+
if (!fs.existsSync(scenarioPath)) return results;
|
|
12358
|
+
const ksFiles = this.findKsFiles(scenarioPath);
|
|
12359
|
+
const bracketRegex = new RegExp(
|
|
12360
|
+
`\\[${this.escapeRegExp(macroName)}(?=[\\s\\]]|$)`,
|
|
12361
|
+
"g"
|
|
12362
|
+
);
|
|
12363
|
+
const atRegex = new RegExp(
|
|
12364
|
+
`^@${this.escapeRegExp(macroName)}(?=[\\s]|$)`,
|
|
12365
|
+
"g"
|
|
12366
|
+
);
|
|
12367
|
+
const defRegex = new RegExp(
|
|
12368
|
+
`\\[macro\\s+name\\s*=\\s*"${this.escapeRegExp(macroName)}"\\s*\\]`,
|
|
12369
|
+
"i"
|
|
12370
|
+
);
|
|
12371
|
+
for (const filePath of ksFiles) {
|
|
12372
|
+
try {
|
|
12373
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
12374
|
+
const lines = content.split("\n");
|
|
12375
|
+
const relativePath = path.relative(this.dataPath, filePath);
|
|
12376
|
+
for (let i = 0; i < lines.length; i++) {
|
|
12377
|
+
const line = lines[i];
|
|
12378
|
+
if (defRegex.test(line)) continue;
|
|
12379
|
+
bracketRegex.lastIndex = 0;
|
|
12380
|
+
let match;
|
|
12381
|
+
while ((match = bracketRegex.exec(line)) !== null) {
|
|
12382
|
+
const start = match.index + 1;
|
|
12383
|
+
results.push({
|
|
12384
|
+
file: relativePath,
|
|
12385
|
+
line: i,
|
|
12386
|
+
startChar: start,
|
|
12387
|
+
endChar: start + macroName.length
|
|
12388
|
+
});
|
|
12389
|
+
}
|
|
12390
|
+
atRegex.lastIndex = 0;
|
|
12391
|
+
while ((match = atRegex.exec(line)) !== null) {
|
|
12392
|
+
const start = match.index + 1;
|
|
12393
|
+
results.push({
|
|
12394
|
+
file: relativePath,
|
|
12395
|
+
line: i,
|
|
12396
|
+
startChar: start,
|
|
12397
|
+
endChar: start + macroName.length
|
|
12398
|
+
});
|
|
12399
|
+
}
|
|
12400
|
+
}
|
|
12401
|
+
} catch {
|
|
12402
|
+
}
|
|
12403
|
+
}
|
|
12404
|
+
return results;
|
|
12405
|
+
}
|
|
12406
|
+
/**
|
|
12407
|
+
* data/ からの相対パスを file:// URI に変換する
|
|
12408
|
+
*/
|
|
12409
|
+
resolveFilePath(relativePath) {
|
|
12410
|
+
const absPath = path.join(this.dataPath, relativePath);
|
|
12411
|
+
return `file://${encodeURI(absPath)}`;
|
|
12412
|
+
}
|
|
12413
|
+
/**
|
|
12414
|
+
* 正規表現の特殊文字をエスケープする
|
|
12415
|
+
*/
|
|
12416
|
+
escapeRegExp(str) {
|
|
12417
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12418
|
+
}
|
|
12302
12419
|
};
|
|
12303
12420
|
|
|
12304
12421
|
// src/server.ts
|
|
@@ -12319,7 +12436,9 @@ connection.onInitialize((params) => {
|
|
|
12319
12436
|
triggerCharacters: ["[", "@", " ", '"'],
|
|
12320
12437
|
resolveProvider: false
|
|
12321
12438
|
},
|
|
12322
|
-
hoverProvider: true
|
|
12439
|
+
hoverProvider: true,
|
|
12440
|
+
definitionProvider: true,
|
|
12441
|
+
referencesProvider: true
|
|
12323
12442
|
}
|
|
12324
12443
|
};
|
|
12325
12444
|
});
|
|
@@ -12458,12 +12577,12 @@ function createMacroCompletions(trigger) {
|
|
|
12458
12577
|
return {
|
|
12459
12578
|
label: macro.name,
|
|
12460
12579
|
kind: import_node.CompletionItemKind.Function,
|
|
12461
|
-
detail: `\u30DE\u30AF\u30ED (${macro.file})`,
|
|
12580
|
+
detail: macro.description ? macro.description.split("\n")[0] : `\u30DE\u30AF\u30ED (${macro.file})`,
|
|
12462
12581
|
documentation: {
|
|
12463
12582
|
kind: import_node.MarkupKind.Markdown,
|
|
12464
12583
|
value: `**[${macro.name}]** \u2014 \u30E6\u30FC\u30B6\u30FC\u5B9A\u7FA9\u30DE\u30AF\u30ED
|
|
12465
12584
|
|
|
12466
|
-
\u5B9A\u7FA9\u5143: \`${macro.file}\` (\u884C ${macro.line + 1})`
|
|
12585
|
+
${macro.description ? macro.description + "\n\n" : ""}\u5B9A\u7FA9\u5143: \`${macro.file}\` (\u884C ${macro.line + 1})`
|
|
12467
12586
|
},
|
|
12468
12587
|
insertText,
|
|
12469
12588
|
insertTextFormat: import_node.InsertTextFormat.PlainText,
|
|
@@ -12529,6 +12648,152 @@ connection.onCompletion(
|
|
|
12529
12648
|
return [];
|
|
12530
12649
|
}
|
|
12531
12650
|
);
|
|
12651
|
+
function getDefinitionContext(lineText, character) {
|
|
12652
|
+
const valueCtx = getParamValueContext(lineText, character);
|
|
12653
|
+
if (valueCtx) {
|
|
12654
|
+
if (valueCtx.paramName === "target" && valueCtx.currentValue.startsWith("*")) {
|
|
12655
|
+
return { kind: "label", name: valueCtx.currentValue.substring(1) };
|
|
12656
|
+
}
|
|
12657
|
+
if (valueCtx.paramName === "storage" && valueCtx.currentValue.length > 0) {
|
|
12658
|
+
return { kind: "file", name: valueCtx.currentValue };
|
|
12659
|
+
}
|
|
12660
|
+
return null;
|
|
12661
|
+
}
|
|
12662
|
+
const tagCtx = getTagContext(lineText, character);
|
|
12663
|
+
if (tagCtx && !tagCtx.isInParams) {
|
|
12664
|
+
if (!TAG_DATABASE.has(tagCtx.tagName)) {
|
|
12665
|
+
return { kind: "macro", name: tagCtx.tagName };
|
|
12666
|
+
}
|
|
12667
|
+
}
|
|
12668
|
+
return null;
|
|
12669
|
+
}
|
|
12670
|
+
function refToLocation(ref) {
|
|
12671
|
+
return {
|
|
12672
|
+
uri: scanner.resolveFilePath(ref.file),
|
|
12673
|
+
range: import_node.Range.create(
|
|
12674
|
+
import_node.Position.create(ref.line, ref.startChar),
|
|
12675
|
+
import_node.Position.create(ref.line, ref.endChar)
|
|
12676
|
+
)
|
|
12677
|
+
};
|
|
12678
|
+
}
|
|
12679
|
+
connection.onDefinition(
|
|
12680
|
+
(params) => {
|
|
12681
|
+
const document = documents.get(params.textDocument.uri);
|
|
12682
|
+
if (!document) return null;
|
|
12683
|
+
const lineText = document.getText({
|
|
12684
|
+
start: { line: params.position.line, character: 0 },
|
|
12685
|
+
end: { line: params.position.line + 1, character: 0 }
|
|
12686
|
+
}).replace(/\n$/, "");
|
|
12687
|
+
const ctx = getDefinitionContext(lineText, params.position.character);
|
|
12688
|
+
if (!ctx) return null;
|
|
12689
|
+
switch (ctx.kind) {
|
|
12690
|
+
case "label": {
|
|
12691
|
+
const label = scanner.getLabels().find((l) => l.name === ctx.name);
|
|
12692
|
+
if (!label) return null;
|
|
12693
|
+
return {
|
|
12694
|
+
uri: scanner.resolveFilePath(label.file),
|
|
12695
|
+
range: import_node.Range.create(
|
|
12696
|
+
import_node.Position.create(label.line, 0),
|
|
12697
|
+
import_node.Position.create(label.line, label.name.length + 1)
|
|
12698
|
+
// +1 は "*" の分
|
|
12699
|
+
)
|
|
12700
|
+
};
|
|
12701
|
+
}
|
|
12702
|
+
case "file": {
|
|
12703
|
+
const tagCtx = getTagContext(lineText, params.position.character);
|
|
12704
|
+
if (!tagCtx) return null;
|
|
12705
|
+
const category = TAG_STORAGE_MAPPING.get(tagCtx.tagName);
|
|
12706
|
+
if (!category) return null;
|
|
12707
|
+
const filePath = `${category}/${ctx.name}`;
|
|
12708
|
+
return {
|
|
12709
|
+
uri: scanner.resolveFilePath(filePath),
|
|
12710
|
+
range: import_node.Range.create(import_node.Position.create(0, 0), import_node.Position.create(0, 0))
|
|
12711
|
+
};
|
|
12712
|
+
}
|
|
12713
|
+
case "macro": {
|
|
12714
|
+
const macro = scanner.getMacros().find((m) => m.name === ctx.name);
|
|
12715
|
+
if (!macro) return null;
|
|
12716
|
+
return {
|
|
12717
|
+
uri: scanner.resolveFilePath(macro.file),
|
|
12718
|
+
range: import_node.Range.create(
|
|
12719
|
+
import_node.Position.create(macro.line, 0),
|
|
12720
|
+
import_node.Position.create(macro.line, 0)
|
|
12721
|
+
)
|
|
12722
|
+
};
|
|
12723
|
+
}
|
|
12724
|
+
}
|
|
12725
|
+
}
|
|
12726
|
+
);
|
|
12727
|
+
function getLabelDefinitionAtCursor(lineText, character) {
|
|
12728
|
+
const match = lineText.match(/^\*(\w+)/);
|
|
12729
|
+
if (match && character <= match[0].length) {
|
|
12730
|
+
return match[1];
|
|
12731
|
+
}
|
|
12732
|
+
return null;
|
|
12733
|
+
}
|
|
12734
|
+
function getMacroDefinitionAtCursor(lineText) {
|
|
12735
|
+
const match = lineText.match(/\[macro\s+name\s*=\s*"(\w+)"\s*\]/i);
|
|
12736
|
+
if (match) {
|
|
12737
|
+
return match[1];
|
|
12738
|
+
}
|
|
12739
|
+
return null;
|
|
12740
|
+
}
|
|
12741
|
+
connection.onReferences(
|
|
12742
|
+
(params) => {
|
|
12743
|
+
const document = documents.get(params.textDocument.uri);
|
|
12744
|
+
if (!document) return [];
|
|
12745
|
+
const lineText = document.getText({
|
|
12746
|
+
start: { line: params.position.line, character: 0 },
|
|
12747
|
+
end: { line: params.position.line + 1, character: 0 }
|
|
12748
|
+
}).replace(/\n$/, "");
|
|
12749
|
+
const character = params.position.character;
|
|
12750
|
+
const results = [];
|
|
12751
|
+
const labelDef = getLabelDefinitionAtCursor(lineText, character);
|
|
12752
|
+
if (labelDef) {
|
|
12753
|
+
const refs = scanner.findLabelReferences(labelDef);
|
|
12754
|
+
return refs.map(refToLocation);
|
|
12755
|
+
}
|
|
12756
|
+
const macroDef = getMacroDefinitionAtCursor(lineText);
|
|
12757
|
+
if (macroDef) {
|
|
12758
|
+
const refs = scanner.findMacroReferences(macroDef);
|
|
12759
|
+
return refs.map(refToLocation);
|
|
12760
|
+
}
|
|
12761
|
+
const defCtx = getDefinitionContext(lineText, character);
|
|
12762
|
+
if (defCtx) {
|
|
12763
|
+
if (defCtx.kind === "label") {
|
|
12764
|
+
const label = scanner.getLabels().find((l) => l.name === defCtx.name);
|
|
12765
|
+
if (label) {
|
|
12766
|
+
results.push({
|
|
12767
|
+
uri: scanner.resolveFilePath(label.file),
|
|
12768
|
+
range: import_node.Range.create(
|
|
12769
|
+
import_node.Position.create(label.line, 0),
|
|
12770
|
+
import_node.Position.create(label.line, label.name.length + 1)
|
|
12771
|
+
)
|
|
12772
|
+
});
|
|
12773
|
+
}
|
|
12774
|
+
const refs = scanner.findLabelReferences(defCtx.name);
|
|
12775
|
+
results.push(...refs.map(refToLocation));
|
|
12776
|
+
return results;
|
|
12777
|
+
}
|
|
12778
|
+
if (defCtx.kind === "macro") {
|
|
12779
|
+
const macro = scanner.getMacros().find((m) => m.name === defCtx.name);
|
|
12780
|
+
if (macro) {
|
|
12781
|
+
results.push({
|
|
12782
|
+
uri: scanner.resolveFilePath(macro.file),
|
|
12783
|
+
range: import_node.Range.create(
|
|
12784
|
+
import_node.Position.create(macro.line, 0),
|
|
12785
|
+
import_node.Position.create(macro.line, 0)
|
|
12786
|
+
)
|
|
12787
|
+
});
|
|
12788
|
+
}
|
|
12789
|
+
const refs = scanner.findMacroReferences(defCtx.name);
|
|
12790
|
+
results.push(...refs.map(refToLocation));
|
|
12791
|
+
return results;
|
|
12792
|
+
}
|
|
12793
|
+
}
|
|
12794
|
+
return results;
|
|
12795
|
+
}
|
|
12796
|
+
);
|
|
12532
12797
|
connection.onHover(
|
|
12533
12798
|
(params) => {
|
|
12534
12799
|
const document = documents.get(params.textDocument.uri);
|