Added support for full error messages
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:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "DiagnosticSeverity.hpp"
|
||||
#include "DiagnosticCode.hpp"
|
||||
#include "Diagnostic.hpp"
|
||||
@@ -16,6 +17,7 @@ namespace Porygon::Diagnostics {
|
||||
vector<Diagnostic> _diagnostics;
|
||||
vector<size_t> _lineStarts;
|
||||
vector<size_t> _lineLength;
|
||||
|
||||
public:
|
||||
explicit DiagnosticsHolder(const u16string& str) {
|
||||
_hasErrors = false;
|
||||
@@ -35,13 +37,13 @@ namespace Porygon::Diagnostics {
|
||||
_diagnostics.clear();
|
||||
}
|
||||
|
||||
void Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments = {});
|
||||
|
||||
void LogError(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void LogError(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments = {});
|
||||
|
||||
void LogWarning(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void LogWarning(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments = {});
|
||||
|
||||
void LogInfo(DiagnosticCode code, unsigned int start, unsigned int length);
|
||||
void LogInfo(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments = {});
|
||||
|
||||
bool HasErrors();
|
||||
|
||||
@@ -51,28 +53,12 @@ namespace Porygon::Diagnostics {
|
||||
|
||||
Diagnostic *GetDiagnosticAt(int position);
|
||||
|
||||
size_t GetLineFromPosition(size_t i){
|
||||
size_t topLimit = _lineStarts.size() - 1;
|
||||
size_t bottomLimit = 0;
|
||||
while (true){
|
||||
if (bottomLimit == topLimit){
|
||||
return bottomLimit;
|
||||
}
|
||||
size_t half = (topLimit - bottomLimit) / 2;
|
||||
size_t pos = _lineStarts[half];
|
||||
size_t length = _lineLength[half];
|
||||
if (pos < i && pos + length > i){
|
||||
return half;
|
||||
}
|
||||
if (pos > i){
|
||||
bottomLimit = half;
|
||||
} else if (pos < i){
|
||||
topLimit = half;
|
||||
} else{
|
||||
return half;
|
||||
}
|
||||
}
|
||||
size_t GetLineFromPosition(size_t i);
|
||||
size_t GetStartPositionForLine(size_t i){
|
||||
return _lineStarts[i];
|
||||
}
|
||||
|
||||
std::string GetFullErrorMessage(Diagnostic diagnostic);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user