Commit Graph

1540 Commits

Author SHA1 Message Date
Fangrui Song
36f7775a67 Delay requests if the document has not not indexed (#176)
This fixes a plethora of "not indexed" errors when the document has not been indexed.

* Message handler throws NotIndexed if not overdue
* The message is put into backlog and tagged with backlog_path
* path2backlog[path] tracks backlog associated with document `path`
* The backlog is cleared when the index is merged
* backlog[0] is forced to run if it becomes overdue
2019-10-24 18:37:55 -07:00
Fangrui Song
70e0eec831 Adjust FrontendOpts.Inputs[0] for inferred files 2019-10-24 18:37:55 -07:00
Fangrui Song
d430cb8ff9 Handle file deletion and register workspace/didChangeWatchedFiles
* In the "initialized" callback, send client/registerCapability with DidChangeWatchedFilesRegistrationOptions
* In workspace/didChangeWatchedFiles callback, call pipeline::Index
* In pipeline::Index, add a `deleted` status
2019-10-24 18:37:55 -07:00
Fangrui Song
7977bf3edb Make cacheDirectory related to project root; delete Timer 2019-10-24 18:37:55 -07:00
Fangrui Song
61ff7aacc6 completion: ignore CXXDeductionGuide
Fix #173
2019-10-24 18:37:55 -07:00
Fangrui Song
f8c8eca8ee Extend .ccls
* Add %h for C header files (the suffix .h is considered a C header, not a C++ header)
* Add %hpp for C++ header files
* If .ccls exists, it provides full command line for files not specified by compile_commands.json (before, compile_commands.json was ignored)
* If the first line of .ccls is %compile_commands.json, it appends flags to compile_commands.json "arguments", instead of overriding.
  Files not specified by compile_commands.json will not be added to folder.entries, but their command line can be inferred from other files.

Also fix `#include <` completion of -I flags for clang < 8
2019-10-24 18:37:55 -07:00
Fangrui Song
79732bf375 Make -v=1 work and log cflags for SemaManager session and Indexer 2019-10-24 18:37:55 -07:00
Fangrui Song
808aa120d1 Add strict to FuzzyMatcher::Match
In completion, underscore prefixed builtin macros may be annoying when the first type character is not an underscore.

When `strict` is true, `Match` enforces the first characters should be loosely of the same category.
2019-10-24 18:37:55 -07:00
Fangrui Song
cd5c524089 ParameterInformation: use label: [number, number]
Don't bother checking signatureHelp.signatureInformationparameterInformation.labelOffsetSupport
2019-10-24 18:37:55 -07:00
Fangrui Song
ba39be4bcd Support textDocument/declaration & LocationLink
textDocument/{declaration,definition,typeDefinition} return either LocationLink[] or Location[]
Add an initialization option client.linkSupport . When it is false, ccls will return Location[] disregarding client's linkSupport.
`struct LocationLink` does not include originSelectionRange as it is wasteful.
2019-10-24 18:37:55 -07:00
Fangrui Song
926ea421e6 cmake_minimum_required 3.8; clean up 2019-10-24 18:37:55 -07:00
Fangrui Song
7b6768fd1c Rendezvous after receiving "exit" notification (#159) 2019-10-24 18:37:55 -07:00
Fangrui Song
1d7674bdfc Support multiple -init=
Initialization options are applied (deserialized to the same object) in the following order:

* "initializationOptions" from client
* first -init=
* second -init=
* ...

Scalar options will be overridden but arrays will get concatenated, e.g.

ccls -log-file=/dev/stderr -index . -init='{"clang":{"extraArgs":["-DA"]}}' -init='{"clang":{"extraArgs":["-DB"]}}'

results in clang.extraArgs: ["-DA", "-DB"]
2019-10-24 18:37:55 -07:00
Leszek Swirski
e53a1aba97 Spin IncludeComplete's destructor until scanning completes (#147) 2019-10-24 18:37:55 -07:00
Fangrui Song
4416a258ae query: fix UpdateUses when a new entity is seen; simplify {DeclRef,Use,Usr}Update
Thanks to Leszek Swirski
2019-10-24 18:37:55 -07:00
Fangrui Song
cc11d30dad Refactor serializer
Delete virtual bases Reader & Writer
Delete unused MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY
Merge serializers/{json,binary}.hh into serializer.{hh,cc}
MAKE_REFLECT_STRUCT => REFLECT_STRUCT
MAKE_REFLECT_TYPE_PROXY => REFLECT_UNDERLYING
2019-10-24 18:37:55 -07:00
Fangrui Song
1a7e463553 Add ReplyOnce::NotReady and error if didOpen is not seen
Use IgnoringDiagConsumer to override default TextDiagnosticPrinter
2019-10-24 18:37:55 -07:00
Fangrui Song
d49119b364 Refactor WorkingFiles and CompletionManager
* WorkingFiles::files : vector -> unordered_map
* Add timestamp to WorkingFile

* Rename "comp-preload" thread to "preamble"
* Rename CompletionManager to SemaManager as it is used by "diag" "comp" "preamble"
* Rename clang_complete.* to sema_manager.*
* Merge SemaManager::{preloads,sessions}
* Add initialization option session.maxNum
* In DiagnosticMain, if an included file was modified, cancel the DiagTask and create a PreambleTask instead. The task sets `from_diag` so as to trigger immediate DiagTask after the preamble is built.
2019-10-24 18:37:55 -07:00
Fangrui Song
bddd8d1209 completion: use Text for Macro{Instantiation,Definition} 2019-10-24 18:37:54 -07:00
Fangrui Song
58f6f6048f Fix ComputeGuessScore and delete dead code
Thanks to CXuesong
2019-10-24 18:37:54 -07:00
Fangrui Song
ab28a3a7ce Merge maybe.hh into utils.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
5b41788ebb Merge query.hh and query_util.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
bf6fc50b54 Refactor Matcher to use pimpl and merge match.hh into utils.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
a3e635fb09 Make EmptyParam empty & rewrite LruCache 2019-10-24 18:37:54 -07:00
Fangrui Song
6379beb9ba 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-10-24 18:37:54 -07:00
Fangrui Song
385eb582c8 codeAction: use codeActionProvider: CodeActionOptions and respect CodeActionParams::range 2019-10-24 18:37:54 -07:00
Fangrui Song
38227e2bd5 Make DocumentLink::range narrower
Thanks to Riatre #135
2019-10-24 18:37:54 -07:00
Fangrui Song
8fc6b8a9f4 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-10-24 18:37:54 -07:00
Fangrui Song
9d767ffa99 serializer: make visitor/vis value/v consistent 2019-10-24 18:37:54 -07:00
Fangrui Song
e6300aeb57 Refactor ReplyOnce; error if InitializeParams.rootUri is null 2019-10-24 18:37:54 -07:00
Fangrui Song
008b1762c1 indexer: handle DecltypeType and empty main file; diag: -Wno-unused-function for headers
Don't replace name with qualified name in Cls::*name
2019-10-24 18:37:54 -07:00
Fangrui Song
2d00b62f63 .ccls: add %objective-c %objective-cpp
Also allow multiple directives on a line, e.g. %c %cpp -DFOO
2019-10-24 18:37:54 -07:00
Fangrui Song
c2cf488114 Use clang::isIdentifierBody and clean up utils/working_files 2019-10-24 18:37:54 -07:00
Fangrui Song
d2969b5185 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-10-24 18:37:54 -07:00
Fangrui Song
2e16b3c6bb Use SM.isWrittenInMainFile; suppress -Werror in preamble
SM.isWrittenInMainFile is to work around preamble bug: spurious err_pp_unterminated_conditional with circular #include
2019-10-24 18:37:54 -07:00
Fangrui Song
6283f7e919 hierarchicalDocumentSymbol: display member function declarations 2019-10-24 18:37:54 -07:00
Fangrui Song
c84895e39d Fix some MSVC 2017 errors
Thanks to Dso Tsin!
2019-10-24 18:37:54 -07:00
Fangrui Song
cb06324c13 If clang >= 8, delete search path detection and use Sema::CodeCompleteIncludedFile 2019-10-24 18:37:54 -07:00
Fangrui Song
3e39b86981 Work around relative --sysroot= 2019-10-24 18:37:54 -07:00
Fangrui Song
ceeae84662 Improve semantic highlight in templates 2019-10-24 18:37:54 -07:00
Fangrui Song
6dfe5d1c4f Reduce MAKE_REFLECT_STRUCT in lsp.hh
Position -> Pos; lsPosition -> Position
2019-10-24 18:37:54 -07:00
Fangrui Song
50736827ca Remove ls prefix from many LSP interfaces
Rename SymbolKind to Kind & lsSymbolKind to SymbolKind
Use textDocumentSync: TextDocumentSyncOptions
2019-10-24 18:37:54 -07:00
Fangrui Song
6517f9f143 Misc 2019-10-24 18:37:54 -07:00
Fangrui Song
85b449df03 Simplify and work around vscode _sortTextLow 2019-10-24 18:37:54 -07:00
Fangrui Song
b0863ba366 project.cc: deduplicate more cases 2019-10-24 18:37:54 -07:00
Fangrui Song
041ce5b6f1 Fix EnumConstantDecl's kind & EnumDecl's vars 2019-10-24 18:37:54 -07:00
Fangrui Song
9b0ff9f9ea textDocument/references workspace/symbol: add folders
For textDocument/reference, base/excludeRole/role has been lifted from params.context.* to params.*
2019-10-24 18:37:54 -07:00
Fangrui Song
4c6278c152 Report InvalidParams for serialization error 2019-10-24 18:37:54 -07:00
Fangrui Song
ca550720e4 Simplify and better compatibility with encodings retaining the feature of low bytes being 1-byte characters 2019-10-24 18:37:54 -07:00
Fangrui Song
e3a2f1a9a8 *.h -> *.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
67eb1e6b23 Refactor message handler and namespace ccls 2019-10-24 18:37:53 -07:00
Fangrui Song
05929b8afb Implement textDocument/documentLink 2019-10-24 18:37:35 -07:00
Fangrui Song
6de2789635 Implement textDocument/foldingRange 2019-10-24 18:37:35 -07:00
Fangrui Song
2180320540 Deprioritize completion items with additionTextEdits 2019-10-24 18:37:35 -07:00
Fangrui Song
65fc01c671 Fix textDocument/implementation 2019-10-24 18:37:35 -07:00
Fangrui Song
6ce79155a9 Add command line option -index=root to index without starting language server 2019-10-24 18:37:35 -07:00
Fangrui Song
a1094c0897 Improve DeducedType 2019-10-24 18:37:35 -07:00
Fangrui Song
610798f634 Improve extent of definition/declaration; uniquify typeDefinition 2019-10-24 18:37:35 -07:00
Fangrui Song
ca1edb582e Simplify 2019-10-24 18:37:35 -07:00
Fangrui Song
556e611573 Add ExtentRef; merge symbol2refcnt and outline2refcnt
Fix hierarchical document symbol for namespaces when there are multiple declarations.
2019-10-24 18:37:35 -07:00
Fangrui Song
6deadc5f24 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-10-24 18:37:35 -07:00
Fangrui Song
8fea558f95 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-10-24 18:37:35 -07:00
Fangrui Song
78e323b662 Adapt trunk change and write comments to PCH 2019-10-24 18:37:35 -07:00
Riatre Foo
5a442dfb53 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-10-24 18:37:35 -07:00
Fangrui Song
5fb2407685 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-10-24 18:37:35 -07:00
Fangrui Song
56c70ad1fd Namespace: improve indexer and don't trace bases in $ccls/member 2019-10-24 18:37:35 -07:00
Riatre Foo
d98965d8d9 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-10-24 18:37:35 -07:00
Fangrui Song
3bf5002c98 Support workspace folders 2019-10-24 18:37:35 -07:00
Fangrui Song
798cf7852d 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-10-24 18:37:35 -07:00
Fangrui Song
9ad26111ef Clean and update tests after Index* refactoring 2019-10-24 18:37:35 -07:00
Fangrui Song
53e6a15f34 Use DeclRef spell to represent Use spell + Use extent 2019-10-24 18:37:35 -07:00
Fangrui Song
fc4b5b00c0 Redesign SymbolRef, Ref, Use
Remove lsLocationEx
2019-10-24 18:37:35 -07:00
Fangrui Song
bb124b132e Add completion.maxNum: 100 2019-10-24 18:37:35 -07:00
Fangrui Song
46c99cda02 For $ccls/member, use unadjusted RecordDecl (if there is forward declaration) and handle ClassTemplateSpecialization 2019-10-24 18:37:35 -07:00
Fangrui Song
b0d85fa6f3 Add PreambleStatCache 2019-10-24 18:37:35 -07:00
Fangrui Song
093abb89b5 Use pthread if defined(__unix__) || defined(__APPLE__) 2019-10-24 18:37:35 -07:00
firstlove
334e4f32ac regard conversion as method instead of constructor 2019-10-24 18:37:35 -07:00
Fangrui Song
d998861d2e Add $ccls/info 2019-10-24 18:37:35 -07:00
Fangrui Song
f737ac31db Clean 2019-10-24 18:37:35 -07:00
Fangrui Song
bd8d065da9 Use non-inferred entries and build preamble for .h; index on didOpen if no pending requests; documentHighlight 2019-10-24 18:37:35 -07:00
Fangrui Song
0273c59ac7 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-10-24 18:37:35 -07:00
Fangrui Song
2a0ba86675 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-10-24 18:37:35 -07:00
Fangrui Song
b0959deead Construct SourceManager with UserFilesAreVolatile
Prettify pipeline
2019-10-24 18:37:35 -07:00
Fangrui Song
c437b16ef7 Support textDocument/{formatting,onTypeFormatting,rangeFormatting} 2019-10-24 18:37:35 -07:00
Fangrui Song
0cc9160ef7 Merge textDocument_did{Change,Close,Open,Save}.cc 2019-10-24 18:37:35 -07:00
Amos Bird
fa07ed1519 Update threaded_queue.h (#82)
https://en.cppreference.com/w/cpp/language/fold
2019-10-24 18:37:35 -07:00
Fangrui Song
058ac08621 Simplify semantic highlighting; improve hover of auto && 2019-10-24 18:37:35 -07:00
Fangrui Song
d425e15cdb Add index.trackDependency and improve pipeline 2019-10-24 18:37:35 -07:00
Fangrui Song
4420bcf76f 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-10-24 18:37:35 -07:00
Fangrui Song
5b7758a6ca Add GetAdjustedDecl to adjust Decl's that are missed by clangIndex 2019-10-24 18:37:35 -07:00
Fangrui Song
35cba6d49c Remove clang_utils.* 2019-10-24 18:37:35 -07:00
Fangrui Song
395e9d8724 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-10-24 18:37:35 -07:00
Riatre Foo
174466516e Allow force disabling snippet via client.snippetSupport 2019-10-24 18:37:35 -07:00
Fangrui Song
dfdabe41b2 documentSymbol: ignore TypeParameter
Reported by Riatre
2019-10-24 18:37:35 -07:00
Riatre Foo
61a61dd4a2 Include macros in completion result 2019-10-24 18:37:35 -07:00
Fangrui Song
562207bf96 Add kind to $ccls/member and iterate all QueryType::def
kind:2 => member functions
kind:3 => nested classes / namespace members
2019-10-24 18:37:35 -07:00
Fangrui Song
176039fe35 Misc 2019-10-24 18:37:35 -07:00
Fangrui Song
5a8b36c997 Fix spurious "Failed to index" errors 2019-10-24 18:37:35 -07:00
Fangrui Song
4792ad845b Publish diagnostics of inferred files and change diagnostics.{onChange,onOpen,onSave} from bool to debounce time 2019-10-24 18:37:35 -07:00
Riatre Foo
1a2e31660c 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-10-24 18:37:35 -07:00