1/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- 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|* This header provides a public inferface to a Clang library for extracting *| 11|* high-level symbol information from source files without exposing the full *| 12|* Clang C++ API. *| 13|* *| 14\*===----------------------------------------------------------------------===*/ 15 16#ifndef CLANG_C_INDEX_H 17#define CLANG_C_INDEX_H 18 19#include <sys/stat.h> |
20#include <time.h> |
21 22#ifdef __cplusplus 23extern "C" { 24#endif 25 26/* MSVC DLL import/export. */ 27#ifdef _MSC_VER 28 #ifdef _CINDEX_LIB_ --- 522 unchanged lines hidden (view full) --- 551 CXCompletionChunk_LeftAngle, 552 /** 553 * \brief A right angle bracket ('>'). 554 */ 555 CXCompletionChunk_RightAngle, 556 /** 557 * \brief A comma separator (','). 558 */ |
559 CXCompletionChunk_Comma, 560 /** 561 * \brief Text that specifies the result type of a given result. 562 * 563 * This special kind of informative chunk is not meant to be inserted into 564 * the text buffer. Rather, it is meant to illustrate the type that an 565 * expression using the given completion string would have. 566 */ 567 CXCompletionChunk_ResultType |
568}; |
569 570/** 571 * \brief Determine the kind of a particular chunk within a completion string. 572 * 573 * \param completion_string the completion string to query. 574 * 575 * \param chunk_number the 0-based index of the chunk in the completion string. 576 * --- 35 unchanged lines hidden (view full) --- 612 613/** 614 * \brief Retrieve the number of chunks in the given code-completion string. 615 */ 616CINDEX_LINKAGE unsigned 617clang_getNumCompletionChunks(CXCompletionString completion_string); 618 619/** |
620 * \brief Contains the results of code-completion. 621 * 622 * This data structure contains the results of code completion, as 623 * produced by \c clang_codeComplete. Its contents must be freed by 624 * \c clang_disposeCodeCompleteResults. 625 */ 626typedef struct { 627 /** 628 * \brief The code-completion results. 629 */ 630 CXCompletionResult *Results; 631 632 /** 633 * \brief The number of code-completion results stored in the 634 * \c Results array. 635 */ 636 unsigned NumResults; 637} CXCodeCompleteResults; 638 639/** |
640 * \brief Perform code completion at a given location in a source file. 641 * 642 * This function performs code completion at a particular file, line, and 643 * column within source code, providing results that suggest potential 644 * code snippets based on the context of the completion. The basic model 645 * for code completion is that Clang will parse a complete source file, 646 * performing syntax checking up to the location where code-completion has 647 * been requested. At that point, a special code-completion token is passed 648 * to the parser, which recognizes this token and determines, based on the 649 * current location in the C/Objective-C/C++ grammar and the state of 650 * semantic analysis, what completions to provide. These completions are |
651 * returned via a new \c CXCodeCompleteResults structure. |
652 * 653 * Code completion itself is meant to be triggered by the client when the 654 * user types punctuation characters or whitespace, at which point the 655 * code-completion location will coincide with the cursor. For example, if \c p 656 * is a pointer, code-completion might be triggered after the "-" and then 657 * after the ">" in \c p->. When the code-completion location is afer the ">", 658 * the completion results will provide, e.g., the members of the struct that 659 * "p" points to. The client is responsible for placing the cursor at the 660 * beginning of the token currently being typed, then filtering the results 661 * based on the contents of the token. For example, when code-completing for 662 * the expression \c p->get, the client should provide the location just after 663 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the 664 * client can filter the results based on the current token text ("get"), only 665 * showing those results that start with "get". The intent of this interface |
666 * is to separate the relatively high-latency acquisition of code-completion |
667 * results from the filtering of results on a per-character basis, which must 668 * have a lower latency. 669 * 670 * \param CIdx the \c CXIndex instance that will be used to perform code 671 * completion. 672 * 673 * \param source_filename the name of the source file that should be parsed to 674 * perform code-completion. This source file must be the same as or include the --- 24 unchanged lines hidden (view full) --- 699 * code-completion results for a header. 700 * 701 * \param complete_line the line at which code-completion should occur. 702 * 703 * \param complete_column the column at which code-completion should occur. 704 * Note that the column should point just after the syntactic construct that 705 * initiated code completion, and not in the middle of a lexical token. 706 * |
707 * \returns if successful, a new CXCodeCompleteResults structure 708 * containing code-completion results, which should eventually be 709 * freed with \c clang_disposeCodeCompleteResults(). If code 710 * completion fails, returns NULL. |
711 */ |
712CINDEX_LINKAGE 713CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx, 714 const char *source_filename, 715 int num_command_line_args, 716 const char **command_line_args, 717 unsigned num_unsaved_files, 718 struct CXUnsavedFile *unsaved_files, 719 const char *complete_filename, 720 unsigned complete_line, 721 unsigned complete_column); |
722 |
723/** 724 * \brief Free the given set of code-completion results. 725 */ 726CINDEX_LINKAGE 727void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); 728 |
729#ifdef __cplusplus 730} 731#endif 732#endif 733 |