dot-language-support 4.2.1 → 4.3.1
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 +111 -3
- 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
|
@@ -1694,6 +1694,54 @@ const attributes = Array.from(new Set([
|
|
|
1694
1694
|
...graphAttributes,
|
|
1695
1695
|
...clusterAttributes
|
|
1696
1696
|
])).sort();
|
|
1697
|
+
const attributeDescriptions = Object.freeze({
|
|
1698
|
+
arrowhead: "Style of arrowhead at head end",
|
|
1699
|
+
arrowsize: "Scaling factor for arrowheads",
|
|
1700
|
+
arrowtail: "Style of arrowhead at tail end",
|
|
1701
|
+
bgcolor: "Background color",
|
|
1702
|
+
color: "Node shape/edge/cluster color",
|
|
1703
|
+
comment: "Any string",
|
|
1704
|
+
compound: "Allow edges between clusters",
|
|
1705
|
+
concentrate: "Enables edge concentrators",
|
|
1706
|
+
constraint: "Use edge to affect node ranking",
|
|
1707
|
+
decorate: "If set, line between label and edge",
|
|
1708
|
+
dir: "Direction of edge",
|
|
1709
|
+
distortion: "Node distortion",
|
|
1710
|
+
fillcolor: "Node/cluster fill color",
|
|
1711
|
+
fixedsize: "Label text has no effect on node size",
|
|
1712
|
+
fontcolor: "Font face color",
|
|
1713
|
+
fontname: "Font family",
|
|
1714
|
+
fontsize: "Point size of label",
|
|
1715
|
+
group: "Name of node group",
|
|
1716
|
+
headlabel: "Label placed near head of edge",
|
|
1717
|
+
headport: "Where on the node to attach head of edge",
|
|
1718
|
+
height: "Height in inches",
|
|
1719
|
+
label: "Any string",
|
|
1720
|
+
labelangle: "Angle in degrees",
|
|
1721
|
+
labeldistance: "Scaling factor for distance for head or tail label",
|
|
1722
|
+
labelfontcolor: "Type face color for head and tail labels",
|
|
1723
|
+
labelfontname: "Font family for head and tail labels",
|
|
1724
|
+
labelfontsize: "Point size for head and tail labels",
|
|
1725
|
+
labeljust: "Label justification",
|
|
1726
|
+
labelloc: "Label vertical justification",
|
|
1727
|
+
layer: "Overlay range",
|
|
1728
|
+
nodesep: "Separation between nodes, in inches",
|
|
1729
|
+
orientation: "Node rotation angle",
|
|
1730
|
+
peripheries: "Number of node boundaries",
|
|
1731
|
+
ranksep: "Separation between ranks, in inches",
|
|
1732
|
+
ratio: "Aspect ratio",
|
|
1733
|
+
regular: "Force polygon to be regular",
|
|
1734
|
+
rotate: "If 90, set orientation to landscape",
|
|
1735
|
+
shape: "Node shape",
|
|
1736
|
+
shapefile: "External custom shape file",
|
|
1737
|
+
sides: "Number of sides for shape=polygon",
|
|
1738
|
+
skew: "Skewing node for shape=polygon",
|
|
1739
|
+
style: "Graphics options",
|
|
1740
|
+
taillabel: "Label placed near tail of edge",
|
|
1741
|
+
tailport: "Where on the node to attach tail of edge",
|
|
1742
|
+
weight: "Integer cost of stretching an edge",
|
|
1743
|
+
width: "Width in inches"
|
|
1744
|
+
});
|
|
1697
1745
|
/**
|
|
1698
1746
|
* We only support the X11 color scheme
|
|
1699
1747
|
*/
|
|
@@ -3239,6 +3287,7 @@ function getAttributeCompletions(posistion) {
|
|
|
3239
3287
|
return attributes.map((label) => ({
|
|
3240
3288
|
kind,
|
|
3241
3289
|
label,
|
|
3290
|
+
documentation: attributeDescriptions[label.toLowerCase()],
|
|
3242
3291
|
textEdit: {
|
|
3243
3292
|
range,
|
|
3244
3293
|
newText: `${escapeIdentifierText(label)}=`
|
|
@@ -3310,8 +3359,12 @@ function getHoverContents(n) {
|
|
|
3310
3359
|
return { contents: `(node) ${getIdentifierText(n)}` };
|
|
3311
3360
|
case syntaxKind.Assignment: {
|
|
3312
3361
|
const assignment = parent;
|
|
3362
|
+
const left = getIdentifierText(assignment.leftId);
|
|
3363
|
+
const right = getIdentifierText(assignment.rightId);
|
|
3364
|
+
const desc = attributeDescriptions[left.toLowerCase()];
|
|
3365
|
+
const base = `(assignment) \`${left}\` = \`${right}\``;
|
|
3313
3366
|
return {
|
|
3314
|
-
contents:
|
|
3367
|
+
contents: desc ? `${base}\n\n${desc}` : base,
|
|
3315
3368
|
range: {
|
|
3316
3369
|
pos: assignment.pos,
|
|
3317
3370
|
end: assignment.end
|
|
@@ -3343,8 +3396,12 @@ function getHoverContents(n) {
|
|
|
3343
3396
|
}
|
|
3344
3397
|
case syntaxKind.IdEqualsIdStatement: {
|
|
3345
3398
|
const idEqId = parent;
|
|
3399
|
+
const left = getIdentifierText(idEqId.leftId);
|
|
3400
|
+
const right = getIdentifierText(idEqId.rightId);
|
|
3401
|
+
const desc = attributeDescriptions[left.toLowerCase()];
|
|
3402
|
+
const base = `(graph property) \`${left}\` = \`${right}\``;
|
|
3346
3403
|
return {
|
|
3347
|
-
contents:
|
|
3404
|
+
contents: desc ? `${base}\n\n${desc}` : base,
|
|
3348
3405
|
range: {
|
|
3349
3406
|
pos: idEqId.pos,
|
|
3350
3407
|
end: idEqId.end
|
|
@@ -3449,7 +3506,22 @@ function findDefinition(doc, sourceFile, position) {
|
|
|
3449
3506
|
range
|
|
3450
3507
|
};
|
|
3451
3508
|
}
|
|
3452
|
-
|
|
3509
|
+
}
|
|
3510
|
+
function findDeclaration(doc, sourceFile, position) {
|
|
3511
|
+
if (!sourceFile.symbols) throw "sourceFile is not bound";
|
|
3512
|
+
const g = sourceFile.graph;
|
|
3513
|
+
if (!g) return;
|
|
3514
|
+
const node = findNodeAtOffset(g, doc.offsetAt(position));
|
|
3515
|
+
if (!node) return;
|
|
3516
|
+
if (!isIdentifierNode(node)) return;
|
|
3517
|
+
const nodeSymbol = node.symbol;
|
|
3518
|
+
if (!nodeSymbol) throw "node.symbol is not bound";
|
|
3519
|
+
const firstUse = nodeSymbol.firstMention;
|
|
3520
|
+
if (!firstUse) return;
|
|
3521
|
+
return {
|
|
3522
|
+
uri: doc.uri,
|
|
3523
|
+
range: syntaxNodeToRange(doc, sourceFile, firstUse)
|
|
3524
|
+
};
|
|
3453
3525
|
}
|
|
3454
3526
|
//#endregion
|
|
3455
3527
|
//#region src/service/rename.ts
|
|
@@ -3476,6 +3548,40 @@ function isRenameableNode(node) {
|
|
|
3476
3548
|
function isRenamableIdentifier(node) {
|
|
3477
3549
|
return node.kind !== syntaxKind.QuotedTextIdentifier;
|
|
3478
3550
|
}
|
|
3551
|
+
//#endregion
|
|
3552
|
+
//#region src/service/selectionRange.ts
|
|
3553
|
+
function getSelectionRanges(doc, sourceFile, positions) {
|
|
3554
|
+
return positions.map((p) => buildSelectionRange(doc, sourceFile, p));
|
|
3555
|
+
}
|
|
3556
|
+
function buildSelectionRange(doc, sourceFile, position) {
|
|
3557
|
+
const empty = { range: {
|
|
3558
|
+
start: position,
|
|
3559
|
+
end: position
|
|
3560
|
+
} };
|
|
3561
|
+
const g = sourceFile.graph;
|
|
3562
|
+
if (!g) return empty;
|
|
3563
|
+
const leaf = findNodeAtOffset(g, doc.offsetAt(position), true);
|
|
3564
|
+
const chain = [];
|
|
3565
|
+
let curr = leaf;
|
|
3566
|
+
while (curr) {
|
|
3567
|
+
chain.push(curr);
|
|
3568
|
+
curr = curr.parent;
|
|
3569
|
+
}
|
|
3570
|
+
if (chain.length === 0) return empty;
|
|
3571
|
+
let result;
|
|
3572
|
+
let lastKey;
|
|
3573
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
3574
|
+
const range = syntaxNodeToRange(doc, sourceFile, chain[i]);
|
|
3575
|
+
const key = `${range.start.line}:${range.start.character}-${range.end.line}:${range.end.character}`;
|
|
3576
|
+
if (key === lastKey) continue;
|
|
3577
|
+
lastKey = key;
|
|
3578
|
+
result = {
|
|
3579
|
+
range,
|
|
3580
|
+
parent: result
|
|
3581
|
+
};
|
|
3582
|
+
}
|
|
3583
|
+
return result ?? empty;
|
|
3584
|
+
}
|
|
3479
3585
|
const subErrorCodeLength = 3;
|
|
3480
3586
|
function formatError(error) {
|
|
3481
3587
|
const subCode = (error.sub | 0).toString().padStart(subErrorCodeLength, "0");
|
|
@@ -3517,8 +3623,10 @@ function createService() {
|
|
|
3517
3623
|
hover,
|
|
3518
3624
|
findReferences,
|
|
3519
3625
|
findDefinition,
|
|
3626
|
+
findDeclaration,
|
|
3520
3627
|
renameSymbol,
|
|
3521
3628
|
getCompletions,
|
|
3629
|
+
getSelectionRanges,
|
|
3522
3630
|
getDocumentColors,
|
|
3523
3631
|
getColorRepresentations,
|
|
3524
3632
|
getCodeActions,
|