Skip to content

Commit 804be12

Browse files
committed
Address PR feedback
1 parent 9a1d5aa commit 804be12

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

Extension/src/Debugger/configurationProvider.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,20 +546,14 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
546546
return;
547547
}
548548

549-
const fileExt: string = path.extname(editor.document.fileName);
550-
if (!fileExt) {
551-
DebugConfigurationProvider.detectedBuildTasks = emptyTasks;
552-
return;
553-
}
554-
555549
// Don't offer tasks for header files.
556550
const isHeader: boolean = util.isHeaderFile(editor.document.uri);
557551
if (isHeader) {
558552
DebugConfigurationProvider.detectedBuildTasks = emptyTasks;
559553
return;
560554
}
561555

562-
// Don't offer tasks if the active file's extension is not a recognized C/C++ extension.
556+
// Don't offer tasks if the active file is not a recognized C/C++ source file.
563557
const fileIsCpp: boolean = util.isCppFile(editor.document.uri, editor.document.languageId);
564558
const fileIsC: boolean = util.isCFile(editor.document.uri, editor.document.languageId);
565559
if (!(fileIsCpp || fileIsC)) {

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,21 @@ export class CppBuildTaskProvider implements TaskProvider {
7373
return _task;
7474
}
7575

76-
// Generate tasks to build the current file based on the user's detected compilers, the user's compilerPath setting, and the current file's extension.
76+
// Generate tasks to build the current file based on the user's detected compilers, compilerPath setting, and file type.
7777
public async getTasks(appendSourceToName: boolean = false): Promise<CppBuildTask[]> {
7878
const editor: TextEditor | undefined = window.activeTextEditor;
7979
const emptyTasks: CppBuildTask[] = [];
8080
if (!editor) {
8181
return emptyTasks;
8282
}
8383

84-
const fileExt: string = path.extname(editor.document.fileName);
85-
if (!fileExt) {
86-
return emptyTasks;
87-
}
88-
8984
// Don't offer tasks for header files.
9085
const isHeader: boolean = util.isHeaderFile(editor.document.uri);
9186
if (isHeader) {
9287
return emptyTasks;
9388
}
9489

95-
// Don't offer tasks if the active file's extension is not a recognized C/C++ extension.
90+
// Don't offer tasks if the active file is not a recognized C/C++ source file.
9691
const fileIsCpp: boolean = util.isCppFile(editor.document.uri, editor.document.languageId);
9792
const fileIsC: boolean = util.isCFile(editor.document.uri, editor.document.languageId);
9893
if (!(fileIsCpp || fileIsC)) {

Extension/test/unit/fileType.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe('file type mappings', () => {
5353
],
5454
filenames: [
5555
{ name: 'foo.h', kind: 'source', language: 'c' },
56+
{ name: 'build', kind: 'source', language: 'cpp' },
5657
{ name: 'vector', kind: 'header' },
5758
{ name: 'kernel.custom', kind: 'source', language: 'cuda' }
5859
]
@@ -62,11 +63,13 @@ describe('file type mappings', () => {
6263
deepStrictEqual(classifyFilePath('module.CPPM'), { name: '.cppm', kind: 'source', language: 'cpp' });
6364
deepStrictEqual(classifyFilePath('file.C'), { name: '.C', kind: 'source', language: 'cpp' });
6465
deepStrictEqual(classifyFilePath('foo.h'), { name: 'foo.h', kind: 'source', language: 'c' });
66+
deepStrictEqual(classifyFilePath('build'), { name: 'build', kind: 'source', language: 'cpp' });
6567
deepStrictEqual(classifyFilePath('VECTOR'), { name: 'vector', kind: 'header' });
6668
deepStrictEqual(classifyFilePath('kernel.custom'), { name: 'kernel.custom', kind: 'source', language: 'cuda' });
6769
equal(classifyFilePath('Makefile'), undefined);
6870
equal(isTagParsableFile('schema.idl'), true);
6971
equal(isTagParsableFile('kernel.custom'), true);
72+
equal(isTagParsableFile('build'), true);
7073
equal(isTagParsableFile('vector'), true);
7174
equal(isTagParsableFile('unknown.txt'), false);
7275
});
@@ -96,5 +99,6 @@ describe('file type mappings', () => {
9699
deepStrictEqual(classifyFilePath('file.h', 'c'), { name: '.h', kind: 'header', language: 'cpp' });
97100
deepStrictEqual(classifyFilePath('file.special', 'c'), { name: '', kind: 'source', language: 'c' });
98101
deepStrictEqual(classifyFilePath('file.special', 'cuda-cpp'), { name: '', kind: 'source', language: 'cuda' });
102+
deepStrictEqual(classifyFilePath('extensionless', 'cpp'), { name: '', kind: 'source', language: 'cpp' });
99103
});
100104
});

0 commit comments

Comments
 (0)