Skip to content

Commit 8cff3fe

Browse files
authored
use export function x(...) instead of export const x (microsoft#250927)
1 parent 73f8b07 commit 8cff3fe

24 files changed

+107
-178
lines changed

src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,22 @@ function getFocusedChatWidget(accessor: ServicesAccessor): IChatWidget | undefin
197197
/**
198198
* Gets `URI` of a instructions file open in an active editor instance, if any.
199199
*/
200-
const getActiveInstructionsFileUri = (accessor: ServicesAccessor): URI | undefined => {
200+
function getActiveInstructionsFileUri(accessor: ServicesAccessor): URI | undefined {
201201
const codeEditorService = accessor.get(ICodeEditorService);
202202
const model = codeEditorService.getActiveCodeEditor()?.getModel();
203203
if (model?.getLanguageId() === INSTRUCTIONS_LANGUAGE_ID) {
204204
return model.uri;
205205
}
206206
return undefined;
207-
};
207+
}
208208

209209
/**
210210
* Helper to register the `Attach Prompt` action.
211211
*/
212-
export const registerAttachPromptActions = () => {
212+
export function registerAttachPromptActions(): void {
213213
registerAction2(AttachInstructionsAction);
214214
registerAction2(ManageInstructionsFilesAction);
215-
};
215+
}
216216

217217

218218
export class ChatInstructionsPickerPick implements IChatContextPickerItem {

src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ class ManageModeAction extends Action2 {
4646
});
4747
}
4848

