33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import { Attachment } from '@github/copilot/sdk' ;
67import * as l10n from '@vscode/l10n' ;
78import type { ChatPromptReference } from 'vscode' ;
89import { isLocation } from '../../../util/common/types' ;
910import { coalesce } from '../../../util/vs/base/common/arrays' ;
1011import { Codicon } from '../../../util/vs/base/common/codicons' ;
12+ import { ResourceSet } from '../../../util/vs/base/common/map' ;
1113import { basename } from '../../../util/vs/base/common/resources' ;
1214import { isNumber , isString } from '../../../util/vs/base/common/types' ;
1315import { URI } from '../../../util/vs/base/common/uri' ;
1416import { Range as InternalRange } from '../../../util/vs/editor/common/core/range' ;
1517import { SymbolKind } from '../../../util/vs/workbench/api/common/extHostTypes/symbolInformation' ;
1618import { ChatReferenceDiagnostic , Diagnostic , DiagnosticRelatedInformation , DiagnosticSeverity , Range , Uri } from '../../../vscodeTypes' ;
17- import { Attachment } from '@github/copilot/sdk' ;
18- import { ResourceSet } from '../../../util/vs/base/common/map' ;
1919
20+ /**
21+ * Converts a ChatPromptReference into a PromptVariable entry that is used in VS code.
22+ */
2023export function convertReferenceToVariable ( ref : ChatPromptReference , attachments : readonly Attachment [ ] ) {
2124 const value = ref . value ;
2225 const range = ref . range ? { start : ref . range [ 0 ] , endExclusive : ref . range [ 1 ] } : undefined ;
@@ -63,8 +66,8 @@ export function convertReferenceToVariable(ref: ChatPromptReference, attachments
6366 }
6467
6568 const folders = new ResourceSet ( attachments . filter ( att => att . type === 'directory' ) . map ( att => URI . file ( att . path ) ) ) ;
66- const isFile = URI . isUri ( value ) || ( value && typeof value === 'object' && 'uri' in value ) ;
67- const isFolder = isFile && URI . isUri ( value ) && ( value . path . endsWith ( '/' ) || folders . has ( value ) ) ;
69+ const isFile = URI . isUri ( value ) || isLocation ( value ) ;
70+ const isFolder = URI . isUri ( value ) && ( value . path . endsWith ( '/' ) || folders . has ( value ) ) ;
6871 return {
6972 id : ref . id ,
7073 name : ref . name ,
@@ -204,7 +207,7 @@ namespace DiagnosticConverter {
204207 message : value . message ,
205208 source : value . source ,
206209 code,
207- severity : DiagnosticSeverityConveter . from ( value . severity ) ,
210+ severity : DiagnosticSeverityConverter . from ( value . severity ) ,
208211 relatedInformation : value . relatedInformation && value . relatedInformation . map ( DiagnosticRelatedInformationConverter . from ) ,
209212 tags : Array . isArray ( value . tags ) ? coalesce ( value . tags . map ( DiagnosticTagConverter . from ) ) : undefined ,
210213 } ;
@@ -221,7 +224,7 @@ namespace DiagnosticRelatedInformationConverter {
221224 }
222225}
223226
224- namespace DiagnosticSeverityConveter {
227+ namespace DiagnosticSeverityConverter {
225228 export enum MarkerSeverity {
226229 Hint = 1 ,
227230 Info = 2 ,
0 commit comments