-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace tooltip dock with atom-ide-ui datatips
Datatips are much like our original tooltips, but they have a way to become sticky, after which the user can drag them anywhere he wants and also scroll through them. This pretty much removes the need for a separate dock. It also makes our UI consistent with that of other IDE packages and allows us to benefit from UI and functionality improvements done in atom-ide-ui itself. Finally, this code is pretty much ready for use, except there are some minor nitpicks in atom-ide-ui that I'd like ironed out before pushing this in php-integrator: - facebookarchive/atom-ide-ui#98 - facebookarchive/atom-ide-ui#99 References #315
- Loading branch information
Showing
8 changed files
with
115 additions
and
332 deletions.
There are no files selected for viewing
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 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 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,84 @@ | ||
{Disposable, CompositeDisposable} = require 'atom' | ||
|
||
SymbolHelpers = require './SymbolHelpers' | ||
|
||
module.exports = | ||
|
||
##* | ||
# Provides datatips (tooltips). | ||
## | ||
class DatatipProvider | ||
###* | ||
* The service (that can be used to query the source code and contains utility methods). | ||
* | ||
* @var {Object|null} | ||
### | ||
service: null | ||
|
||
###* | ||
* @var {Array} | ||
### | ||
grammarScopes: ['text.html.php'] | ||
|
||
###* | ||
* @var {Number} | ||
### | ||
priority: 1 | ||
|
||
###* | ||
* @var {String} | ||
### | ||
providerName: 'php-integrator' | ||
|
||
###* | ||
* Initializes this provider. | ||
* | ||
* @param {mixed} service | ||
### | ||
activate: (@service) -> | ||
|
||
###* | ||
* Deactives the provider. | ||
### | ||
deactivate: () -> | ||
|
||
###* | ||
* @param {TextEditor} editor | ||
* @param {Point} bufferPosition | ||
* | ||
* @return {Promise|null} | ||
### | ||
datatip: (editor, bufferPosition, heldKeys) -> | ||
if not @service.getCurrentProjectSettings() | ||
return new Promise (resolve, reject) => | ||
reject() | ||
|
||
scopeChain = editor.scopeDescriptorForBufferPosition(bufferPosition).getScopeChain() | ||
|
||
if scopeChain.length == 0 | ||
return new Promise (resolve, reject) => | ||
reject() | ||
|
||
# Skip whitespace and other noise | ||
if scopeChain == '.text.html.php .meta.embedded.block.php .source.php' | ||
return new Promise (resolve, reject) => | ||
reject() | ||
|
||
successHandler = (tooltip) => | ||
return null if not tooltip? | ||
|
||
return { | ||
markedStrings : [{ | ||
type : 'markdown' | ||
value : tooltip.contents | ||
}] | ||
|
||
# FIXME: core doesn't generate ranges yet, otherwise we could use tooltip.range | ||
range : SymbolHelpers.getRangeForSymbolAtPosition(editor, bufferPosition) | ||
pinnable : true | ||
} | ||
|
||
failureHandler = () -> | ||
return null | ||
|
||
return @service.tooltipAt(editor, bufferPosition).then(successHandler, failureHandler) |
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
Oops, something went wrong.