dot-language-support 4.2.1 → 4.3.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/index.d.mts +2 -0
- package/dist/index.mjs +37 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -553,8 +553,10 @@ interface LanguageService {
|
|
|
553
553
|
hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
|
|
554
554
|
findReferences(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position, context: lst.ReferenceContext): lst.Location[];
|
|
555
555
|
findDefinition(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Location | undefined;
|
|
556
|
+
findDeclaration(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Location | undefined;
|
|
556
557
|
renameSymbol(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position, newName: string): lst.WorkspaceEdit | undefined;
|
|
557
558
|
getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
|
|
559
|
+
getSelectionRanges(doc: DocumentLike, sourceFile: SourceFile, positions: lst.Position[]): lst.SelectionRange[];
|
|
558
560
|
getDocumentColors(doc: DocumentLike, sourceFile: SourceFile): ColorInformation[] | undefined;
|
|
559
561
|
getColorRepresentations(doc: DocumentLike, sourceFile: SourceFile, color: Color$1, range: lst.Range): ColorPresentation[] | undefined;
|
|
560
562
|
getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, context: lst.CodeActionContext): lst.Command[] | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -3451,6 +3451,7 @@ function findDefinition(doc, sourceFile, position) {
|
|
|
3451
3451
|
}
|
|
3452
3452
|
debugger;
|
|
3453
3453
|
}
|
|
3454
|
+
const findDeclaration = findDefinition;
|
|
3454
3455
|
//#endregion
|
|
3455
3456
|
//#region src/service/rename.ts
|
|
3456
3457
|
function renameSymbol(doc, sourceFile, position, newName) {
|
|
@@ -3476,6 +3477,40 @@ function isRenameableNode(node) {
|
|
|
3476
3477
|
function isRenamableIdentifier(node) {
|
|
3477
3478
|
return node.kind !== syntaxKind.QuotedTextIdentifier;
|
|
3478
3479
|
}
|
|
3480
|
+
//#endregion
|
|
3481
|
+
//#region src/service/selectionRange.ts
|
|
3482
|
+
function getSelectionRanges(doc, sourceFile, positions) {
|
|
3483
|
+
return positions.map((p) => buildSelectionRange(doc, sourceFile, p));
|
|
3484
|
+
}
|
|
3485
|
+
function buildSelectionRange(doc, sourceFile, position) {
|
|
3486
|
+
const empty = { range: {
|
|
3487
|
+
start: position,
|
|
3488
|
+
end: position
|
|
3489
|
+
} };
|
|
3490
|
+
const g = sourceFile.graph;
|
|
3491
|
+
if (!g) return empty;
|
|
3492
|
+
const leaf = findNodeAtOffset(g, doc.offsetAt(position), true);
|
|
3493
|
+
const chain = [];
|
|
3494
|
+
let curr = leaf;
|
|
3495
|
+
while (curr) {
|
|
3496
|
+
chain.push(curr);
|
|
3497
|
+
curr = curr.parent;
|
|
3498
|
+
}
|
|
3499
|
+
if (chain.length === 0) return empty;
|
|
3500
|
+
let result;
|
|
3501
|
+
let lastKey;
|
|
3502
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
3503
|
+
const range = syntaxNodeToRange(doc, sourceFile, chain[i]);
|
|
3504
|
+
const key = `${range.start.line}:${range.start.character}-${range.end.line}:${range.end.character}`;
|
|
3505
|
+
if (key === lastKey) continue;
|
|
3506
|
+
lastKey = key;
|
|
3507
|
+
result = {
|
|
3508
|
+
range,
|
|
3509
|
+
parent: result
|
|
3510
|
+
};
|
|
3511
|
+
}
|
|
3512
|
+
return result ?? empty;
|
|
3513
|
+
}
|
|
3479
3514
|
const subErrorCodeLength = 3;
|
|
3480
3515
|
function formatError(error) {
|
|
3481
3516
|
const subCode = (error.sub | 0).toString().padStart(subErrorCodeLength, "0");
|
|
@@ -3517,8 +3552,10 @@ function createService() {
|
|
|
3517
3552
|
hover,
|
|
3518
3553
|
findReferences,
|
|
3519
3554
|
findDefinition,
|
|
3555
|
+
findDeclaration,
|
|
3520
3556
|
renameSymbol,
|
|
3521
3557
|
getCompletions,
|
|
3558
|
+
getSelectionRanges,
|
|
3522
3559
|
getDocumentColors,
|
|
3523
3560
|
getColorRepresentations,
|
|
3524
3561
|
getCodeActions,
|