2017-12-19 20:23:48 +08:00
|
|
|
//===--- SourceCode.h - Manipulating source code as strings -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Various code that examines C++ source code without using heavy AST machinery
|
|
|
|
// (and often not even the lexer). To be used sparingly!
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
|
|
|
|
#include "Protocol.h"
|
2018-02-21 10:39:08 +08:00
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2017-12-19 20:23:48 +08:00
|
|
|
|
|
|
|
namespace clang {
|
2018-02-21 10:39:08 +08:00
|
|
|
class SourceManager;
|
|
|
|
|
2017-12-19 20:23:48 +08:00
|
|
|
namespace clangd {
|
|
|
|
|
|
|
|
/// Turn a [line, column] pair into an offset in Code.
|
|
|
|
size_t positionToOffset(llvm::StringRef Code, Position P);
|
|
|
|
|
|
|
|
/// Turn an offset in Code into a [line, column] pair.
|
|
|
|
Position offsetToPosition(llvm::StringRef Code, size_t Offset);
|
|
|
|
|
2018-02-21 10:39:08 +08:00
|
|
|
/// Turn a SourceLocation into a [line, column] pair.
|
|
|
|
Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc);
|
|
|
|
|
2017-12-19 20:23:48 +08:00
|
|
|
} // namespace clangd
|
|
|
|
} // namespace clang
|
|
|
|
#endif
|