2018-08-21 05:27:52 +00:00
|
|
|
/* Copyright 2017-2018 ccls Authors
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==============================================================================*/
|
|
|
|
|
2018-01-17 01:48:22 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-07 21:20:31 +00:00
|
|
|
#include "lsp.h"
|
2018-01-17 01:48:22 +00:00
|
|
|
#include "serializer.h"
|
|
|
|
|
2018-02-13 01:15:19 +00:00
|
|
|
// The order matters. In FindSymbolsAtLocation, we want Var/Func ordered in
|
|
|
|
// front of others.
|
|
|
|
enum class SymbolKind : uint8_t { Invalid, File, Type, Func, Var };
|
|
|
|
MAKE_REFLECT_TYPE_PROXY(SymbolKind);
|
2018-01-17 01:48:22 +00:00
|
|
|
|
2018-02-12 18:15:43 +00:00
|
|
|
enum class Role : uint16_t {
|
2018-02-08 02:29:34 +00:00
|
|
|
None = 0,
|
2018-01-29 04:39:41 +00:00
|
|
|
Declaration = 1 << 0,
|
|
|
|
Definition = 1 << 1,
|
|
|
|
Reference = 1 << 2,
|
2018-02-12 18:15:43 +00:00
|
|
|
Read = 1 << 3,
|
|
|
|
Write = 1 << 4,
|
|
|
|
Call = 1 << 5,
|
|
|
|
Dynamic = 1 << 6,
|
|
|
|
Address = 1 << 7,
|
|
|
|
Implicit = 1 << 8,
|
2018-02-22 21:50:46 +00:00
|
|
|
All = (1 << 9) - 1,
|
2018-01-29 04:39:41 +00:00
|
|
|
};
|
2018-02-11 04:01:10 +00:00
|
|
|
MAKE_REFLECT_TYPE_PROXY(Role);
|
2018-01-29 04:39:41 +00:00
|
|
|
|
2018-02-12 18:15:43 +00:00
|
|
|
inline uint16_t operator&(Role lhs, Role rhs) {
|
|
|
|
return uint16_t(lhs) & uint16_t(rhs);
|
2018-01-29 04:39:41 +00:00
|
|
|
}
|
|
|
|
|
2018-02-11 04:01:10 +00:00
|
|
|
inline Role operator|(Role lhs, Role rhs) {
|
2018-02-12 18:15:43 +00:00
|
|
|
return Role(uint16_t(lhs) | uint16_t(rhs));
|
2018-01-29 04:39:41 +00:00
|
|
|
}
|
2018-02-13 01:15:19 +00:00
|
|
|
|
|
|
|
// A document highlight kind.
|
|
|
|
enum class lsDocumentHighlightKind {
|
|
|
|
// A textual occurrence.
|
|
|
|
Text = 1,
|
|
|
|
// Read-access of a symbol, like reading a variable.
|
|
|
|
Read = 2,
|
|
|
|
// Write-access of a symbol, like writing to a variable.
|
|
|
|
Write = 3
|
|
|
|
};
|
|
|
|
MAKE_REFLECT_TYPE_PROXY(lsDocumentHighlightKind);
|
|
|
|
|
|
|
|
// A document highlight is a range inside a text document which deserves
|
|
|
|
// special attention. Usually a document highlight is visualized by changing
|
|
|
|
// the background color of its range.
|
|
|
|
struct lsDocumentHighlight {
|
|
|
|
// The range this highlight applies to.
|
|
|
|
lsRange range;
|
|
|
|
|
|
|
|
// The highlight kind, default is DocumentHighlightKind.Text.
|
|
|
|
lsDocumentHighlightKind kind = lsDocumentHighlightKind::Text;
|
|
|
|
|
2018-03-31 03:16:33 +00:00
|
|
|
// ccls extension
|
2018-02-13 01:15:19 +00:00
|
|
|
Role role = Role::None;
|
|
|
|
};
|
|
|
|
MAKE_REFLECT_STRUCT(lsDocumentHighlight, range, kind, role);
|
|
|
|
|
|
|
|
struct lsSymbolInformation {
|
|
|
|
std::string_view name;
|
|
|
|
lsSymbolKind kind;
|
|
|
|
lsLocation location;
|
2018-09-13 04:03:35 +00:00
|
|
|
std::optional<std::string_view> containerName;
|
2018-02-13 01:15:19 +00:00
|
|
|
};
|
|
|
|
MAKE_REFLECT_STRUCT(lsSymbolInformation, name, kind, location, containerName);
|