-
Notifications
You must be signed in to change notification settings - Fork 12
fix #321 - feat: Implement volar-service-json for JSON language support #434
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
Merged
lornakelly
merged 12 commits into
open-workflow-specification:main
from
fantonangeli:issue-321-feat-Implement-volar-service-json-for-JSON-language-support
Sep 18, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a2f0697
Add dependencies
fantonangeli c580d23
Json plugin creation with first schema driven completions
fantonangeli 093ab61
Created foundation for OWS completions and code lenses
fantonangeli ed4de38
Add Changeset file
fantonangeli a4ca56f
Add createJsonLanguageServicePlugins tests
fantonangeli a906218
Merge remote-tracking branch 'upstream/main' into issue-321-feat-Impl…
fantonangeli f917e42
Restored previous test filenames
fantonangeli e890c46
Fixes comment: https://github.com/open-workflow-specification/editor/…
fantonangeli c54c886
Fixes comment: https://github.com/open-workflow-specification/editor/…
fantonangeli 767c68f
Fixes comment: https://github.com/open-workflow-specification/editor/…
fantonangeli 94a47b6
Add guard for non Json files
fantonangeli d8d5dc3
Merge remote-tracking branch 'upstream/main' into issue-321-feat-Impl…
fantonangeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@openworkflowspec/language-service": minor | ||
| --- | ||
|
|
||
| Add JSON language service plugins foundation for Open Workflow Spec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * Copyright 2021-Present The Open Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| export const HELLO_WORLD_SAMPLE = `{ | ||
| "document": { | ||
| "dsl": "1.0.3", | ||
| "namespace": "examples", | ||
| "name": "hello-world", | ||
| "version": "0.1.0" | ||
| }, | ||
| "do": [ | ||
| { | ||
| "greet": { | ||
| "call": "http", | ||
| "with": { | ||
| "method": "GET", | ||
| "endpoint": "https://httpbin.org/get" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Copyright 2021-Present The Open Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Returns true if the document content is considered an empty Open Workflow — | ||
| * i.e. the trimmed content is an empty string. | ||
| * Any other content, including bare `{}`, returns false. | ||
| */ | ||
| export function isEmptyWorkflow(text: string): boolean { | ||
| return text.trim().length === 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright 2021-Present The Open Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { LanguageServicePlugin } from "@volar/language-service"; | ||
| import { isEmptyWorkflow } from "../../utils"; | ||
|
|
||
| export function createJsonCodeLensesPlugin(): LanguageServicePlugin { | ||
| return { | ||
| capabilities: { | ||
| codeLensProvider: {}, | ||
| }, | ||
| create() { | ||
| return { | ||
| provideCodeLenses(document) { | ||
| if (document.languageId !== "json" || !isEmptyWorkflow(document.getText())) { | ||
|
lornakelly marked this conversation as resolved.
|
||
| return null; | ||
| } | ||
|
|
||
| return [ | ||
| { | ||
| range: { | ||
| start: { line: 0, character: 0 }, | ||
| end: { line: 0, character: 0 }, | ||
| }, | ||
| command: { | ||
| title: "Create an Open Workflow", | ||
| command: "openworkflow.insertHelloWorld", | ||
| }, | ||
| }, | ||
| ]; | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2021-Present The Open Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { LanguageServicePlugin, LanguageServicePluginInstance } from "@volar/language-service"; | ||
| import { HELLO_WORLD_SAMPLE } from "../../samples/hello-world"; | ||
| import { isEmptyWorkflow } from "../../utils"; | ||
|
|
||
| // CompletionItemKind.Snippet = 15 (LSP spec, cast needed because kind is a const enum) | ||
| const SNIPPET_KIND = 15; | ||
|
|
||
| const EMPTY_RANGE = { | ||
| start: { line: 0, character: 0 }, | ||
| end: { line: 0, character: 0 }, | ||
| }; | ||
|
|
||
| export function createJsonCompletionsPlugin(): LanguageServicePlugin { | ||
| return { | ||
| capabilities: { | ||
| completionProvider: {}, | ||
| }, | ||
| create(): LanguageServicePluginInstance { | ||
| return { | ||
| isAdditionalCompletion: true, | ||
| provideCompletionItems(document) { | ||
| if (document.languageId !== "json" || !isEmptyWorkflow(document.getText())) { | ||
| return null; | ||
| } | ||
|
|
||
| return { | ||
| isIncomplete: false, | ||
| items: [ | ||
| { | ||
| label: "Insert Hello World workflow", | ||
| kind: SNIPPET_KIND as 15, | ||
| detail: "Insert a Hello World Open Workflow document", | ||
|
lornakelly marked this conversation as resolved.
|
||
| textEdit: { range: EMPTY_RANGE, newText: HELLO_WORLD_SAMPLE }, | ||
| }, | ||
| ], | ||
| }; | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright 2021-Present The Open Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { LanguageServicePlugin } from "@volar/language-service"; | ||
| import { create } from "volar-service-json"; | ||
| import { workflowSchema } from "@openworkflowspec/sdk"; | ||
|
|
||
| const DEFAULT_SCHEMA_URI = "urn:open-workflow-specification:workflow-schema"; | ||
|
|
||
| export function createJsonSchemaLanguageServicePlugin(): LanguageServicePlugin { | ||
| return create({ | ||
| getLanguageSettings() { | ||
| return { | ||
| schemas: [ | ||
| { | ||
| uri: workflowSchema.$id || DEFAULT_SCHEMA_URI, | ||
| fileMatch: ["*.json"], | ||
|
fantonangeli marked this conversation as resolved.
|
||
| schema: workflowSchema, | ||
|
fantonangeli marked this conversation as resolved.
fantonangeli marked this conversation as resolved.
|
||
| }, | ||
| ], | ||
| }; | ||
| }, | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.