Commit Graph

1567 Commits

Author SHA1 Message Date
Fangrui Song
38e87a0729 Make EmptyParam empty & rewrite LruCache 2019-11-09 20:09:13 -08:00
Fangrui Song
9603a73421 constexpr std::string_view -> const std::string_view
This works around gcc 7.2/clang rC347417 which have a bad interaction with libstdc++'s implementation of P0426
constexpr std::string_view also emits a string_view object in .rodata that cannot be optimized out by clang (which means larger object file size)

So use good old const.
2019-11-09 20:09:13 -08:00
Fangrui Song
7f8f68c0b2 codeAction: use codeActionProvider: CodeActionOptions and respect CodeActionParams::range 2019-11-09 20:09:13 -08:00
Fangrui Song
19d38bc1d2 Make DocumentLink::range narrower
Thanks to Riatre #135
2019-11-09 20:09:13 -08:00
Fangrui Song
0f0c328a91 completion: delete insertText; don't set filterText if it is the same as label
It decreases Content-Length: from 32K to 25K for the following case:

 #include <bits/stdc++.h>
int main() { std::| }

Also

* make results deterministic when completion text is empty
* sort by newText, label, filterText
2019-11-09 20:09:13 -08:00
Fangrui Song
98be09cc2e serializer: make visitor/vis value/v consistent 2019-11-09 20:09:13 -08:00
Fangrui Song
741d8f2130 Refactor ReplyOnce; error if InitializeParams.rootUri is null 2019-11-09 20:09:13 -08:00
Fangrui Song
8f442c6c35 indexer: handle DecltypeType and empty main file; diag: -Wno-unused-function for headers
Don't replace name with qualified name in Cls::*name
2019-11-09 20:09:13 -08:00
Fangrui Song
e27a5eaff9 .ccls: add %objective-c %objective-cpp
Also allow multiple directives on a line, e.g. %c %cpp -DFOO
2019-11-09 20:09:13 -08:00
Fangrui Song
46d3f075dc Use clang::isIdentifierBody and clean up utils/working_files 2019-11-09 20:09:13 -08:00
Fangrui Song
95bba3ed15 hierarchicalDocumentSymbol: support SymbolKind::Function declaration and uniquify by range
Also ensure selectionRange is a subrange of range, otherwise VSCode won't show the item.
Use detailed_name for 'detail'
2019-11-09 20:09:13 -08:00
Fangrui Song
985f5ec4d3 Use SM.isWrittenInMainFile; suppress -Werror in preamble
SM.isWrittenInMainFile is to work around preamble bug: spurious err_pp_unterminated_conditional with circular #include
2019-11-09 20:09:13 -08:00
Fangrui Song
d9a31a72bd hierarchicalDocumentSymbol: display member function declarations 2019-11-09 20:09:13 -08:00
Fangrui Song
aaa5008ec6 Fix some MSVC 2017 errors
Thanks to Dso Tsin!
2019-11-09 20:09:13 -08:00
Fangrui Song
d398e071dc If clang >= 8, delete search path detection and use Sema::CodeCompleteIncludedFile 2019-11-09 20:09:13 -08:00
Fangrui Song
444f0db1f2 Work around relative --sysroot= 2019-11-09 20:09:13 -08:00
Fangrui Song
02a6f39559 Improve semantic highlight in templates 2019-11-09 20:09:13 -08:00
Fangrui Song
09669fff76 Reduce MAKE_REFLECT_STRUCT in lsp.hh
Position -> Pos; lsPosition -> Position
2019-11-09 20:09:13 -08:00
Fangrui Song
0d4f4b68c0 Remove ls prefix from many LSP interfaces
Rename SymbolKind to Kind & lsSymbolKind to SymbolKind
Use textDocumentSync: TextDocumentSyncOptions
2019-11-09 20:09:13 -08:00
Fangrui Song
9a6851c6a5 Misc 2019-11-09 20:09:13 -08:00
Fangrui Song
353b398a73 Simplify and work around vscode _sortTextLow 2019-11-09 20:09:13 -08:00
Fangrui Song
857f41c247 project.cc: deduplicate more cases 2019-11-09 20:09:13 -08:00
Fangrui Song
c598f3ebbd Fix EnumConstantDecl's kind & EnumDecl's vars 2019-11-09 20:09:13 -08:00
Fangrui Song
c8e57ee7b3 textDocument/references workspace/symbol: add folders
For textDocument/reference, base/excludeRole/role has been lifted from params.context.* to params.*
2019-11-09 20:09:13 -08:00
Fangrui Song
c4bf9c5d6a Report InvalidParams for serialization error 2019-11-09 20:09:13 -08:00
Fangrui Song
c1422c7a8d Simplify and better compatibility with encodings retaining the feature of low bytes being 1-byte characters 2019-11-09 20:09:13 -08:00
Fangrui Song
bbce333042 *.h -> *.hh 2019-11-09 20:09:13 -08:00
Fangrui Song
3cd0ee2fc7 Refactor message handler and namespace ccls 2019-11-09 20:09:11 -08:00
Fangrui Song
8fa853c321 Implement textDocument/documentLink 2019-11-09 20:03:28 -08:00
Fangrui Song
617cdd89de Implement textDocument/foldingRange 2019-11-09 20:03:28 -08:00
Fangrui Song
4f8889c195 Deprioritize completion items with additionTextEdits 2019-11-09 20:03:28 -08:00
Fangrui Song
dc20ea3b33 Fix textDocument/implementation 2019-11-09 20:03:28 -08:00
Fangrui Song
66bf514b5f Add command line option -index=root to index without starting language server 2019-11-09 20:03:28 -08:00
Fangrui Song
a56b6fb228 Improve DeducedType 2019-11-09 20:03:28 -08:00
Fangrui Song
18b47d3f5c Improve extent of definition/declaration; uniquify typeDefinition 2019-11-09 20:03:28 -08:00
Fangrui Song
46cfd5504a Simplify 2019-11-09 20:03:28 -08:00
Fangrui Song
5fbe4eac83 Add ExtentRef; merge symbol2refcnt and outline2refcnt
Fix hierarchical document symbol for namespaces when there are multiple declarations.
2019-11-09 20:03:28 -08:00
Fangrui Song
bc4dc6720b Add pipeline::{Notify,Reply,ReplyError} and simplify message handling
Delete method.{cc,h}
Rename $ccls/setSkippedRanges to $ccls/publishSkippedRanges
Rename $ccls/publishSemanticHighlighting to $ccls/publishSemanticHighlight; stableId -> id
2019-11-09 20:03:28 -08:00
Fangrui Song
4a1eea75db Misc changes to project
* Better LanguageId detection with clangDriver (e.g. .cu -> types::TY_CUDA)
* fallback when there is no .ccls or compile_commands.json

