Commit Graph

1877 Commits

Author SHA1 Message Date
Fangrui Song
d2b904a514 indexer: llvm::sys::fs::UniqueID -> clang::FileID
Fix a minor issue that an empty included file is not recorded.

Note, we need to skip invalid uid2lid_and_path because
otherwise lid2path may contain invalid entries with lid: 0,
which will cause the file entry with file_id 0 to have an empty path.
2019-11-09 20:09:13 -08:00
Fangrui Song
91abea080b 💥 Rename FunctionName -> functionName, VarName -> var_name 2019-11-09 20:09:13 -08:00
Fangrui Song
1ca8d45914 textDocument/definition: don't jump to the type definition 2019-11-09 20:09:13 -08:00
Fangrui Song
373e502dd3 project: allow absolute compilationDatabaseDirectory
Fix #466
2019-11-09 20:09:13 -08:00
Shengjing Zhu
5200f431f1 Support override CLANG_RESOURCE_DIR
The result from clang commandline is something like
/usr/lib/llvm-7/lib/clang/7.0.1

Which means I need to recompile when the clang is upgraded to newer 7.x.x

However the system has a convenient symlink, which is
/usr/include/clang/7.
2019-11-09 20:09:13 -08:00
Fangrui Song
6528dcb81d Construct SourceManager with UserFilesAreVolatile
Fix #235. Close #453

In clang, it may be worth generalizing UserFilesAreVolatile (introduced in rC160074) to FilesAreVolatile.
2019-11-09 20:09:13 -08:00
Fangrui Song
9ff1897dfb project: improve ComputeGuessScore heuristics 2019-11-09 20:09:13 -08:00
Fangrui Song
d965bcdb1d Support indexing non-existent files in index.onChange:true mode 2019-11-09 20:09:13 -08:00
Fangrui Song
7e7a120c48 $ccls/fileInfo: optionally dump dependencies, includes and skipped_ranges 2019-11-09 20:09:13 -08:00
Riatre Foo
034bd1615f Change RequestId::value from int to std::string to allow non-numeric IDs. 2019-11-09 20:09:13 -08:00
Dan Čermák
0ca7d350cf Only add include directories for LLVM, clang & rapidjson if they are not in CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
/usr/include/c++/9 comes before /usr/include in `{clang,gcc} -v -fsyntax-only -xc++ /dev/null`.

    target_include_directories(ccls SYSTEM PRIVATE ${RapidJSON_INCLUDE_DIRS})

