ccls/src/lex_utils.h

46 lines
1.5 KiB
C
Raw Normal View History

2017-06-15 05:32:23 +00:00
#pragma once
#include "language_server_api.h"
#include <string_view.h>
2018-02-03 14:36:07 +00:00
#include <regex>
2017-06-15 05:32:23 +00:00
#include <string>
2018-01-29 14:26:13 +00:00
#include <tuple>
2017-06-15 05:32:23 +00:00
// Utility method to map |position| to an offset inside of |content|.
int GetOffsetForPosition(lsPosition position, std::string_view content);
2017-06-15 05:32:23 +00:00
// Utility method to find a position for the given character.
lsPosition CharPos(std::string_view search,
2017-09-22 01:14:57 +00:00
char character,
int character_offset = 0);
2017-06-15 05:32:23 +00:00
2018-02-03 14:36:07 +00:00
struct ParseIncludeLineResult
{
bool ok;
std::string text; // include the "include" part
std::smatch match;
};
ParseIncludeLineResult ParseIncludeLine(const std::string& line);
void DecorateIncludePaths(const std::smatch& match,
std::vector<lsCompletionItem>* items);
2017-06-15 05:32:23 +00:00
// TODO: eliminate |line_number| param.
optional<lsRange> ExtractQuotedRange(int line_number, const std::string& line);
2017-09-22 01:14:57 +00:00
void LexFunctionDeclaration(const std::string& buffer_content,
lsPosition declaration_spelling,
optional<std::string> type_name,
std::string* insert_text,
int* newlines_after_name);
2017-06-15 05:32:23 +00:00
std::string LexWordAroundPos(lsPosition position, const std::string& content);
// Case-insensitive subsequence matching.
bool SubsequenceMatch(std::string_view search, std::string_view content);
2018-02-03 04:36:44 +00:00
std::tuple<bool, int> SubsequenceCountSkip(std::string_view search,
std::string_view content);