| 1 |
#include "PHPEntityFunctionAlias.h" |
| 2 |
|
| 3 |
#include "PHPEntityFunction.h" |
| 4 |
#include "PHPLookupTable.h" |
| 5 |
#include "file_logger.h" |
| 6 |
|
| 7 |
PHPEntityFunctionAlias::PHPEntityFunctionAlias() {} |
| 8 |
|
| 9 |
PHPEntityFunctionAlias::~PHPEntityFunctionAlias() {} |
| 10 |
|
| 11 |
bool PHPEntityFunctionAlias::Is(eEntityType type) const { return type == kEntityTypeFunctionAlias; } |
| 12 |
|
| 13 |
void PHPEntityFunctionAlias::FromResultSet(wxSQLite3ResultSet& res) |
| 14 |
{ |
| 15 |
SetDbId(res.GetInt("ID")); |
| 16 |
SetShortName(res.GetString("NAME")); |
| 17 |
SetRealname(res.GetString("REALNAME")); |
| 18 |
SetLine(res.GetInt("LINE_NUMBER")); |
| 19 |
SetFilename(res.GetString("FILE_NAME")); |
| 20 |
SetFullName(res.GetString("FULLNAME")); |
| 21 |
SetScope(res.GetString("SCOPE")); |
| 22 |
} |
| 23 |
|
| 24 |
void PHPEntityFunctionAlias::Store(PHPLookupTable* lookup) |
| 25 |
{ |
| 26 |
try { |
| 27 |
wxSQLite3Database& db = lookup->Database(); |
| 28 |
wxSQLite3Statement statement = db.PrepareStatement( |
| 29 |
"INSERT OR REPLACE INTO FUNCTION_ALIAS_TABLE VALUES(NULL, :SCOPE_ID, :NAME, :REALNAME, :FULLNAME, :SCOPE, " |
| 30 |
":LINE_NUMBER, :FILE_NAME)"); |
| 31 |
statement.Bind(statement.GetParamIndex(":SCOPE_ID"), Parent()->GetDbId()); |
| 32 |
statement.Bind(statement.GetParamIndex(":NAME"), GetShortName()); |
| 33 |
statement.Bind(statement.GetParamIndex(":REALNAME"), GetRealname()); |
| 34 |
statement.Bind(statement.GetParamIndex(":FULLNAME"), GetFullName()); |
| 35 |
statement.Bind(statement.GetParamIndex(":SCOPE"), GetScope()); |
| 36 |
statement.Bind(statement.GetParamIndex(":LINE_NUMBER"), GetLine()); |
| 37 |
statement.Bind(statement.GetParamIndex(":FILE_NAME"), GetFilename().GetFullPath()); |
| 38 |
statement.ExecuteUpdate(); |
| 39 |
SetDbId(db.GetLastRowId()); |
| 40 |
|
| 41 |
} catch(wxSQLite3Exception& exc) { |
| 42 |
clWARNING() << "PHPEntityFunctionAlias::Store:" << exc.GetMessage() << endl; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
wxString PHPEntityFunctionAlias::FormatPhpDoc(const CommentConfigData& data) const |
| 47 |
{ |
| 48 |
if(m_func) { |
| 49 |
return m_func->FormatPhpDoc(data); |
| 50 |
} |
| 51 |
return ""; |
| 52 |
} |
| 53 |
|
| 54 |
wxString PHPEntityFunctionAlias::GetDisplayName() const { return GetShortName(); } |
| 55 |
|
| 56 |
void PHPEntityFunctionAlias::PrintStdout(int indent) const { wxUnusedVar(indent); } |
| 57 |
|
| 58 |
wxString PHPEntityFunctionAlias::Type() const |
| 59 |
{ |
| 60 |
if(m_func) { |
| 61 |
return m_func->Type(); |
| 62 |
} |
| 63 |
return ""; |
| 64 |
} |
| 65 |
|
| 66 |
void PHPEntityFunctionAlias::FromJSON(const JSONItem& json) |
| 67 |
{ |
| 68 |
BaseFromJSON(json); |
| 69 |
m_realname = json.namedObject("realName").toString(); |
| 70 |
m_scope = json.namedObject("scope").toString(); |
| 71 |
if(json.hasNamedObject("func")) { |
| 72 |
JSONItem func = json.namedObject("func"); |
| 73 |
m_func.Reset(new PHPEntityFunction()); |
| 74 |
m_func->FromJSON(func); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
JSONItem PHPEntityFunctionAlias::ToJSON() const |
| 79 |
{ |
| 80 |
JSONItem json = BaseToJSON("a"); |
| 81 |
json.addProperty("realName", m_realname); |
| 82 |
json.addProperty("scope", m_scope); |
| 83 |
if(m_func) { |
| 84 |
JSONItem func = m_func->ToJSON(); |
| 85 |
json.addProperty("func", func); |
| 86 |
} |
| 87 |
return json; |
| 88 |
} |