Commit 907a9c2 1 parent 43a6b62 commit 907a9c2 Copy full SHA for 907a9c2
File tree 7 files changed +20
-15
lines changed
plugin-ext/src/hosted/node/scanners
7 files changed +20
-15
lines changed Original file line number Diff line number Diff line change 7
7
<a name="breaking_changes_1.18.0">[Breaking Changes:](#breaking_changes_1.18.0)</a>
8
8
9
9
- [core] added `BreadcrumbsRendererFactory` to constructor arguments of `DockPanelRenderer` and `ToolbarAwareTabBar`. [#9920](https://github.com/eclipse-theia/theia/pull/9920)
10
+ - [task] `TaskDefinition.properties.required` is now optional to align with the specification [#10015](https://github.com/eclipse-theia/theia/pull/10015)
10
11
11
12
## v1.17.2 - 9/1/2021
12
13
Original file line number Diff line number Diff line change @@ -698,7 +698,7 @@ export class TheiaPluginScanner implements PluginScanner {
698
698
taskType : definitionContribution . type ,
699
699
source : pluginName ,
700
700
properties : {
701
- required : definitionContribution . required ,
701
+ required : definitionContribution . required || [ ] ,
702
702
all : propertyKeys ,
703
703
schema : definitionContribution
704
704
}
Original file line number Diff line number Diff line change @@ -101,12 +101,12 @@ export class ProvidedTaskConfigurations {
101
101
let highest = - 1 ;
102
102
const tasks = await this . getTasks ( token ) ;
103
103
for ( const task of tasks ) { // find detected tasks that match the `definition`
104
- let score = 0 ;
105
- if ( ! definition . properties . required . every ( requiredProp => customization [ requiredProp ] !== undefined ) ) {
104
+ const required = definition . properties . required || [ ] ;
105
+ if ( ! required . every ( requiredProp => customization [ requiredProp ] !== undefined ) ) {
106
106
continue ;
107
107
}
108
- score += definition . properties . required . length ; // number of required properties
109
- const requiredProps = new Set ( definition . properties . required ) ;
108
+ let score = required . length ; // number of required properties
109
+ const requiredProps = new Set ( required ) ;
110
110
// number of optional properties
111
111
score += definition . properties . all . filter ( p => ! requiredProps . has ( p ) && customization [ p ] !== undefined ) . length ;
112
112
if ( score >= highest ) {
Original file line number Diff line number Diff line change @@ -249,10 +249,9 @@ export class TaskConfigurations implements Disposable {
249
249
if ( hasCustomization ) {
250
250
const taskDefinition = this . taskDefinitionRegistry . getDefinition ( taskConfig ) ;
251
251
if ( taskDefinition ) {
252
- const cus = customizationByType . filter ( customization =>
253
- taskDefinition . properties . required . every ( rp => customization [ rp ] === taskConfig [ rp ] )
254
- ) [ 0 ] ; // Only support having one customization per task
255
- return cus ;
252
+ const required = taskDefinition . properties . required || [ ] ;
253
+ // Only support having one customization per task.
254
+ return customizationByType . find ( customization => required . every ( property => customization [ property ] === taskConfig [ property ] ) ) ;
256
255
}
257
256
}
258
257
return undefined ;
Original file line number Diff line number Diff line change @@ -71,12 +71,12 @@ export class TaskDefinitionRegistry {
71
71
let matchedDefinition : TaskDefinition | undefined ;
72
72
let highest = - 1 ;
73
73
for ( const def of definitions ) {
74
- let score = 0 ;
75
- if ( ! def . properties . required . every ( requiredProp => taskConfiguration [ requiredProp ] !== undefined ) ) {
74
+ const required = def . properties . required || [ ] ;
75
+ if ( ! required . every ( requiredProp => taskConfiguration [ requiredProp ] !== undefined ) ) {
76
76
continue ;
77
77
}
78
- score += def . properties . required . length ; // number of required properties
79
- const requiredProps = new Set ( def . properties . required ) ;
78
+ let score = required . length ; // number of required properties
79
+ const requiredProps = new Set ( required ) ;
80
80
// number of optional properties
81
81
score += def . properties . all . filter ( p => ! requiredProps . has ( p ) && taskConfiguration [ p ] !== undefined ) . length ;
82
82
if ( score > highest ) {
Original file line number Diff line number Diff line change @@ -168,8 +168,9 @@ export class TaskSchemaUpdater implements JsonSchemaContribution {
168
168
description : 'The task type to customize'
169
169
} ;
170
170
customizedDetectedTask . properties ! . type = taskType ;
171
+ const required = def . properties . required || [ ] ;
171
172
def . properties . all . forEach ( taskProp => {
172
- if ( ! ! def . properties . required . find ( requiredProp => requiredProp === taskProp ) ) { // property is mandatory
173
+ if ( required . find ( requiredProp => requiredProp === taskProp ) ) { // property is mandatory
173
174
customizedDetectedTask . required ! . push ( taskProp ) ;
174
175
}
175
176
customizedDetectedTask . properties ! [ taskProp ] = { ...def . properties . schema . properties ! [ taskProp ] } ;
Original file line number Diff line number Diff line change @@ -274,7 +274,11 @@ export interface TaskDefinition {
274
274
taskType : string ;
275
275
source : string ;
276
276
properties : {
277
- required : string [ ] ;
277
+ /**
278
+ * Should be treated as an empty array if omitted.
279
+ * https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3
280
+ */
281
+ required ?: string [ ] ;
278
282
all : string [ ] ;
279
283
schema : IJSONSchema ;
280
284
}
You can’t perform that action at this time.
0 commit comments