From 67d36e699a2852ce471c4d1b8dab5992d6c01a98 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sat, 24 Jan 2015 03:08:16 +0100 Subject: Implemented SourceContextReader, added unit tests, implemented SourceContextReader interface in ResourceManager, added LoggerTest --- src/core/resource/ResourceManager.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/core/resource/ResourceManager.hpp') diff --git a/src/core/resource/ResourceManager.hpp b/src/core/resource/ResourceManager.hpp index 51c00e3..d5381b9 100644 --- a/src/core/resource/ResourceManager.hpp +++ b/src/core/resource/ResourceManager.hpp @@ -34,6 +34,7 @@ #include #include +#include #include #include "Resource.hpp" @@ -74,11 +75,11 @@ private: std::unordered_map nodes; /** - * Cache used for translating byte offsets to line numbers. Maps from a - * SourceId onto a list of (sorted) SourceOffsets. The index in the list - * corresponds to the line number. + * Map containing SourceContextReader instances which are -- as their name + * suggests -- used to produce SourceContext structures describing the + * source code at a given SourceLocation. */ - std::unordered_map> lineNumberCache; + std::unordered_map contextReaders; /** * Allocates a new SourceId for the given resource. @@ -224,11 +225,14 @@ public: * @param location is the SourceLocation for which context information * should be retrieved. This method is used by the Logger class to print * pretty messages. + * @param maxContextLength is the maximum length in character of context + * that should be extracted. * @return a valid SourceContext if a valid SourceLocation was given or an * invalid SourceContext if the location is invalid. */ - SourceContext buildContext(const SourceLocation &location); - + SourceContext readContext( + const SourceLocation &location, + size_t maxContextLength = SourceContextReader::MAX_MAX_CONTEXT_LENGTH); }; } -- cgit v1.2.3