Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import path from 'path';

import URI from 'vscode-uri';
import { IConnection, TextDocuments } from 'vscode-languageserver';
import { IConnection, MarkupKind, TextDocuments } from 'vscode-languageserver';
import formatMessage from 'format-message';
import {
Diagnostic,
Expand All @@ -30,6 +30,7 @@ import isEqual from 'lodash/isEqual';
import { filterTemplateDiagnostics, isValid, lgUtil } from '@bfc/indexers';
import { MemoryResolver, ResolverResource, LgFile } from '@bfc/shared';
import { buildInFunctionsMap } from '@bfc/built-in-functions';
import { LgTemplate } from '@botframework-composer/types';
Comment thread
cosmicshuai marked this conversation as resolved.

import { LgParser } from './lgParser';
import {
Expand Down Expand Up @@ -341,7 +342,12 @@ export class LGServer {
let word = document.getText(wordRange);
const matchItem = allTemplates.find((u) => u.name === word);
if (matchItem) {
const hoveritem: Hover = { contents: [matchItem.body] };
const hoveritem: Hover = {
contents: {
kind: MarkupKind.Markdown,
value: this.buildHoverTemplateInfo(matchItem),
},
};
return Promise.resolve(hoveritem);
}
if (word.startsWith('builtin.')) {
Expand All @@ -367,6 +373,18 @@ export class LGServer {
return Promise.resolve(null);
}

private buildHoverTemplateInfo(template: LgTemplate) {
let templateName = '';
if (template.parameters.length > 0) {
templateName = `\\# ${template.name}(${template.parameters.join(', ')})`;
} else {
templateName = `\\# ${template.name}`;
}

const templateBody = template.body.replace(/-/g, '\\-').replace(/\r?\n/g, '\n\n');
Comment thread
cosmicshuai marked this conversation as resolved.
Outdated
return [templateName, templateBody].join('\n\n');
}

private getExplicitReturnType(numReturnType: number): string[] {
const result: string[] = [];
const mapping = [
Expand Down