-
Notifications
You must be signed in to change notification settings - Fork 86
refactor: preparing for user-widgets and context suggestions #193
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
10 commits
Select commit
Hold shift + click to select a range
74bacc8
refactor: preparing for user-widgets and context suggestions
EdAyers d81f584
fix: @gebner's suggestions
EdAyers 91eccca
chore: hide wrapper struct
Vtec234 b688e88
doc: shorten comments
Vtec234 5cc7a66
doc: error message
Vtec234 81de27f
chore: move RPC functions
Vtec234 6d60a78
feat: add new error codes
Vtec234 0f2bc3a
fix: add dummy indices
Vtec234 d6232af
fix: make index prop on GoalUI optional
EdAyers b685c88
feat: useAsyncUnthrottled
EdAyers 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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| import { InteractiveDiagnostics_msgToInteractive, MessageData } from './infoview/rpcInterface'; | ||
| import { InteractiveMessage } from './infoview/traceExplorer'; | ||
| import { DocumentPosition, useAsync, mapRpcError } from './infoview/util'; | ||
| import { RpcContext } from './infoview/contexts'; | ||
|
|
||
| export { DocumentPosition }; | ||
| export { EditorContext, RpcContext, VersionContext } from './infoview/contexts'; | ||
| export { EditorConnection } from './infoview/editorConnection'; | ||
| export { RpcSessions } from './infoview/rpcSessions'; | ||
| export { ServerVersion } from './infoview/serverVersion'; | ||
|
|
||
| /** Display the given message data as interactive, pretty-printed text. */ | ||
| export function InteractiveMessageData({ pos, msg }: { pos: DocumentPosition, msg: MessageData }) { | ||
| const rs = React.useContext(RpcContext) | ||
|
|
||
| const [status, tt, error] = useAsync( | ||
| () => InteractiveDiagnostics_msgToInteractive(rs, pos, msg, 0), | ||
| [pos.character, pos.line, pos.uri, msg] | ||
| ) | ||
|
|
||
| if (tt) { | ||
| return <InteractiveMessage pos={pos} fmt={tt} /> | ||
| } else if (status === 'pending') { | ||
| return <>...</> | ||
| } else { | ||
| return <div>Failed to display message: | ||
| {error && <span>{mapRpcError(error).message}</span>} | ||
| </div> | ||
| } | ||
| } |
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,33 @@ | ||
| import React from 'react'; | ||
|
|
||
|
|
||
| /** Error boundary as described in https://reactjs.org/docs/error-boundaries.html */ | ||
| export class ErrorBoundary extends React.Component<{}, {error: string | undefined}> { | ||
| constructor(props: {}) { | ||
| super(props); | ||
| this.state = { error: undefined }; | ||
| } | ||
|
|
||
| static getDerivedStateFromError(error: any) { | ||
| // Update state so the next render will show the fallback UI. | ||
| return { error: error.toString() }; | ||
| } | ||
|
|
||
| componentDidCatch(error : any, errorInfo : any) { | ||
| // You can also log the error to an error reporting service | ||
| return | ||
| } | ||
|
|
||
| render() { | ||
| if (this.state.error) { | ||
| // You can render any custom fallback UI | ||
| return <div> | ||
| <h1>Error:</h1>{this.state.error}<br/> | ||
| <a onClick={() => this.setState({ error: undefined })}>Click to reload.</a> | ||
| </div>; | ||
| } | ||
|
|
||
| return this.props.children; | ||
| } | ||
| } | ||
|
|
||
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
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.
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.
I'm not sure how this component is going to be used (it's still unused). The Lean 3 version had a
componentDidCatchhandler, should we add this here as well?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.
componentDidCatch is needed if you want to log errors. I added a stub that does nothing in case react is looking for that method.