| Sam McCall | 98775c5 | 2017-12-04 13:49:59 +0000 | [diff] [blame] | 1 | //===--- CodeComplete.h -----------------------------------------*- C++-*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===---------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Code completion provides suggestions for what the user might type next. |
| 11 | // After "std::string S; S." we might suggest members of std::string. |
| 12 | // Signature help describes the parameters of a function as you type them. |
| 13 | // |
| 14 | //===---------------------------------------------------------------------===// |
| 15 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H |
| 16 | #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H |
| 17 | |
| 18 | #include "Logger.h" |
| 19 | #include "Path.h" |
| 20 | #include "Protocol.h" |
| 21 | #include "clang/Frontend/PrecompiledPreamble.h" |
| 22 | #include "clang/Sema/CodeCompleteOptions.h" |
| 23 | #include "clang/Tooling/CompilationDatabase.h" |
| 24 | |
| 25 | namespace clang { |
| 26 | class PCHContainerOperations; |
| 27 | namespace clangd { |
| 28 | |
| 29 | struct CodeCompleteOptions { |
| 30 | /// Returns options that can be passed to clang's completion engine. |
| 31 | clang::CodeCompleteOptions getClangCompleteOpts() const; |
| 32 | |
| 33 | /// When true, completion items will contain expandable code snippets in |
| 34 | /// completion (e.g. `return ${1:expression}` or `foo(${1:int a}, ${2:int |
| 35 | /// b})). |
| 36 | bool EnableSnippets = false; |
| 37 | |
| 38 | /// Add code patterns to completion results. |
| 39 | /// If EnableSnippets is false, this options is ignored and code patterns will |
| 40 | /// always be omitted. |
| 41 | bool IncludeCodePatterns = true; |
| 42 | |
| 43 | /// Add macros to code completion results. |
| 44 | bool IncludeMacros = true; |
| 45 | |
| 46 | /// Add globals to code completion results. |
| 47 | bool IncludeGlobals = true; |
| 48 | |
| 49 | /// Add brief comments to completion items, if available. |
| 50 | /// FIXME(ibiryukov): it looks like turning this option on significantly slows |
| 51 | /// down completion, investigate if it can be made faster. |
| 52 | bool IncludeBriefComments = true; |
| 53 | |
| 54 | /// Include results that are not legal completions in the current context. |
| 55 | /// For example, private members are usually inaccessible. |
| 56 | bool IncludeIneligibleResults = false; |
| 57 | |
| 58 | /// Limit the number of results returned (0 means no limit). |
| 59 | /// If more results are available, we set CompletionList.isIncomplete. |
| 60 | size_t Limit = 0; |
| 61 | }; |
| 62 | |
| 63 | /// Get code completions at a specified \p Pos in \p FileName. |
| 64 | CompletionList codeComplete(PathRef FileName, |
| 65 | const tooling::CompileCommand &Command, |
| 66 | PrecompiledPreamble const *Preamble, |
| 67 | StringRef Contents, Position Pos, |
| 68 | IntrusiveRefCntPtr<vfs::FileSystem> VFS, |
| 69 | std::shared_ptr<PCHContainerOperations> PCHs, |
| 70 | CodeCompleteOptions Opts, Logger &Logger); |
| 71 | |
| 72 | /// Get signature help at a specified \p Pos in \p FileName. |
| 73 | SignatureHelp |
| 74 | signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, |
| 75 | PrecompiledPreamble const *Preamble, StringRef Contents, |
| 76 | Position Pos, IntrusiveRefCntPtr<vfs::FileSystem> VFS, |
| 77 | std::shared_ptr<PCHContainerOperations> PCHs, Logger &Logger); |
| 78 | |
| 79 | } // namespace clangd |
| 80 | } // namespace clang |
| 81 | |
| 82 | #endif |