1 | //===--- SymbolLocation.cpp --------------------------------------*- C++-*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "SymbolLocation.h" |
10 | |
11 | namespace clang { |
12 | namespace clangd { |
13 | |
14 | constexpr uint32_t SymbolLocation::Position::MaxLine; |
15 | constexpr uint32_t SymbolLocation::Position::MaxColumn; |
16 | |
17 | void SymbolLocation::Position::setLine(uint32_t L) { |
18 | if (L > MaxLine) |
19 | L = MaxLine; |
20 | LineColumnPacked = (L << ColumnBits) | column(); |
21 | } |
22 | void SymbolLocation::Position::setColumn(uint32_t Col) { |
23 | if (Col > MaxColumn) |
24 | Col = MaxColumn; |
25 | LineColumnPacked = (LineColumnPacked & ~MaxColumn) | Col; |
26 | } |
27 | |
28 | llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolLocation &L) { |
29 | if (!L) |
30 | return OS << "(none)"; |
31 | return OS << L.FileURI << "["<< L.Start.line() << ":"<< L.Start.column() |
32 | << "-"<< L.End.line() << ":"<< L.End.column() << ")"; |
33 | } |
34 | |
35 | } // namespace clangd |
36 | } // namespace clang |
37 |