| 1 |
#include "CompletionItem.h" |
| 2 |
#include "JSON.h" |
| 3 |
|
| 4 |
LSP::CompletionItem::CompletionItem() {} |
| 5 |
|
| 6 |
LSP::CompletionItem::~CompletionItem() {} |
| 7 |
|
| 8 |
JSONItem LSP::CompletionItem::ToJSON(const wxString& name) const { return JSONItem(NULL); } |
| 9 |
|
| 10 |
void LSP::CompletionItem::FromJSON(const JSONItem& json) |
| 11 |
{ |
| 12 |
m_label = json.namedObject("label").toString(); |
| 13 |
m_kind = json.namedObject("kind").toInt(m_kind); |
| 14 |
m_detail = json.namedObject("detail").toString(); |
| 15 |
|
| 16 |
// parse the documentation |
| 17 |
auto doc = json.namedObject("documentation"); |
| 18 |
if(doc.isOk()) { |
| 19 |
if(doc.isString()) { |
| 20 |
// plain string, nothing more to be done here |
| 21 |
m_documentation.SetKind("plaintext"); |
| 22 |
m_documentation.SetValue(doc.toString()); |
| 23 |
} else { |
| 24 |
// an object of type MarkupContent |
| 25 |
m_documentation.FromJSON(doc); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
m_filterText = json.namedObject("filterText").toString(); |
| 30 |
m_insertText = json.namedObject("insertText").toString(); |
| 31 |
m_insertTextFormat = json.namedObject("insertTextFormat").toString(); |
| 32 |
m_vAdditionalText.clear(); |
| 33 |
if(json.hasNamedObject("additionalTextEdits")) { |
| 34 |
JSONItem additionalTextEdits = json.namedObject("additionalTextEdits"); |
| 35 |
int count = additionalTextEdits.arraySize(); |
| 36 |
for(int i = 0; i < count; ++i) { |
| 37 |
wxSharedPtr<TextEdit> edit(new TextEdit()); |
| 38 |
edit->FromJSON(additionalTextEdits.arrayItem(i)); |
| 39 |
m_vAdditionalText.push_back(edit); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
m_insertText.Trim().Trim(false); |
| 44 |
m_label.Trim().Trim(false); |
| 45 |
m_detail.Trim().Trim(false); |
| 46 |
m_documentation.SetValue(wxString(m_documentation.GetValue()).Trim().Trim(false)); |
| 47 |
if(json.hasNamedObject("textEdit") && !json.namedObject("textEdit").isNull()) { |
| 48 |
m_textEdit.reset(new LSP::TextEdit()); |
| 49 |
m_textEdit->FromJSON(json.namedObject("textEdit")); |
| 50 |
} |
| 51 |
} |