Skip to content

Commit 9ccd8a4

Browse files
committed
refactor(scriptProperties): enhance hover content formatting
Class ScriptProperties: ~update hover content to include type annotations for variables and keywords; ~improve property display formatting
1 parent aace5c6 commit 9ccd8a4

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

extensions/scripts/src/scripts/scriptProperties.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,14 +1324,14 @@ export class ScriptProperties {
13241324
let fullContentOnStep = firstPart;
13251325

13261326
if (isVariableBased) {
1327-
hoverContent.appendMarkdown(`**${firstPart}**:\n\n`);
1327+
hoverContent.appendMarkdown(`**${firstPart}**(*variable*):\n\n`);
13281328
} else {
13291329
// Look for keyword
13301330
currentContentType = this.getKeyword(firstPart, schema);
13311331

13321332
if (currentContentType) {
13331333
// Add keyword/type information
1334-
hoverContent.appendMarkdown(`**${currentContentType.name}**:`);
1334+
hoverContent.appendMarkdown(`**${currentContentType.name}**(*keyword*):`);
13351335
if (currentContentType instanceof KeywordEntry && currentContentType.details) {
13361336
hoverContent.appendMarkdown(` *${currentContentType.details}*:`);
13371337
}
@@ -1399,13 +1399,10 @@ export class ScriptProperties {
13991399
}
14001400
for (const property of resultProperties) {
14011401
if (isVariations) {
1402-
hoverContent.appendMarkdown(`- :\n\n`);
1402+
hoverContent.appendMarkdown(`- **${property.owner.name}**(*type*):\n\n`);
14031403
}
1404-
hoverContent.appendMarkdown(`${indent}- *Property`);
1405-
if (!currentContentType && property.owner) {
1406-
hoverContent.appendMarkdown(` of ${property.owner.name}`);
1407-
}
1408-
hoverContent.appendMarkdown(`:*\n\n ${indent}- **${property.name.replace(/([<>])/g, '\\$1')}**`);
1404+
hoverContent.appendMarkdown(`${indent}- *Property:*\n\n`);
1405+
hoverContent.appendMarkdown(` ${indent}- **${property.name.replace(/([<>])/g, '\\$1')}**`);
14091406
if (property.details) {
14101407
hoverContent.appendMarkdown(`: ${property.details}\n\n`);
14111408
}
@@ -1417,11 +1414,10 @@ export class ScriptProperties {
14171414
continue;
14181415
}
14191416
if (!isLastPart) {
1420-
currentContentType = result.newContentType;
1421-
if (currentContentType) {
1422-
hoverContent.appendMarkdown(`${indent}**${currentContentType.name}**:`);
1423-
if (currentContentType instanceof KeywordEntry && currentContentType.details) {
1424-
hoverContent.appendMarkdown(` *${currentContentType.details}*:`);
1417+
if (result.newContentType) {
1418+
hoverContent.appendMarkdown(`${indent}**${result.newContentType.name}**(*type*):`);
1419+
if (result.newContentType instanceof KeywordEntry && result.newContentType.details) {
1420+
hoverContent.appendMarkdown(` *${result.newContentType.details}*:`);
14251421
}
14261422
hoverContent.appendMarkdown('\n\n');
14271423
} else if (result.property.name === '$<variable>' && variablePatternExact.test(part)) {
@@ -1438,6 +1434,12 @@ export class ScriptProperties {
14381434
range: new vscode.Range(startPosition, endPosition.translate(0, -expressionLength + contentOnStepLength)),
14391435
};
14401436
}
1437+
if (!isLastPart) {
1438+
currentContentType = result.newContentType;
1439+
prefix = ''; // Reset prefix for next property step
1440+
types = [];
1441+
properties = [];
1442+
}
14411443
} else {
14421444
prefix = prefix ? `${prefix}.${part}` : part;
14431445
types = result.newTypes || [];

0 commit comments

Comments
 (0)