From ca0081e14b96eb6436ad349be2f2148520c16f38 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 17 Feb 2015 01:05:32 +0100 Subject: Improved semantics of the return value of the autocomplete function: Empty return value explicitly means that the file does not exist at all. --- src/core/resource/ResourceLocator.cpp | 4 ++-- src/core/resource/ResourceLocator.hpp | 9 ++++++--- src/core/resource/ResourceRequest.cpp | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/core/resource') diff --git a/src/core/resource/ResourceLocator.cpp b/src/core/resource/ResourceLocator.cpp index da38cbd..0498577 100644 --- a/src/core/resource/ResourceLocator.cpp +++ b/src/core/resource/ResourceLocator.cpp @@ -94,8 +94,8 @@ std::vector ResourceLocator::doAutocomplete( const std::string &path, const ResourceType type, const std::string &relativeTo) const { - // Default implementation - return std::vector{}; + // Default implementation, just return the path again + return std::vector{path}; } /* Class StaticResourceLocator */ diff --git a/src/core/resource/ResourceLocator.hpp b/src/core/resource/ResourceLocator.hpp index d6a2ffc..d8afcb2 100644 --- a/src/core/resource/ResourceLocator.hpp +++ b/src/core/resource/ResourceLocator.hpp @@ -71,7 +71,8 @@ protected: * the resource is looked up. * @param relativeTo is an already resolved Resource relative to which the * file should be searched. - * @return a list of matching, autocompleted file paths. + * @return a list of matching, autocompleted file paths. If autocomplete is + * not supported, simply returns the given path as a result. */ virtual std::vector doAutocomplete( const std::string &path, const ResourceType type, @@ -108,7 +109,8 @@ public: * the resource is looked up. * @param relativeTo is an already resolved Resource relative to which the * file should be searched. - * @return a list of matching, autocompleted file paths. + * @return a list of matching, autocompleted file paths. If autocomplete is + * not supported, simply returns the given path as a result. */ std::vector autocomplete( const std::string &path, @@ -126,7 +128,8 @@ public: * the resource is looked up. * @param relativeTo is the location of an already resolved resource * relative to which this resource should be located. - * @return a list of matching, autocompleted file paths. + * @return a list of matching, autocompleted file paths. If autocomplete is + * not supported, simply returns the given path as a result. */ std::vector autocomplete(const std::string &path, const ResourceType type, diff --git a/src/core/resource/ResourceRequest.cpp b/src/core/resource/ResourceRequest.cpp index 79e1ff7..ed94b2d 100644 --- a/src/core/resource/ResourceRequest.cpp +++ b/src/core/resource/ResourceRequest.cpp @@ -206,6 +206,9 @@ bool ResourceRequest::deduce(Registry ®istry, Logger &logger) ok = false; } } else { + // Autocompletion already tries to determine the file path, so + // if an empty list is returned, this means that the resource + // is explicitly not found logger.error(std::string("Resource \"") + path + std::string("\" not found")); ok = false; -- cgit v1.2.3