Skip to content

Commit

Permalink
feat: use getDocumentationHtml and getSnippetHtml from atom-ide-base
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 6, 2020
1 parent b7cfbfb commit 8c5cdd0
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions lib/signature-help-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
const { CompositeDisposable, Disposable, Range, Point, TextEditor } = require("atom")
import { ProviderRegistry } from "atom-ide-base/commons-atom/ProviderRegistry"
import { ViewContainer } from "atom-ide-base/commons-ui/float-pane/ViewContainer"
import { getDocumentationHtml } from "atom-ide-base/commons-ui/float-pane/HTMLView"
import { getSnippetHtml } from "atom-ide-base/commons-ui/float-pane/SnippetView"

module.exports = class SignatureHelpManager {
constructor() {
Expand Down Expand Up @@ -286,41 +288,8 @@ module.exports = class SignatureHelpManager {
}
}

/**
* converts a given code snippet into syntax formatted HTML
* @param {String} snippet the code snippet to be converted
* @param {String} grammarName the name of the grammar to be used for syntax highlighting
* @return {Promise<string>} a promise object to track the asynchronous operation
*/
async getSnippetHtml(snippet, grammarName) {
if (snippet !== undefined && snippet.length > 0) {
const regExpLSPPrefix = /^\((method|property|parameter|alias)\)\W/
const preElem = document.createElement("pre")
const codeElem = document.createElement("code")

codeElem.innerText = snippet.replace(regExpLSPPrefix, "")
preElem.appendChild(codeElem)

return this.renderer.render(preElem.outerHTML, grammarName)
}
return null
}

/**
* convert the markdown documentation to HTML
* @param {String} markdownText the documentation text in markdown format to be converted
* @param {String} grammarName the default grammar used for embedded code samples
* @return {Promise<string>} a promise object to track the asynchronous operation
*/
async getDocumentationHtml(markdownText, grammarName) {
if (markdownText !== undefined && markdownText.length > 0) {
return this.renderer.render(markdownText, grammarName)
}
return null
}

/**
* mounts / displays a signature help view component at a specific position in a given Atom Text editor
/*
* mounts displays a signature help view component at a specific position in a given Atom Text editor
* @param {TextEditor} editor the Atom Text editor instance to host the data tip view
* @param {Point} position the position on which to show the signature help view
* @param {SignatureHelpView} view the signature help component to display
Expand Down

0 comments on commit 8c5cdd0

Please sign in to comment.