-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add missing features in useLSP
mode
#295
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3211665
chore(babel): update babel to v7
Mayank1791989 1f56e9e
feat(syntax): enable syntax highlighting in .flowconfig
Mayank1791989 3f33b0a
fix(useLsp): add missing features in lsp mode.
Mayank1791989 baee2f0
chore(build): clean old build before starting new compilation
Mayank1791989 7af1f28
fix(formatting): use prettier to format output
Mayank1791989 852bcac
Merge branch 'master' of https://github.com/flowtype/flow-for-vscode …
orta 2ecc125
fix(lsp): merge status and coverage bar item
Mayank1791989 9ea86db
Merge branch 'feat/lsp' of github.com:Mayank1791989/flow-for-vscode i…
orta a215448
fix(lsp): fix multiple output channel
Mayank1791989 8642d61
fix: update flow to 0.75 and fix all flow errors
Mayank1791989 222e3c5
feat(lsp): add version & flowconfig check
Mayank1791989 a93157c
fix(coverage): fix missing coverage in some cases
Mayank1791989 051752e
Merge branch 'feat/lsp' of github.com:Mayank1791989/flow-for-vscode i…
orta 06a414c
Address all feedback in #295
orta a31f31a
Convert LSP to be the default, and migrate to version 1.0
orta 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 was deleted.
Oops, something went wrong.
This file contains 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,26 @@ | ||
'use strict'; | ||
|
||
// NOTE: using babel.config.js instead of .babelrc to force | ||
// babel to compile files inside lib/pkg/* using this config | ||
|
||
module.exports = function(api) { | ||
api.env(); | ||
|
||
return { | ||
plugins: ['@babel/plugin-proposal-class-properties'], | ||
|
||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: '6' | ||
} | ||
} | ||
], | ||
'@babel/preset-flow' | ||
], | ||
|
||
ignore: ['node_modules'] | ||
}; | ||
}; |
This file contains 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 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,140 @@ | ||
/* @flow */ | ||
import * as vscode from 'vscode'; | ||
import { LspMessageType, type StatusData } from './types'; | ||
import StatusProvider from './StatusProvider'; | ||
import StatusBarWidget from '../StatusBarWidget'; | ||
|
||
type State = { | ||
status: StatusData, | ||
}; | ||
|
||
export default class Status { | ||
state: State = { | ||
status: { kind: 'null' }, | ||
}; | ||
|
||
_provider: StatusProvider; | ||
_widget: StatusBarWidget; | ||
_command: vscode.Disposable; | ||
|
||
constructor(provider: StatusProvider, widget: StatusBarWidget) { | ||
this._widget = widget; | ||
this._provider = provider; | ||
this._provider.onStatus(statusData => { | ||
this.setState({ status: statusData }); | ||
}); | ||
// register command to handle show current server status | ||
this._command = vscode.commands.registerCommand( | ||
'flow.show-status', | ||
this._handleShowStatus, | ||
); | ||
} | ||
|
||
setState(partialState: $Shape<State>) { | ||
this.state = { | ||
...this.state, | ||
...partialState, | ||
}; | ||
this.render(); | ||
} | ||
|
||
render() { | ||
const item = this._widget; | ||
const { status } = this.state; | ||
|
||
switch (status.kind) { | ||
case 'green': | ||
this._widget.setStatus({ | ||
state: 'idle', | ||
message: status.message || '', | ||
}); | ||
break; | ||
case 'yellow': | ||
this._widget.setStatus({ | ||
state: 'busy', | ||
progress: this._getProgress(status), | ||
message: status.message || '', | ||
}); | ||
break; | ||
case 'red': | ||
this._widget.setStatus({ | ||
state: 'error', | ||
message: status.message || '', | ||
}); | ||
break; | ||
case 'null': | ||
this._widget.setStatus(null); | ||
default: | ||
this._widget.setStatus(null); | ||
break; | ||
} | ||
} | ||
|
||
_getProgress(status: StatusData): string { | ||
if (status.kind !== 'yellow') { | ||
return ''; | ||
} | ||
if (status.shortMessage != null) { | ||
return status.shortMessage; | ||
} | ||
if (status.progress != null) { | ||
const { numerator, denominator } = status.progress; | ||
return ( | ||
Math.round( | ||
(numerator / (denominator == null ? 100 : denominator)) * 100, | ||
) + '%' | ||
); | ||
} | ||
|
||
if (status.message != null) { | ||
// remove `Flow:` from message | ||
return status.message.replace('Flow:', ''); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
_handleShowStatus = () => { | ||
const { status } = this.state; | ||
switch (status.kind) { | ||
case 'red': { | ||
const items = status.buttons.map(button => ({ | ||
title: button, | ||
command: () => this._provider.clickAction(status.id || '', button), | ||
})); | ||
vscode.window | ||
.showErrorMessage(status.message || '', ...items) | ||
.then(selection => { | ||
if (selection) { | ||
selection.command(); | ||
} | ||
}); | ||
break; | ||
} | ||
case 'yellow': { | ||
const items = status.buttons.map(button => ({ | ||
title: button, | ||
command: () => this._provider.clickAction(status.id || '', button), | ||
})); | ||
vscode.window | ||
.showWarningMessage(status.message || '', ...items) | ||
.then(selection => { | ||
if (selection) { | ||
selection.command(); | ||
} | ||
}); | ||
break; | ||
} | ||
case 'green': { | ||
vscode.window.showInformationMessage(status.message || ''); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
dispose() { | ||
this._command.dispose(); | ||
} | ||
} |
This file contains 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,30 @@ | ||
/* @flow */ | ||
// add support using "window/showStatus" lsp extension | ||
import * as lsp from 'vscode-languageclient'; | ||
import * as vscode from 'vscode'; | ||
import StatusProvider from './StatusProvider'; | ||
import Status from './Status'; | ||
import { type ShowStatusParams, LspMessageType } from './types'; | ||
import StatusBarWidget from '../StatusBarWidget'; | ||
|
||
type StaticFeature = lsp.StaticFeature; | ||
|
||
export default class StatusFeature implements StaticFeature { | ||
_client: lsp.BaseLanguageClient; | ||
_widget: StatusBarWidget; | ||
|
||
constructor(client: lsp.BaseLanguageClient, widget: StatusBarWidget) { | ||
this._client = client; | ||
this._widget = widget; | ||
} | ||
|
||
fillClientCapabilities(capabilities: lsp.ClientCapabilities): void { | ||
capabilities.window = capabilities.window || {}; | ||
capabilities.window.status = { dynamicRegistration: false }; | ||
} | ||
|
||
initialize(): lsp.Disposable { | ||
const statusProvider = new StatusProvider(this._client); | ||
return new Status(statusProvider, this._widget); | ||
} | ||
} |
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.
can we dispose
StatusProvider
as well, just not to forget about 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.
@thymikee Actually there is nothing in
StatusProvider
to dispose so I kept it this way.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 remember a comment about adding such in StatusProvider. Maybe worth removing 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.
Hmm I should remove the
onStatus
listener in dispose method. As provider and status component both disposes together it will not cause any issues but I will push a fix thanks.