Skip to content

Commit 6271f4e

Browse files
authored
Make including JS Doc optional (#1186)
1 parent 28ef807 commit 6271f4e

File tree

15 files changed

+185
-90
lines changed

15 files changed

+185
-90
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,16 @@
28272827
],
28282828
"markdownDescription": "%github.copilot.chat.languageContext.typescript.items%"
28292829
},
2830+
"github.copilot.chat.languageContext.typescript.includeDocumentation": {
2831+
"type": "boolean",
2832+
"default": false,
2833+
"scope": "resource",
2834+
"tags": [
2835+
"experimental",
2836+
"onExP"
2837+
],
2838+
"markdownDescription": "%github.copilot.chat.languageContext.typescript.includeDocumentation%"
2839+
},
28302840
"github.copilot.chat.languageContext.typescript.cacheTimeout": {
28312841
"type": "number",
28322842
"default": 500,

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
"github.copilot.chat.completionContext.typescript.mode": "The execution mode of the TypeScript Copilot context provider.",
230230
"github.copilot.chat.languageContext.typescript.enabled": "Enables the TypeScript language context provider for inline completions",
231231
"github.copilot.chat.languageContext.typescript.items": "Controls which kind of items are included in the TypeScript language context provider.",
232+
"github.copilot.chat.languageContext.typescript.includeDocumentation": "Controls whether to include documentation comments in the generated code snippets.",
232233
"github.copilot.chat.languageContext.typescript.cacheTimeout": "The cache population timeout for the TypeScript language context provider in milliseconds. The default is 500 milliseconds.",
233234
"github.copilot.chat.languageContext.fix.typescript.enabled": "Enables the TypeScript language context provider for /fix commands",
234235
"github.copilot.chat.languageContext.inline.typescript.enabled": "Enables the TypeScript language context provider for inline chats (both generate and edit)",

src/extension/typescriptContext/common/serverProtocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ export interface ComputeContextRequestArgs extends tt.server.protocol.FileLocati
399399
timeBudget: number;
400400
primaryCharacterBudget: number;
401401
secondaryCharacterBudget: number;
402+
includeDocumentation?: boolean;
402403
neighborFiles?: readonly FilePath[];
403404
clientSideRunnableResults?: readonly CachedContextRunnableResult[];
404405
}

src/extension/typescriptContext/serverPlugin/src/common/baseContextProviders.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,15 @@ export class TypeOfExpressionRunnable extends AbstractContextRunnable {
523523
if (returnTypeSymbol === undefined) {
524524
continue;
525525
}
526-
const snippetBuilder = new CodeSnippetBuilder(this.session, this.symbols, sourceFile);
526+
const snippetBuilder = new CodeSnippetBuilder(this.context, this.symbols, sourceFile);
527527
snippetBuilder.addTypeSymbol(returnTypeSymbol, returnTypeSymbol.name);
528528
result.addSnippet(snippetBuilder, this.location, undefined);
529529
}
530530
const typeSymbol = type.getSymbol();
531531
if (typeSymbol === undefined) {
532532
return;
533533
}
534-
const snippetBuilder = new CodeSnippetBuilder(this.session, this.symbols, sourceFile);
534+
const snippetBuilder = new CodeSnippetBuilder(this.context, this.symbols, sourceFile);
535535
snippetBuilder.addTypeSymbol(typeSymbol, typeSymbol.name);
536536
result.addSnippet(snippetBuilder, this.location, undefined);
537537
}

src/extension/typescriptContext/serverPlugin/src/common/classContextProvider.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ts = TS();
99
import { CodeSnippetBuilder } from './code';
1010
import { AbstractContextRunnable, ComputeCost, ContextProvider, ContextResult, Search, SnippetLocation, type ComputeContextSession, type ContextRunnableCollector, type RequestContext, type RunnableResult } from './contextProvider';
1111
import { EmitMode, Priorities, SpeculativeKind } from './protocol';
12-
import tss, { ClassDeclarations, ReferencedByVisitor, Symbols } from './typescripts';
12+
import tss, { ClassDeclarations, ReferencedByVisitor, Symbols, type DirectSuperSymbolInfo } from './typescripts';
1313

1414
export type TypeInfo = {
1515
symbol: tt.Symbol;
@@ -284,9 +284,23 @@ export class SuperClassRunnable extends AbstractContextRunnable {
284284
return;
285285
}
286286

287-
const [extendsClass, extendsName] = symbols.getExtendsSymbol(clazz);
288-
if (extendsClass !== undefined && extendsName !== undefined) {
289-
this.handleSymbol(extendsClass, extendsName);
287+
const directSuperSymbolInfo: DirectSuperSymbolInfo | undefined = symbols.getDirectSuperSymbols(clazz);
288+
if (directSuperSymbolInfo === undefined) {
289+
return;
290+
}
291+
if (directSuperSymbolInfo.extends !== undefined) {
292+
const { symbol, name } = directSuperSymbolInfo.extends;
293+
if (symbol !== undefined && name !== undefined) {
294+
this.handleSymbol(symbol, name);
295+
}
296+
}
297+
if (directSuperSymbolInfo.implements !== undefined) {
298+
for (const impl of directSuperSymbolInfo.implements) {
299+
const { symbol, name } = impl;
300+
if (symbol !== undefined && name !== undefined) {
301+
this.handleSymbol(symbol, name);
302+
}
303+
}
290304
}
291305
}
292306
}
@@ -323,7 +337,7 @@ class SimilarClassRunnable extends AbstractContextRunnable {
323337
if (foundInProgram === undefined || similarClass === undefined) {
324338
return;
325339
}
326-
const code = new CodeSnippetBuilder(this.session, this.context.getSymbols(foundInProgram), classDeclaration.getSourceFile());
340+
const code = new CodeSnippetBuilder(this.context, this.context.getSymbols(foundInProgram), classDeclaration.getSourceFile());
327341
code.addDeclaration(similarClass.declaration);
328342
result.addSnippet(code, this.location, undefined);
329343
}

0 commit comments

Comments
 (0)