clang-tools 10.0.0

SymbolLocation.cpp
Go to the documentation of this file.
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 Line = MaxLine;
20 return;
21 }
22 Line = L;
23 }
24 void SymbolLocation::Position::setColumn(uint32_t Col) {
25 if (Col > MaxColumn) {
26 Column = MaxColumn;
27 return;
28 }
29 Column = Col;
30 }
31
32 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolLocation &L) {
33 if (!L)
34 return OS << "(none)";
35 return OS << L.FileURI << "[" << L.Start.line() << ":" << L.Start.column()
36 << "-" << L.End.line() << ":" << L.End.column() << ")";
37 }
38
39 } // namespace clangd
40 } // namespace clang
clang::clangd::SymbolLocation::Position::setColumn
void setColumn(uint32_t Column)
Definition: SymbolLocation.cpp:24
clang::clangd::SymbolLocation
Definition: SymbolLocation.h:19
clang::clangd::SymbolLocation::Position::column
uint32_t column() const
Definition: SymbolLocation.h:37
clang::clangd::SymbolLocation::Position::setLine
void setLine(uint32_t Line)
Definition: SymbolLocation.cpp:17
clang::clangd::SymbolLocation::Position::MaxColumn
static constexpr uint32_t MaxColumn
Definition: SymbolLocation.h:44
clang::clangd::SymbolLocation::End
Position End
Definition: SymbolLocation.h:53
clang::clangd::SymbolLocation::Position::MaxLine
static constexpr uint32_t MaxLine
Definition: SymbolLocation.h:43
clang::clangd::SymbolLocation::Start
Position Start
The symbol range, using half-open range [Start, End).
Definition: SymbolLocation.h:52
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::SymbolLocation::Position::line
uint32_t line() const
Definition: SymbolLocation.h:35
clang::clangd::operator<<
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
Definition: CodeComplete.cpp:1850
clang::clangd::SymbolLocation::FileURI
const char * FileURI
Definition: SymbolLocation.h:63
SymbolLocation.h