Cache diagnostic message for easier access, and better extern C handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -97,7 +97,11 @@ const string PrettyDiagnostic ( const char * format, vector<string> arguments)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DiagnosticsHolder::GetFullDiagnostic(Diagnostic* diagnostic) {
|
||||
std::string* DiagnosticsHolder::GetFullDiagnostic(Diagnostic* diagnostic) {
|
||||
auto previousMsg = diagnostic->GetMessage();
|
||||
if (previousMsg != nullptr){
|
||||
return previousMsg;
|
||||
}
|
||||
stringstream stream;
|
||||
stream << "[" << SeverityToString(diagnostic->GetSeverity()) << "] ";
|
||||
auto startPos = diagnostic->GetStartPosition();
|
||||
@@ -108,7 +112,9 @@ std::string DiagnosticsHolder::GetFullDiagnostic(Diagnostic* diagnostic) {
|
||||
if (unformatted != ErrorMessages.end()){
|
||||
stream << PrettyDiagnostic(unformatted->second, diagnostic->GetArguments());
|
||||
}
|
||||
return stream.str();
|
||||
auto s = new string(stream.str());
|
||||
diagnostic->SetMessage(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
@@ -120,7 +126,7 @@ extern "C" {
|
||||
return diagnostics->GetDiagnosticAt(position);
|
||||
}
|
||||
|
||||
const char* GetFullDiagnostic(DiagnosticsHolder* diagnostics, Diagnostic* diag){
|
||||
return diagnostics ->GetFullDiagnostic(diag).c_str();
|
||||
const char * GetFullDiagnostic(DiagnosticsHolder* diagnostics, Diagnostic* diag){
|
||||
return diagnostics ->GetFullDiagnostic(diag)->c_str();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user