-
-
Notifications
You must be signed in to change notification settings - Fork 436
/
Copy patharduino-plugin-reader.ts
47 lines (42 loc) · 2.04 KB
/
arduino-plugin-reader.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { injectable, inject } from 'inversify';
import { HostedPluginReader } from '@theia/plugin-ext/lib/hosted/node/plugin-reader';
import { PluginPackage, PluginContribution } from '@theia/plugin-ext/lib/common/plugin-protocol';
import { CLI_CONFIG } from './cli-config';
import { ConfigServiceImpl } from './config-service-impl';
@injectable()
export class ArduinoHostedPluginReader extends HostedPluginReader {
@inject(ConfigServiceImpl)
protected readonly configService: ConfigServiceImpl;
protected cliConfigSchemaUri: string;
async onStart(): Promise<void> {
this.cliConfigSchemaUri = await this.configService.getConfigurationFileSchemaUri();
}
readContribution(plugin: PluginPackage): PluginContribution | undefined {
const scanner = this.scanner.getScanner(plugin);
const contribution = scanner.getContribution(plugin);
if (!contribution) {
return contribution;
}
if (plugin.name === 'vscode-yaml' && plugin.publisher === 'redhat' && contribution.configuration) {
// Use the schema for the Arduino CLI.
const { configuration } = contribution;
for (const config of configuration) {
if (typeof config.properties['yaml.schemas'] === 'undefined') {
config.properties['yaml.schemas'] = {};
}
config.properties['yaml.schemas'].default = {
[this.cliConfigSchemaUri]: [CLI_CONFIG]
};
}
} else if (plugin.name === 'cpp' && plugin.publisher === 'vscode' && contribution.languages) {
// Do not associate `.ino` files with the VS Code built-in extension for C++.
// https://github.com/eclipse-theia/theia/issues/7533#issuecomment-611055328
for (const language of contribution.languages) {
if (language.extensions) {
language.extensions = language.extensions.filter(ext => ext !== '.ino');
}
}
}
return contribution;
}
}