Also Hide clangTooling options from --help
2019-11-09 20:03:28 -08:00
Fangrui Song
40b47f9ca3 Adapt trunk change and write comments to PCH 2019-11-09 20:03:28 -08:00
Riatre Foo
ec71d4c6c0 Fix hierarchical document symbol
1. Fixed a bug on building document symbol tree: As sym2ds was updated in
place, nested funcs/types may be moved into children of another
lsDocumentSymbol before itself got processed.

2. Namespaces only have declarations, in the old implementation it wasn't included in the result, making the result less hierarchical. This
commit fixes this by including the declarations of a symbol if no
definitions found.
2019-11-09 20:03:28 -08:00
Fangrui Song
82deedf8c3 Add namespace alias clang::vfs = llvm::vfs to adapt D52783
vfs::x should be written as llvm::vfs::x to work around a [namepace.udir] bug before GCC 8 when namespace alias is used
2019-11-09 20:03:28 -08:00
Fangrui Song
7b19c87485 Namespace: improve indexer and don't trace bases in $ccls/member 2019-11-09 20:03:28 -08:00
Riatre Foo
3de62168c8 Fix additionalTextEdits -> textEdit hack for VS Code (#89)
* Fix additionalTextEdits -> textEdit hack for VS Code

Visual Studio Code filters the completion result according to
textEdit.range and filterText, if the textEdit.range overlaps with
existing text, we have to include it in filterText, otherwise it would
be filtered out.

* Fix has_open_paren in FilterCandidates
2019-11-09 20:03:28 -08:00
Fangrui Song
49dd0ed558 Support workspace folders 2019-11-09 20:03:28 -08:00
Fangrui Song
e352604ee4 Improve completion
blacklist some undesired candidates
additionalTextEdits if clang>=7
Use CodePatterns for preprocessor directive completion if there is a #
Prefer textEdit over insertText
2019-11-09 20:03:28 -08:00
Fangrui Song
a920e71711 Clean and update tests after Index* refactoring 2019-11-09 20:03:28 -08:00
Fangrui Song
2864f2c647 Use DeclRef spell to represent Use spell + Use extent 2019-11-09 20:03:28 -08:00
Fangrui Song
08b09bc1da Redesign SymbolRef, Ref, Use
Remove lsLocationEx
2019-11-09 20:03:28 -08:00
Fangrui Song
0c5c3a11be Add completion.maxNum: 100 2019-11-09 20:03:28 -08:00
Fangrui Song
8b2565fcd0 For $ccls/member, use unadjusted RecordDecl (if there is forward declaration) and handle ClassTemplateSpecialization 2019-11-09 20:03:28 -08:00
Fangrui Song
2592dd41dd Add PreambleStatCache 2019-11-09 20:03:28 -08:00
Fangrui Song
31314555bb Use pthread if defined(__unix__) || defined(__APPLE__) 2019-11-09 20:03:28 -08:00
firstlove
9a79b2ece1 regard conversion as method instead of constructor 2019-11-09 20:03:28 -08:00
Fangrui Song
3337d3de8c Add $ccls/info 2019-11-09 20:03:28 -08:00
Fangrui Song
3c332b91de Clean 2019-11-09 20:03:28 -08:00
Fangrui Song
fa2234c894 Use non-inferred entries and build preamble for .h; index on didOpen if no pending requests; documentHighlight 2019-11-09 20:03:28 -08:00
Fangrui Song
083a629f90 Rename some initialization options
* Delete index.enabled which can be achieved with index.blacklist: ['.']
* Move completion.include* to completion.include.*
* move largeFileSize to highlight.largeFileSize
2019-11-09 20:03:28 -08:00
Fangrui Song
8d61b1aadb Revamp codeLens & codeAction
b.ref: references of bases
d.ref: references of derived
when b.ref > 0, don't display 0 ref or x bases
2019-11-09 20:03:28 -08:00
Fangrui Song
153e5c0dcc Construct SourceManager with UserFilesAreVolatile
Prettify pipeline
2019-11-09 20:03:28 -08:00
Fangrui Song
7eacd2664f Support textDocument/{formatting,onTypeFormatting,rangeFormatting} 2019-11-09 20:03:26 -08:00
Fangrui Song
ae19826411 Merge textDocument_did{Change,Close,Open,Save}.cc 2019-11-09 20:01:34 -08:00
Amos Bird
93b5fa198c Update threaded_queue.h (#82)
https://en.cppreference.com/w/cpp/language/fold
2019-11-09 19:58:32 -08:00
Fangrui Song
cff6c4714c Simplify semantic highlighting; improve hover of auto && 2019-11-09 19:58:32 -08:00
Fangrui Song
a3b982f5d7 Add index.trackDependency and improve pipeline 2019-11-09 19:58:32 -08:00
Fangrui Song
d9541c3222 Add index.initial{Blacklist,Whitelist}
index.{blacklist,whitelist}: disable indexes thoroughly
index.initial{Blacklist,Whitelist}: disable initial loading. will still be indexed after opening
2019-11-09 19:58:32 -08:00
Fangrui Song
d5f4f22508 Add GetAdjustedDecl to adjust Decl's that are missed by clangIndex 2019-11-09 19:58:32 -08:00
Fangrui Song
3334b2c4b7 Remove clang_utils.* 2019-11-09 19:58:32 -08:00
Fangrui Song
3dea9486b9 Misc
Move using below #include to make preamble happy
textDocument/references: if no references, first line or last line => list where this file is included
malloc_trim() only if files have been indexed in last cycle
Intern: use CachedHashStringRef
2019-11-09 19:58:32 -08:00
Riatre Foo
dc4f45b018 Allow force disabling snippet via client.snippetSupport 2019-11-09 19:58:32 -08:00
Fangrui Song
f82a436536 documentSymbol: ignore TypeParameter
Reported by Riatre
2019-11-09 19:58:32 -08:00
Riatre Foo
3abbca6474 Include macros in completion result 2019-11-09 19:58:32 -08:00
Fangrui Song
e24079366b Add kind to $ccls/member and iterate all QueryType::def
kind:2 => member functions
kind:3 => nested classes / namespace members
2019-11-09 19:58:32 -08:00
Fangrui Song
daa6fbf4b8 Misc 2019-11-09 19:58:32 -08:00
Fangrui Song
4ea0dee1c9 Fix spurious "Failed to index" errors 2019-11-09 19:58:32 -08:00
Fangrui Song
bf698b85d4 Publish diagnostics of inferred files and change diagnostics.{onChange,onOpen,onSave} from bool to debounce time 2019-11-09 19:58:32 -08:00
Riatre Foo
a5b8def411 Remove chunks with CK_Information kind from insertText. (#78)
Without this ccls inserts "size() const" in the following scenario:

std::string text;
text.si| <-- Trigger completion here and pick "size"
2019-11-09 19:58:32 -08:00
Fangrui Song
f0400fdcf2 Delete file_consumer.* 2019-11-09 19:58:32 -08:00
Fangrui Song
28401961ae Simplify semantic highlighting 2019-11-09 19:58:32 -08:00
Fangrui Song
d9f0de4719 Clean up FileConsumer and improve pipeline 2019-11-09 19:58:32 -08:00
Fangrui Song
110023483a Improve VarDef::type for textDocument/typeDefinition 2019-11-09 19:58:32 -08:00
Fangrui Song
569a7624a6 intern args 2019-11-09 19:58:32 -08:00
Fangrui Song
97e773081b intern strings in dependencies and IndexInclude::resolved_path 2019-11-09 19:58:32 -08:00
Fangrui Song
1249eb1eb0 Simplify pipeline and fix race 2019-11-09 19:58:32 -08:00
Fangrui Song
cffc8c8409 Add hierarchicalDocumentSymbolSupport 2019-11-09 19:58:32 -08:00
Fangrui Song
4b2f53aa5d Add clang.pathMappings to reuse cache files with differect source paths
Use `>` as the separator.
2019-11-09 19:58:32 -08:00
Fangrui Song
1208a7d6b2 Remove [spell.start, spell.end) -> [spell.start, extent.end) hack 2019-11-09 19:58:32 -08:00
Fangrui Song
05c4c85bd6 Skip informative scope foo:: 2019-11-09 19:58:32 -08:00
Fangrui Song
62d0c49b0a Rename hierarchies to $ccls/{call,inheritance,member}
bool flat = false; -> bool hierarchy = false; (set it to true to enable hierarchical view)

Delete $ccls/callers (which is what $ccls/call does now)
2019-11-09 19:58:32 -08:00
Fangrui Song
71f2aee644 Better diagnostics 2019-11-09 19:58:32 -08:00
Fangrui Song
db50943cd7 textDocument/documentSymbol 2019-11-09 19:58:32 -08:00
Fangrui Song
d758b78635 Make $ccls/inheritanceHierarchy and textDocument/typeDefinition find declarations if definitions do not exist; spelling ranges of operator= 2019-11-09 19:58:32 -08:00
Fangrui Song
c633ce437b pipeline improvement for files not having a project entry (e.g. .h) 2019-11-09 19:58:32 -08:00
Fangrui Song
f939b6cc44 Make $ccls/reload reset DB and reload cached index files
$ccls/reload is renamed from $ccls/freshenIndex

This is useful when DB (merged index) diverges from backing IndexFile.

Also fix a semantic highlighting bug.
2019-11-09 19:58:32 -08:00
Riatre Foo
082096b613 Normalize paths on Windows
1. Normalize paths in LSP document URIs and project root to forward
slash and uppercase drive letters.
2. Normalize paths in compile_commands.json to forward slash and
uppercase drive letters.
3. Normalize paths from directory listing to forward slash. (Drive
letter should be same as input dir path, which is already uppercase
since path of project root dir is normalized)
4. Add llvm::sys::path::convert_to_slash after certain llvm::sys::path
and llvm::fs calls.
2019-11-09 19:58:32 -08:00
Fangrui Song
fa8b032301 diagnostics; use custom DenseMapInfo 2019-11-09 19:58:32 -08:00
Fangrui Song
68fba7989d Revamp completion and signatureHelp, set completion.detailedLabel: true and add completion.duplicateOptional 2019-11-09 19:58:32 -08:00
Fangrui Song
1b367eeb4b Misc 2019-11-09 19:58:32 -08:00
Fangrui Song
46db389c81 Make CXXConversion references wider; use getTypedefNameForAnonDecl; improve CXXDestructor CXXConversion spell 2019-11-09 19:58:32 -08:00
Fangrui Song
68a27e746d Add diagnostics.onSave 2019-11-09 19:58:32 -08:00
Fangrui Song
1df131d411 Reuse preamble (built by "comp-preload") in indexer 2019-11-09 19:58:32 -08:00
Fangrui Song
f1d9a93819 Support empty cacheDirectory and fix cache load 2019-11-09 19:58:32 -08:00
Fangrui Song
0ba4a7f0a9 Implement index.onChange: true; enable spell checking for diagnostics 2019-11-09 19:58:32 -08:00
Fangrui Song
017a91c30e Add DeclUse as element type of declarations 2019-11-09 19:58:32 -08:00
Fangrui Song
ce72cf7bd9 Remove $ccls/base and clean up; deduplicate codeLens 2019-11-09 19:58:32 -08:00
Fangrui Song
69f749ac9f Improve hover and documentSymbol 2019-11-09 19:58:32 -08:00
Fangrui Song
8a2438411e Add clang.excludeArgs and rename diagnostics.onType to onChange 2019-11-09 19:58:32 -08:00
Fangrui Song
d864f969ad Add $ccls/navigate and improve textDocument/definition 2019-11-09 19:58:29 -08:00
Fangrui Song
d22e6402d9 Add all: boolean to textDocument/documentSymbol 2019-10-24 01:13:24 -07:00
Fangrui Song
d3e0a4c4fd Add index.multiVersion{Black,White}list
They allow files matching specified patterns to be indexed only once
even if index.multiVersion > 0. An example is to exclude system headers
with index.multiVersionBlacklist: ["^/usr/include"]
2019-10-24 01:13:24 -07:00
Fangrui Song
4f67bd03d5 index.multiVersion: int
Before, QueryFile::Def::{all_symbols,outline} were built by indexers.
Now, {symbol,outline}2refcnt are used instead, built by main thread.
*_removed are augmented with Query*:Def to allow removal of old {symbol,outline}2refcnt entries.
2019-10-24 01:13:24 -07:00
Fangrui Song
a8bb605d4a Fix unaligned load/store; add index.multiVersion prototype, rename index.onParse to index.OnOpen
Don't call getFieldOffset() on RD->isInvalidDecl()
2019-10-24 01:13:24 -07:00
Fangrui Song
1ab0d492b7 README 2019-10-24 01:13:24 -07:00
Fangrui Song
6aee7b9648 Remove ASTUnit from indexer and clean up 2019-10-24 01:13:22 -07:00
scturtle
df1717538f Filter deps with index.blacklist. (#64) 2019-10-24 01:12:58 -07:00
Fangrui Song
5c0a146ee4 detailed_name: "{\n}" -> "{}" ; completion 2019-10-24 01:12:58 -07:00
firstlove
ea28e50d0f fix clang_tu.h && clang_complete.cc (#61) 2019-10-24 01:12:58 -07:00
Fangrui Song
fea457616a New diagnostics 2019-10-24 01:12:58 -07:00
Fangrui Song
4c1b8f3811 Use StoreInMemory Preamble for CodeComplete 2019-10-24 01:11:30 -07:00
Fangrui Song
368bd9a283 SkipFunctionBodiesScope; improve fuzzy 2019-10-24 01:01:21 -07:00
Fangrui Song
99fe7c7624 Uniquify $ccls/inheritanceHierarchy and add flat to $ccls/memberHierarchy 2019-10-24 01:01:21 -07:00
Fangrui Song
d7c48d12d6 Fix VarDef::is_local; default cacheDirectory to ".ccls-cache" 2019-10-24 01:01:21 -07:00
Fangrui Song
27a5b24b59 Add license notice 2019-10-24 01:01:21 -07:00
Amos Bird
6e8ba37ad0 correctly grabbing the ownership of index files. (#54) 2019-10-24 01:01:21 -07:00
Fangrui Song
73e500bc97 textDocument/hover: prefer definitions in the same file 2019-10-24 01:01:21 -07:00
Fangrui Song
82962e565b Remove CompileCommandsEntry and reduce clangDriver invocations 2019-10-24 01:01:21 -07:00
Fangrui Song
39787d2851 clang-format
DEF CON 26 CTF
2019-10-24 01:01:21 -07:00
Fangrui Song
7c1e3fc90e Add flat to $ccls/inheritanceHierarchy 2019-10-24 01:01:21 -07:00
Fangrui Song
22627d7a1f Validate RecordDecl 2019-10-24 01:01:21 -07:00
Fangrui Song
fc6e2af66f Uniquify textDocument/references
There can be duplicates with template instantiation.
2019-10-24 01:01:21 -07:00
Fangrui Song
1c0bf0af65 Add textDocument/codeAction for clang FixIt
What do you think of the challenge ccls-fringe in Real World CTF?
2019-10-24 01:01:21 -07:00
Fangrui Song
bfb759fd09 Misc 2019-10-24 01:01:21 -07:00
Chao Shen
8eeb1bb3af Fix diagnostics on MacOS and duplicated bases. 2019-10-24 01:01:20 -07:00
Fangrui Song
bde0e6d837 Improve comment and outline 2019-10-24 01:01:20 -07:00
Chao Shen
f87ee1323c Misc. 2019-10-24 01:01:20 -07:00
Chao Shen
0dae2c4a39 Fix preload completion session. 2019-10-24 01:01:20 -07:00
Fangrui Song
3be281416d Fix Twine; index TypedefNameDecl to specialization; anonymous RecordDecl fields 2019-10-24 01:01:20 -07:00
Fangrui Song
3b997b12ad Use ContainerDC for extent, index callees, set StaticMethod 2019-10-24 01:01:20 -07:00
Fangrui Song
c50f0c5900 Add Query*::file_id to allow textDocument/hover on declarations
Also change StorageClass storage to uint8_t
2019-10-24 01:01:20 -07:00
Fangrui Song
d13586ac4d --init 2019-10-24 01:01:20 -07:00
Fangrui Song
389418f546 Better bases/derived and initializer 2019-10-24 01:01:20 -07:00
Fangrui Song
d6ce5e6768 Fix spell for clang < 7 2019-10-24 01:01:20 -07:00
Fangrui Song
134a09a255 Remove libclang 2019-10-24 01:01:20 -07:00
Fangrui Song
af77e6615d CrashRecoveryContext 2019-10-24 01:01:20 -07:00
Fangrui Song
0f63be2418 Support BindingDecl and VarTemplate{,Partial}SpecializationDecl 2019-10-24 01:01:20 -07:00
Fangrui Song
8cce275206 Misc improvement to indexer
* Make CXXConstructor span one more column to left/right
* Use OrigD to collect Decl::Record members
* Better comment parsing
* Limit lines of initializers and macro definition to 3
* Attribute macro arg uses to spelling loc
* Remove FuncDef::declaring_type
2019-10-24 01:01:20 -07:00
Fangrui Song
ebf07265eb Diagnostics 2019-10-24 01:01:20 -07:00
Fangrui Song
d743743282 Enable clangDriver in project.cc
https://bugs.llvm.org/show_bug.cgi?id=37695 is not fixed. But since we have eliminated libclang for indexing and completion the bug no longer bothers us.
2019-10-24 01:01:20 -07:00
Fangrui Song
b3d5ea8be5 Simplify 2019-10-24 01:01:20 -07:00
Fangrui Song
c4e22bde23 Use Clang C++ for completion and diagnostics 2019-10-24 01:01:20 -07:00