1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "banjo/source_location.h" 6 7 namespace banjo { 8 SourceLine(SourceFile::Position * position_out) const9StringView SourceLocation::SourceLine(SourceFile::Position* position_out) const { 10 return source_file_->LineContaining(data(), position_out); 11 } 12 position() const13std::string SourceLocation::position() const { 14 std::string position(source_file_->filename()); 15 SourceFile::Position pos; 16 SourceLine(&pos); 17 position.push_back(':'); 18 position.append(std::to_string(pos.line)); 19 position.push_back(':'); 20 position.append(std::to_string(pos.column)); 21 return position; 22 } 23 24 } // namespace banjo 25