-
Notifications
You must be signed in to change notification settings - Fork 129
Language service JavaScript API and web worker #426
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
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
276864f
WASM wrapper for language service
minestarks 221cc9b
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks 7d6875e
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks 9b3a504
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks a7420ec
Move worker stuff into compiler subfolder
minestarks 9a2a2da
Move all the compiler related files to a subfolder
minestarks a55ce99
Add QSharpLanguageService to npm package
minestarks f4d2b00
Add language service web worker
minestarks fdddf90
tests passing
minestarks 64c3201
refactor event stuff
minestarks 62752b0
Clean up requests too
minestarks c1971cf
cleaned up almost everything
minestarks e296151
bit more cleanup
minestarks f8e5866
Really clean it up
minestarks 3b4ba81
Add language service
minestarks 5314af0
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks 93c3a71
update .eslintrc
minestarks 144f290
revert package.json
minestarks b7e5e23
Fix npm entrypoint
minestarks b49bea6
Update README.md
minestarks 0345a2a
Remove TODO and run prettier
minestarks 1b03fa3
Add dispose()
minestarks dad7af8
Merge branch 'main' into minestarks/language-service-webworker
minestarks f904b55
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks 4fc0d06
Revert accidental change
minestarks 3569eb9
Remove TODO
minestarks bec69c3
Remove code samples from README.md
minestarks 619efda
Fix minor mistakes
minestarks a390347
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks 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
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
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,83 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { VSDiagnostic } from "../vsdiagnostic.js"; | ||
|
||
// Each DumpMachine output is represented as an object where each key is a basis | ||
// state, e.g., "|3>" and the value is the [real, imag] parts of the complex amplitude. | ||
export type Dump = { | ||
[index: string]: [number, number]; | ||
}; | ||
|
||
export type Result = | ||
| { success: true; value: string } | ||
| { success: false; value: VSDiagnostic }; | ||
|
||
interface DumpMsg { | ||
type: "DumpMachine"; | ||
state: Dump; | ||
} | ||
|
||
interface MessageMsg { | ||
type: "Message"; | ||
message: string; | ||
} | ||
|
||
interface ResultMsg { | ||
type: "Result"; | ||
result: Result; | ||
} | ||
|
||
type EventMsg = ResultMsg | DumpMsg | MessageMsg; | ||
|
||
function outputAsResult(msg: string): ResultMsg | null { | ||
try { | ||
const obj = JSON.parse(msg); | ||
if (obj?.type == "Result" && typeof obj.success == "boolean") { | ||
return { | ||
type: "Result", | ||
result: { | ||
success: obj.success, | ||
value: obj.result, | ||
}, | ||
}; | ||
} | ||
} catch { | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
function outputAsMessage(msg: string): MessageMsg | null { | ||
try { | ||
const obj = JSON.parse(msg); | ||
if (obj?.type == "Message" && typeof obj.message == "string") { | ||
return obj as MessageMsg; | ||
} | ||
} catch { | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
function outputAsDump(msg: string): DumpMsg | null { | ||
try { | ||
const obj = JSON.parse(msg); | ||
if (obj?.type == "DumpMachine" && typeof obj.state == "object") { | ||
return obj as DumpMsg; | ||
} | ||
} catch { | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
export function eventStringToMsg(msg: string): EventMsg | null { | ||
return outputAsResult(msg) || outputAsMessage(msg) || outputAsDump(msg); | ||
} | ||
|
||
export type ShotResult = { | ||
success: boolean; | ||
result: string | VSDiagnostic; | ||
events: Array<MessageMsg | DumpMsg>; | ||
}; |
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
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.