Address comments.
This commit is contained in:
@@ -367,6 +367,7 @@ export type AllExtensionCommands = BaseCommands &
|
||||
QueryEditorCommands &
|
||||
ResultsViewCommands &
|
||||
QueryHistoryCommands &
|
||||
LanguageSelectionCommands &
|
||||
LocalDatabasesCommands &
|
||||
DebuggerCommands &
|
||||
VariantAnalysisCommands &
|
||||
|
||||
@@ -43,11 +43,15 @@ export class LanguageContextStore extends DisposableObject {
|
||||
);
|
||||
}
|
||||
|
||||
// shouldInclude should return true if the given language should be included.
|
||||
// That means that either the given language is selected or the "All" option is selected.
|
||||
public shouldInclude(language: QueryLanguage | undefined): boolean {
|
||||
return this.languageFilter === "All" || this.languageFilter === language;
|
||||
}
|
||||
|
||||
public selectedLanguage(language: QueryLanguage | undefined): boolean {
|
||||
// isSelectedLanguage returns true if the given language is selected. If no language
|
||||
// is given then it returns true if the "All" option is selected.
|
||||
public isSelectedLanguage(language: QueryLanguage | undefined): boolean {
|
||||
return (
|
||||
(this.languageFilter === "All" && language === undefined) ||
|
||||
this.languageFilter === language
|
||||
|
||||
@@ -51,12 +51,12 @@ export class LanguageSelectionTreeDataProvider
|
||||
public constructor(private readonly languageContext: LanguageContextStore) {
|
||||
super();
|
||||
|
||||
this.treeItems = this.createTree(languageContext);
|
||||
this.treeItems = this.createTree();
|
||||
|
||||
// If the language context changes, we need to update the tree.
|
||||
this.push(
|
||||
this.languageContext.onLanguageContextChanged(() => {
|
||||
this.treeItems = this.createTree(languageContext);
|
||||
this.treeItems = this.createTree();
|
||||
this.onDidChangeTreeDataEmitter.fire();
|
||||
}),
|
||||
);
|
||||
@@ -80,13 +80,11 @@ export class LanguageSelectionTreeDataProvider
|
||||
}
|
||||
}
|
||||
|
||||
private createTree(
|
||||
languageContext: LanguageContextStore,
|
||||
): LanguageSelectionTreeViewItem[] {
|
||||
private createTree(): LanguageSelectionTreeViewItem[] {
|
||||
return ALL_LANGUAGE_SELECTION_OPTIONS.map((language) => {
|
||||
return new LanguageSelectionTreeViewItem(
|
||||
language,
|
||||
languageContext.selectedLanguage(language),
|
||||
this.languageContext.isSelectedLanguage(language),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export class LanguageSelectionPanel extends DisposableObject {
|
||||
super();
|
||||
|
||||
const dataProvider = new LanguageSelectionTreeDataProvider(languageContext);
|
||||
this.push(dataProvider);
|
||||
|
||||
const treeView = window.createTreeView("codeQLLanguageSelection", {
|
||||
treeDataProvider: dataProvider,
|
||||
|
||||
@@ -40,16 +40,13 @@ describe("LanguageSelectionTreeDataProvider", () => {
|
||||
return getLanguageDisplayName(language);
|
||||
}),
|
||||
];
|
||||
// Note that the internal order of C# and C / C++ is different from what is shown in the UI.
|
||||
[expectedLanguageNames[1], expectedLanguageNames[2]] = [
|
||||
expectedLanguageNames[2],
|
||||
expectedLanguageNames[1],
|
||||
];
|
||||
const actualLanguagesNames = dataProvider.getChildren().map((item) => {
|
||||
return item.label;
|
||||
});
|
||||
|
||||
expect(actualLanguagesNames).toEqual(expectedLanguageNames);
|
||||
// Note that the internal order of C# and C / C++ is different from what is shown in the UI.
|
||||
// So we sort to make sure we can compare the two lists.
|
||||
expect(actualLanguagesNames.sort()).toEqual(expectedLanguageNames.sort());
|
||||
});
|
||||
|
||||
it("default selection is All languages", async () => {
|
||||
|
||||
Reference in New Issue
Block a user