49-
public override async run(
50-
accessor: ServicesAccessor,
51-
): Promise<void> {
49+
public override async run(accessor: ServicesAccessor): Promise<void> {
5250
const openerService = accessor.get(IOpenerService);
5351
const instaService = accessor.get(IInstantiationService);
5452

@@ -69,6 +67,6 @@ class ManageModeAction extends Action2 {
6967
/**
7068
* Helper to register all the `Run Current Prompt` actions.
7169
*/
72-
export const registerChatModeActions = () => {
70+
export function registerChatModeActions(): void {
7371
registerAction2(ManageModeAction);
74-
};
72+
}

src/vs/workbench/contrib/chat/browser/promptSyntax/saveToPromptAction.ts

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class SaveToPromptAction extends Action2 {
139139
* Check if provided message belongs to the `save to prompt` slash
140140
* command itself that was run in the chat to invoke this action.
141141
*/
142-
const isSaveToPromptSlashCommand = (
143-
message: IParsedChatRequest,
144-
): boolean => {
142+
function isSaveToPromptSlashCommand(message: IParsedChatRequest): boolean {
145143
const { parts } = message;
146144
if (parts.length < 1) {
147145
return false;
@@ -157,14 +155,12 @@ const isSaveToPromptSlashCommand = (
157155
}
158156

159157
return true;
160-
};
158+
}
161159

162160
/**
163161
* Render the response part of a `request`/`response` turn pair.
164162
*/
165-
const renderResponse = (
166-
response: string,
167-
): string => {
163+
function renderResponse(response: string): string {
168164
// if response starts with a code block, add an extra new line
169165
// before it, to prevent full blockquote from being be broken
170166
const delimiter = (response.startsWith('```'))
@@ -176,25 +172,21 @@ const renderResponse = (
176172
const quotedResponse = response.replaceAll('\n', '\n> ');
177173

178174
return `> Copilot:${delimiter}${quotedResponse}`;
179-
};
175+
}
180176

181177
/**
182178
* Render a single `request`/`response` turn of the chat session.
183179
*/
184-
const renderTurn = (
185-
turn: ITurn,
186-
): string => {
180+
function renderTurn(turn: ITurn): string {
187181
const { request, response } = turn;
188182

189183
return `\n${request}\n\n${renderResponse(response)}`;
190-
};
184+
}
191185

192186
/**
193187
* Render the entire chat session as a markdown prompt.
194188
*/
195-
const renderPrompt = (
196-
turns: readonly ITurn[],
197-
): string => {
189+
function renderPrompt(turns: readonly ITurn[]): string {
198190
const content: string[] = [];
199191
const allTools = new Set<string>();
200192

@@ -225,28 +217,24 @@ const renderPrompt = (
225217
result.push('');
226218

227219
return result.join('\n');
228-
};
220+
}
229221

230222

231223
/**
232224
* Render the `tools` metadata inside prompt header.
233225
*/
234-
const renderTools = (
235-
tools: Set<string>,
236-
): string => {
226+
function renderTools(tools: Set<string>): string {
237227
const toolStrings = [...tools].map((tool) => {
238228
return `'${tool}'`;
239229
});
240230

241231
return `tools: [${toolStrings.join(', ')}]`;
242-
};
232+
}
243233

244234
/**
245235
* Render prompt header.
246236
*/
247-
const renderHeader = (
248-
tools: Set<string>,
249-
): string => {
237+
function renderHeader(tools: Set<string>): string {
250238
// skip rendering the header if no tools provided
251239
if (tools.size === 0) {
252240
return '';
@@ -257,7 +245,7 @@ const renderHeader = (
257245
renderTools(tools),
258246
'---',
259247
].join('\n');
260-
};
248+
}
261249

262250
/**
263251
* Interface for a single `request`/`response` turn
@@ -274,19 +262,19 @@ interface ITurn {
274262
* function instead of {@link SAVE_TO_PROMPT_ACTION_ID} directly to
275263
* encapsulate/enforce the correct options to be passed to the action.
276264
*/
277-
export const runSaveToPromptAction = async (
265+
export function runSaveToPromptAction(
278266
options: ISaveToPromptActionOptions,
279267
commandService: ICommandService,
280-
) => {
281-
return await commandService.executeCommand(
268+
) {
269+
return commandService.executeCommand(
282270
SAVE_TO_PROMPT_ACTION_ID,
283271
options,
284272
);
285-
};
273+
}
286274

287275
/**
288276
* Helper to register all the `Save Prompt` actions.
289277
*/
290-
export const registerSaveToPromptActions = () => {
278+
export function registerSaveToPromptActions(): void {
291279
registerAction2(SaveToPromptAction);
292-
};
280+
}

src/vs/workbench/contrib/chat/common/promptSyntax/codecs/base/frontMatterCodec/parsers/frontMatterRecord/frontMatterRecord.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,10 @@ export class PartialFrontMatterRecord extends ParserBase<TSimpleDecoderToken, TN
199199
* Callback to check if a current token should end a
200200
* record value that is a generic sequence of tokens.
201201
*/
202-
const shouldEndTokenSequence = (
203-
token: BaseToken,
204-
): token is (NewLine | CarriageReturn | FormFeed) => {
202+
function shouldEndTokenSequence(token: BaseToken): token is (NewLine | CarriageReturn | FormFeed) {
205203
return (
206204
(token instanceof NewLine)
207205
|| (token instanceof CarriageReturn)
208206
|| (token instanceof FormFeed)
209207
);
210-
};
208+
}

src/vs/workbench/contrib/chat/common/promptSyntax/codecs/base/utils/objectStream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ export class ObjectStream<T extends object> extends ObservableDisposable impleme
215215
/**
216216
* Create a generator out of a provided array.
217217
*/
218-
export const arrayToGenerator = <T extends NonNullable<unknown>>(array: T[]): Generator<T, undefined> => {
218+
export function arrayToGenerator<T extends NonNullable<unknown>>(array: T[]): Generator<T, undefined> {
219219
return (function* (): Generator<T, undefined> {
220220
for (const item of array) {
221221
yield item;
222222
}
223223
})();
224-
};
224+
}

src/vs/workbench/contrib/chat/common/promptSyntax/codecs/base/utils/objectStreamFromTextModel.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export function objectStreamFromTextModel(
2121
/**
2222
* Create a generator out of a provided text model.
2323
*/
24-
const modelToGenerator = (
25-
model: ITextModel,
26-
): Generator<VSBuffer, undefined> => {
24+
function modelToGenerator(model: ITextModel): Generator<VSBuffer, undefined> {
2725
return (function* (): Generator<VSBuffer, undefined> {
2826
const totalLines = model.getLineCount();
2927
let currentLine = 1;
@@ -45,4 +43,4 @@ const modelToGenerator = (
4543
currentLine++;
4644
}
4745
})();
48-
};
46+
}

src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderDiagnosticsProvider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ class PromptHeaderDiagnosticsProvider extends ProviderInstanceBase {
8080
/**
8181
* Convert a provided diagnostic object into a marker data object.
8282
*/
83-
const toMarker = (
84-
diagnostic: TDiagnostic,
85-
): IMarkerData => {
83+
function toMarker(diagnostic: TDiagnostic): IMarkerData {
8684
if (diagnostic instanceof PromptMetadataWarning) {
8785
return {
8886
message: diagnostic.message,
@@ -103,7 +101,7 @@ const toMarker = (
103101
diagnostic,
104102
`Unknown prompt metadata diagnostic type '${diagnostic}'.`,
105103
);
106-
};
104+
}
107105

108106
/**
109107
* The class that manages creation and disposal of {@link PromptHeaderDiagnosticsProvider}

src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptLinkDiagnosticsProvider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ class PromptLinkDiagnosticsProvider extends ProviderInstanceBase {
8383
* - if the original error is of `NotPromptFile` type - we don't want to
8484
* show diagnostic markers for non-prompt file links in the prompts
8585
*/
86-
const toMarker = (
87-
link: IPromptFileReference,
88-
): IMarkerData => {
86+
function toMarker(link: IPromptFileReference): IMarkerData {
8987
const { topError, linkRange } = link;
9088

9189
// a sanity check because this function must be
@@ -115,7 +113,7 @@ const toMarker = (
115113
severity,
116114
...linkRange,
117115
};
118-
};
116+
}
119117

120118
/**
121119
* The class that manages creation and disposal of {@link PromptLinkDiagnosticsProvider}

src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptPathAutocompletion.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ type TTriggerCharacter = ':' | '.' | '/';
5151
/**
5252
* Finds a file reference that suites the provided `position`.
5353
*/
54-
const findFileReference = (
55-
references: readonly TPromptReference[],
56-
position: Position,
57-
): IPromptFileReference | undefined => {
54+
function findFileReference(references: readonly TPromptReference[], position: Position): IPromptFileReference | undefined {
5855
for (const reference of references) {
5956
const { range } = reference;
6057

@@ -78,7 +75,7 @@ const findFileReference = (
7875
}
7976

8077
return undefined;
81-
};
78+
}
8279

8380
/**
8481
* Provides reference paths autocompletion for the `#file:` variables inside prompts.

src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/providerInstanceManagerBase.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,18 @@ export abstract class ProviderInstanceManagerBase<TInstance extends ProviderInst
147147
/**
148148
* Check if provided language ID is one of the prompt file languages.
149149
*/
150-
const isPromptFile = (
151-
languageId: string,
152-
): boolean => {
150+
function isPromptFile(languageId: string): boolean {
153151
return [
154152
PROMPT_LANGUAGE_ID,
155153
INSTRUCTIONS_LANGUAGE_ID,
156154
MODE_LANGUAGE_ID,
157155
].includes(languageId);
158-
};
156+
}
159157

160158
/**
161159
* Check if a provided model is used for prompt files.
162160
*/
163-
const isPromptFileModel = (
164-
model: IEditorModel,
165-
): model is ITextModel => {
161+
function isPromptFileModel(model: IEditorModel): model is ITextModel {
166162
// we support only `text editors` for now so filter out `diff` ones
167163
if ('modified' in model || 'model' in model) {
168164
return false;
@@ -177,4 +173,4 @@ const isPromptFileModel = (
177173
}
178174

179175
return true;
180-
};
176+
}

0 commit comments

Comments
 (0)