If ${RapidJSON_INCLUDE_DIRS} resolves to /usr/include, /usr/include will
be shuffled before /usr/include/c++/9 and will cause `#include_next <stdlib.h>`
issues (see https://github.com/MaskRay/ccls/pull/417).

Check if the include directories are already in CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES.
2019-11-09 20:09:13 -08:00
Fangrui Song
e89e3105b7 project: support %cu directive and strip -M* options 2019-11-09 20:09:13 -08:00
Fangrui Song
73b75a2869 pipeline: report changed arg 2019-11-09 20:09:13 -08:00
Fangrui Song
6d0a096272 Adapt rL364464: clang::FrontendAction::Execute returns llvm::Error instead of bool 2019-11-09 20:09:13 -08:00
TÖRÖK Attila
2d11cc25c1 threaded_queue.hh: fix -Wpessimizing-move (#409) 2019-11-09 20:09:13 -08:00
Fangrui Song
d55fd001bc utils.hh: work around MSVC STL bug 2019-11-09 20:09:13 -08:00
Fangrui Song
7f291c6dd5 Set Diag::concerned if any of its Notes is concerned 2019-11-09 20:09:13 -08:00
Fangrui Song
d472ffc46b Adapt llvm rL360179: Option may have multiple OptionCategory's 2019-11-09 20:09:13 -08:00
Fangrui Song
4dd97d4e27 Refactor FindEntry and use best-fit .ccls
Fixes an issue with hierarchical .ccls found by Riatre in #384
2019-11-09 20:09:13 -08:00
Fangrui Song
bd0006a8f0 JsonWriter: write "null" if VersionedTextDocumentIdentifier.version is null
Fix #387
2019-11-09 20:09:13 -08:00
Riatre Foo
137a9cd638 Append '/' before populating folder.dot_ccls 2019-11-09 20:09:13 -08:00
Fangrui Song
ea8baa68db Adapt clang rC358696: removal of OutputIsBinary 2019-11-09 20:09:13 -08:00
Fangrui Song
b1bcd0e0a2 Set RetainCommentsFromSystemHeaders to true
Note with -fretain-comments-from-system-headers, the .gch of bits/stdc++.h becomes larger by 1%, but that is fine.

And improve comment handling in textDocument/hover

Fix #373
2019-11-09 20:09:13 -08:00
Fangrui Song
1d3fba276f Set RetainRemappedFileBuffers to true
Reported by David Welch in #350.

This fixes double-free of llvm::MemoryBuffer when parsing fails.
2019-11-09 20:09:13 -08:00
Fangrui Song
539ca22e5e Add error checking of object deserialization; ignore non-object initializationOptions 2019-11-09 20:09:13 -08:00
Fangrui Song
193eacc837 Adapt clang rC357037: removal of setVirtualFileSystem 2019-11-09 20:09:13 -08:00
Fangrui Song
752012fa19 Add initialization option index.initialNoLinkage: false
By default, the background indexer doesn't handle names of no linkage.
They are indexed when their files are opened. This saves memory and
makes cache files smaller.
2019-11-09 20:09:13 -08:00
Paul Smith
58530719f1 Enhance the output of --version with Git describe results. (#342) 2019-11-09 20:09:13 -08:00
Fangrui Song
4d68101d0a Change containers of Query*::Def fields from std::vector to ccls::Vec
Query*::Def contain several immutable std::vector fields. Change them to
ccls::Vec to save bytes which were wasted by `capacity`.
2019-11-09 20:09:13 -08:00
Fangrui Song
89ec8ed236 Add initialization option index.name.suppressUnwrittenScope (default: false) 2019-11-09 20:09:13 -08:00
Fangrui Song
c74d3df3e4 If the workspace folder is a symlink, convert paths relative to it (#314)
If the workspace folder is a symlink and the client doesn't follow it.
Treat /tmp/symlink/ as canonical and convert every /tmp/real/ path to
/tmp/symlink/.
2019-11-09 20:09:13 -08:00
Fangrui Song
bbb28c93eb cmake: use {LLVM,Clang}Config.cmake
Combined Daan De Meyer's #227 with other simplification

* USE_SHARED_LLVM is deleted in favor of LLVM_LINK_LLVM_DYLIB
* LLVM_ENABLE_RTTI is deleted as it is provided by LLVMConfig.cmake
* Only direct Clang/LLVM dependencies are required in target_link_libraries
* Restrict -DCLANG_RESOURCE_DIRECTORY= to src/utils.cc
2019-11-09 20:09:13 -08:00
Fangrui Song
5c9b055eaf Add excludeRole to documentSymbol and override declaration's range/selectionRange with definition's 2019-11-09 20:09:13 -08:00
Fangrui Song
09b6f64cca cmake: add option to use system rapidjson if exists 2019-11-09 20:09:13 -08:00
Fangrui Song
be391ee72d Misc 2019-11-09 20:09:13 -08:00
Fangrui Song
38f4a8ac78 Make clang.excludeArgs accept glob patterns 2019-11-09 20:09:13 -08:00
Fangrui Song
fcfd0dddcf stdin: synthesize an "exit" NotificationMessage in abnormal termination 2019-11-09 20:09:13 -08:00
Fangrui Song
75684f0883 textDocument/rename: mitigate edits in the same place and edits in macro replacement
Mitigate edits in the same place (#294) and:

// textDocument/rename on `f`
void f();
void g() { m(); } // incorrectly rewrote m() before
2019-11-09 20:09:13 -08:00
Fangrui Song
bae9ecfe61 Add .github/ISSUE_TEMPLATE
Adapted from https://github.com/hlissner/doom-emacs
2019-11-09 20:09:13 -08:00
Fangrui Song
3594b66eee working_files: normalize \r\n and \n to \n
Clients may normalize end-of-line sequences, thus cause a mismatch
between index_lines and buffer_lines.

Thanks to CXuesong for reporting this issue!
2019-11-09 20:09:13 -08:00
Fangrui Song
cafd2d4f77 Change Pos::line from int16_t to uint16_t
This allows representing line 0 ~ 65535.
2019-11-09 20:09:13 -08:00
Fangrui Song
dd9d21083b Make hover more detailed (e.g. include inheritance info) 2019-11-09 20:09:13 -08:00
Fangrui Song
9438be32c6 indexer: index TemplateTypeParmDecl and ParmVarDecl in declarations for clang >= 9
Index ParmVarDecl in declarations if index.parametersInDeclarations is true

And support some unhandled Decl::Kind
2019-11-09 20:09:13 -08:00
Fangrui Song
f700ac7b4c Add cache.{hierarchicalPath,retainInMemory}
cache.hierarchicalPath: store cache files as $directory/a/b/c.cc.blob to
work around NAME_MAX limitation.

cache.retainInMemory: after this number of loads, keep a copy of file
index in memory. If set to 1, it avoids cache corruption if the index
file is changed after the initial load, which may happen if several
language clients open the same project and share the same cache
directory.

Also rename cacheDirectory cacheFormat to cache.{directory,format}
2019-11-09 20:09:13 -08:00
Leszek Swirski
7e0d8a4357 Use DiagnosticRelatedInformation if client supports publishDiagnostics.relatedInformation (#276)
In clients that support DiagnosticRelatedInformation, display
clang notes as these nested diagnostics rather than appending
them to the parent diagnostic's message. Behaviour for clients
that don't support related information should be unchanged.
2019-11-09 20:09:13 -08:00
Fangrui Song
4f9e7b219e indexer: change Pos computation from byte offset to UTF-8 encoded code point offset 2019-11-09 20:09:13 -08:00
Fangrui Song
7bc952e543 Add initialization option capabilities.* and index.maxInitializerLines
indexer.cc: use index.maxInitializerLines instead of kInitializerMaxLines

messages/initialize.cc: some ServerCapabilities are toggable:

documentOnTypeFormattingProvider.firstTriggerCharacter
foldingRangeProvider
workspace.workspaceFolders.supported
2019-11-09 20:09:13 -08:00
Fangrui Song
f54a350e0c GetFallback: append clang.extraArgs
When compile_commands.json is absent, GetFallback is called to get
default clang command line when there is no .ccls or .ccls is empty.
2019-11-09 20:09:13 -08:00
Fangrui Song
4fd6e11c90 Compute CompletionItemKind from Declaration instead of CursorKind 2019-11-09 20:09:13 -08:00
Riatre Foo
983b40370a Fix is_local for vars with non-auto storage period 2019-11-09 20:09:13 -08:00