blob: ffc72da040b305d01c9254a5b27add569823a072 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "banjo/source_location.h"
namespace banjo {
StringView SourceLocation::SourceLine(SourceFile::Position* position_out) const {
return source_file_->LineContaining(data(), position_out);
}
std::string SourceLocation::position() const {
std::string position(source_file_->filename());
SourceFile::Position pos;
SourceLine(&pos);
position.push_back(':');
position.append(std::to_string(pos.line));
position.push_back(':');
position.append(std::to_string(pos.column));
return position;
}
} // namespace banjo