annotate clang-tools-extra/clangd/CodeCompletionStrings.h @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===--- CodeCompletionStrings.h ---------------------------------*- C++-*-===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // Functions for retrieving code completion information from
anatofuz
parents:
diff changeset
10 // `CodeCompletionString`.
anatofuz
parents:
diff changeset
11 //
anatofuz
parents:
diff changeset
12 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETIONSTRINGS_H
anatofuz
parents:
diff changeset
15 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETIONSTRINGS_H
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 #include "clang/Sema/CodeCompleteConsumer.h"
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 namespace clang {
anatofuz
parents:
diff changeset
20 class ASTContext;
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 namespace clangd {
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 /// Gets a minimally formatted documentation comment of \p Result, with comment
anatofuz
parents:
diff changeset
25 /// markers stripped. See clang::RawComment::getFormattedText() for the detailed
anatofuz
parents:
diff changeset
26 /// explanation of how the comment text is transformed.
anatofuz
parents:
diff changeset
27 /// Returns empty string when no comment is available.
anatofuz
parents:
diff changeset
28 /// If \p CommentsFromHeaders parameter is set, only comments from the main
anatofuz
parents:
diff changeset
29 /// file will be returned. It is used to workaround crashes when parsing
anatofuz
parents:
diff changeset
30 /// comments in the stale headers, coming from completion preamble.
anatofuz
parents:
diff changeset
31 std::string getDocComment(const ASTContext &Ctx,
anatofuz
parents:
diff changeset
32 const CodeCompletionResult &Result,
anatofuz
parents:
diff changeset
33 bool CommentsFromHeaders);
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 /// Similar to getDocComment, but returns the comment for a NamedDecl.
anatofuz
parents:
diff changeset
36 std::string getDeclComment(const ASTContext &Ctx, const NamedDecl &D);
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 /// Formats the signature for an item, as a display string and snippet.
anatofuz
parents:
diff changeset
39 /// e.g. for const_reference std::vector<T>::at(size_type) const, this returns:
anatofuz
parents:
diff changeset
40 /// *Signature = "(size_type) const"
anatofuz
parents:
diff changeset
41 /// *Snippet = "(${1:size_type})"
anatofuz
parents:
diff changeset
42 /// If set, RequiredQualifiers is the text that must be typed before the name.
anatofuz
parents:
diff changeset
43 /// e.g "Base::" when calling a base class member function that's hidden.
anatofuz
parents:
diff changeset
44 ///
anatofuz
parents:
diff changeset
45 /// When \p CompletingPattern is true, the last placeholder will be of the form
anatofuz
parents:
diff changeset
46 /// ${0:…}, indicating the cursor should stay there.
anatofuz
parents:
diff changeset
47 void getSignature(const CodeCompletionString &CCS, std::string *Signature,
anatofuz
parents:
diff changeset
48 std::string *Snippet,
anatofuz
parents:
diff changeset
49 std::string *RequiredQualifiers = nullptr,
anatofuz
parents:
diff changeset
50 bool CompletingPattern = false);
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 /// Assembles formatted documentation for a completion result. This includes
anatofuz
parents:
diff changeset
53 /// documentation comments and other relevant information like annotations.
anatofuz
parents:
diff changeset
54 ///
anatofuz
parents:
diff changeset
55 /// \param DocComment is a documentation comment for the original declaration,
anatofuz
parents:
diff changeset
56 /// it should be obtained via getDocComment or getParameterDocComment.
anatofuz
parents:
diff changeset
57 std::string formatDocumentation(const CodeCompletionString &CCS,
anatofuz
parents:
diff changeset
58 llvm::StringRef DocComment);
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 /// Gets detail to be used as the detail field in an LSP completion item. This
anatofuz
parents:
diff changeset
61 /// is usually the return type of a function.
anatofuz
parents:
diff changeset
62 std::string getReturnType(const CodeCompletionString &CCS);
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 } // namespace clangd
anatofuz
parents:
diff changeset
65 } // namespace clang
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETIONSTRINGS_H