Skip to content

Commit

Permalink
Improve API
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Jul 2, 2024
1 parent 34f86f3 commit a82458d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions packages/preferences/src/browser/util/preference-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ import { injectable } from '@theia/core/shared/inversify';
export interface PreferenceLayout {
id: string;
label: string;
children?: PreferenceLayoutItem[];
settings?: string[];
}

export interface PreferenceLayoutItem {
id: string;
label: string;
children?: PreferenceLayout[];
settings?: string[];
}

Expand Down Expand Up @@ -337,17 +331,18 @@ export class PreferenceLayoutProvider {
return [...this.getLayout(), this.getCommonlyUsedLayout()].some(e => e.id === id);
}

getLayoutItem(preferenceId: string): PreferenceLayoutItem | undefined {
getLayoutForPreference(preferenceId: string): PreferenceLayout | undefined {
const layout = this.getLayout();
for (const section of layout) {
const item = this.findItemInSection(section, preferenceId);
if (item) {
return item;
}
}
return undefined;
}

protected findItemInSection(section: PreferenceLayout, preferenceId: string): PreferenceLayoutItem | undefined {
protected findItemInSection(section: PreferenceLayout, preferenceId: string): PreferenceLayout | undefined {
// First check whether any of its children match the preferenceId.
if (section.children) {
for (const child of section.children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class PreferenceTreeGenerator {
for (const propertyName of propertyNames) {
const property = preferencesSchema.properties[propertyName];
if (!this.preferenceConfigs.isSectionName(propertyName) && !OVERRIDE_PROPERTY_PATTERN.test(propertyName) && !property.deprecationMessage) {
const layoutItem = this.layoutProvider.getLayoutItem(propertyName);
const layoutItem = this.layoutProvider.getLayoutForPreference(propertyName);
const labels = layoutItem ? layoutItem.id.split('.') : propertyName.split('.');
// If a title is set, this property belongs to the 'extensions' category
const groupID = property.title ? this.defaultTopLevelCategory : this.getGroupName(labels);
Expand Down

0 comments on commit a82458d

Please sign in to comment.