-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support contributes.jsonValidation VSCode API. #7560
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ import URI from '@theia/core/lib/common/uri'; | |
import { JsonPreferences } from './json-preferences'; | ||
import { JsonSchemaStore } from '@theia/core/lib/browser/json-schema-store'; | ||
import { Endpoint } from '@theia/core/lib/browser'; | ||
import { JsonValidationContributionsRegistry } from './json-validation-registry'; | ||
|
||
@injectable() | ||
export class JsonClientContribution extends BaseLanguageClientContribution { | ||
|
@@ -42,18 +43,22 @@ export class JsonClientContribution extends BaseLanguageClientContribution { | |
@inject(Languages) protected readonly languages: Languages, | ||
@inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory, | ||
@inject(JsonPreferences) protected readonly preferences: JsonPreferences, | ||
@inject(JsonSchemaStore) protected readonly jsonSchemaStore: JsonSchemaStore | ||
) { | ||
@inject(JsonSchemaStore) protected readonly jsonSchemaStore: JsonSchemaStore, | ||
@inject(JsonValidationContributionsRegistry) protected readonly jsonValidationContributionsRegistry: JsonValidationContributionsRegistry | ||
) { | ||
super(workspace, languages, languageClientFactory); | ||
this.initializeJsonSchemaAssociations(); | ||
} | ||
|
||
protected updateSchemas(client: ILanguageClient): void { | ||
const allConfigs = [...this.jsonSchemaStore.getJsonSchemaConfigurations()]; | ||
const config = this.preferences['json.schemas']; | ||
if (config instanceof Array) { | ||
allConfigs.push(...config); | ||
} | ||
const schemaStoreConfigs = this.jsonSchemaStore.getJsonSchemaConfigurations(); | ||
const pluginContributionConfigs = this.jsonValidationContributionsRegistry.getJsonValidations(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. such configs can be registered dynamically, i.e. a user install or uninstall new extension. registry should fire an event and contribution should trigger |
||
const preferencesConfigs = this.preferences['json.schemas'] instanceof Array ? this.preferences['json.schemas'] : []; | ||
|
||
// The order of combining the schema configs is very important as it implies a precedence. | ||
// Given multiple *identical** fileMatch properties, The **last** schema will take precedence. | ||
// This means: schemaStore < pluginContribution < preferences | ||
const allConfigs = [...schemaStoreConfigs, ...pluginContributionConfigs, ...preferencesConfigs]; | ||
const registry: { [pattern: string]: string[] } = {}; | ||
for (const s of allConfigs) { | ||
if (s.fileMatch) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020 SAP SE or an SAP affiliate company and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { injectable } from 'inversify'; | ||
import { Disposable } from '@theia/core/lib/common/disposable'; | ||
import { deepClone } from '@theia/core'; | ||
import { JsonSchemaConfiguration } from '@theia/core/lib/browser/json-schema-store'; | ||
|
||
@injectable() | ||
/** | ||
* Holds JSON Validation contributions from plugins / VSCode extensions. | ||
* - https://code.visualstudio.com/api/references/contribution-points#contributes.jsonValidation | ||
*/ | ||
export class JsonValidationContributionsRegistry { | ||
|
||
protected readonly registry: JsonSchemaConfiguration[] = []; | ||
|
||
registerJsonValidation(jsonValidationEntry: JsonSchemaConfiguration): Disposable { | ||
akosyakov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.registry.push(jsonValidationEntry); | ||
return Disposable.NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bd82 It was not addressed, this should remove entry from |
||
} | ||
|
||
getJsonValidations(): JsonSchemaConfiguration[] { | ||
return deepClone(this.registry); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,9 @@ | |
}, | ||
{ | ||
"path": "../callhierarchy/compile.tsconfig.json" | ||
}, | ||
{ | ||
"path": "../json/compile.tsconfig.json" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"@theia/editor": "^1.0.0", | ||
"@theia/file-search": "^1.0.0", | ||
"@theia/filesystem": "^1.0.0", | ||
"@theia/json": "^1.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this dependency, we only need to register configuration in core json schema storage There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @azatsarynnyy Do you know whether introducing such dependency will cause issues in Che? i.e. do you use json vscode built-in extensions already? |
||
"@theia/languages": "^1.0.0", | ||
"@theia/markers": "^1.0.0", | ||
"@theia/messages": "^1.0.0", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be here. How did you get it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oy probably via a rebase to update my local branch