Index.h revision ef0cef6cec8de5fc60e469a93436eed7212e0dc2
1d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ 2d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 3d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* The LLVM Compiler Infrastructure *| 4d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 5d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* This file is distributed under the University of Illinois Open Source *| 6d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* License. See LICENSE.TXT for details. *| 7d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 8d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*===----------------------------------------------------------------------===*| 9d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 10d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* This header provides a public inferface to a Clang library for extracting *| 11d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* high-level symbol information from source files without exposing the full *| 12d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* Clang C++ API. *| 13d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 14d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek\*===----------------------------------------------------------------------===*/ 15d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 16d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifndef CLANG_C_INDEX_H 17d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#define CLANG_C_INDEX_H 18d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 1988145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff#include <sys/stat.h> 2088145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff 21d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus 22d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenekextern "C" { 23d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 24d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 2588145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff/* MSVC DLL import/export. */ 262e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#ifdef _MSC_VER 272e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #ifdef _CINDEX_LIB_ 282e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE __declspec(dllexport) 292e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #else 302e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE __declspec(dllimport) 312e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #endif 322e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#else 332e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE 342e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#endif 352e06fc877a633abea3b40a64950c7316dac29ca8John Thompson 36600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff/* 37600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff Clang indeX abstractions. The backing store for the following API's will be 38b7cd17cfd2970636af0fe9b491bab1acf0009c2fSteve Naroff clangs AST file (currently based on PCH). AST files are created as follows: 39600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 40b7cd17cfd2970636af0fe9b491bab1acf0009c2fSteve Naroff "clang -emit-ast <sourcefile.langsuffix> -o <sourcefile.ast>". 41600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 42600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff Naming Conventions: To avoid namespace pollution, data types are prefixed 43600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff with "CX" and functions are prefixed with "clang_". 44600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff*/ 4550398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Narofftypedef void *CXIndex; /* An indexing instance. */ 46600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 4750398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Narofftypedef void *CXTranslationUnit; /* A translation unit instance. */ 48600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 4988145034694ed5267fa6fa5febc54fadc02bd479Steve Narofftypedef void *CXFile; /* A source file */ 5089922f86f4e7da383af2a62ef04ad8b93b941220Steve Narofftypedef void *CXDecl; /* A specific declaration within a translation unit. */ 51fb5704295c6137685a7b90b92cd6b958028740c8Steve Narofftypedef void *CXStmt; /* A specific statement within a function/method */ 52600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 53c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff/* Cursors represent declarations, definitions, and references. */ 5489922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroffenum CXCursorKind { 5589922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff /* Declarations */ 5689922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff CXCursor_FirstDecl = 1, 57c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_TypedefDecl = 2, 58c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_StructDecl = 3, 59c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_UnionDecl = 4, 60c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ClassDecl = 5, 61c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_EnumDecl = 6, 62c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_FieldDecl = 7, 63c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_EnumConstantDecl = 8, 64c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_FunctionDecl = 9, 65c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_VarDecl = 10, 66c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ParmDecl = 11, 67c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCInterfaceDecl = 12, 68c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCCategoryDecl = 13, 69c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCProtocolDecl = 14, 70c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCPropertyDecl = 15, 71c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCIvarDecl = 16, 72c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCInstanceMethodDecl = 17, 73c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCClassMethodDecl = 18, 74c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_LastDecl = 18, 7589922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff 76c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff /* Definitions */ 77c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_FirstDefn = 32, 78c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_FunctionDefn = 32, 79c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCClassDefn = 33, 80c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCCategoryDefn = 34, 81c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCInstanceMethodDefn = 35, 82c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_ObjCClassMethodDefn = 36, 83c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff CXCursor_LastDefn = 36, 84c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Naroff 8589922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff /* References */ 86fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_FirstRef = 40, /* Decl references */ 87f334b4e3eda5a39f041fe13f805dbb53535daa2fSteve Naroff CXCursor_ObjCSuperClassRef = 40, 88f334b4e3eda5a39f041fe13f805dbb53535daa2fSteve Naroff CXCursor_ObjCProtocolRef = 41, 89fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_ObjCClassRef = 42, 90fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff 91fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_ObjCSelectorRef = 43, /* Expression references */ 92fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_ObjCIvarRef = 44, 93fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_VarRef = 45, 94fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_FunctionRef = 46, 95fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_EnumConstantRef = 47, 96fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_MemberRef = 48, 97fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXCursor_LastRef = 48, 9877128ddd3077fc045751a55bb3226802b15d5510Steve Naroff 9977128ddd3077fc045751a55bb3226802b15d5510Steve Naroff /* Error conditions */ 10077128ddd3077fc045751a55bb3226802b15d5510Steve Naroff CXCursor_FirstInvalid = 70, 10177128ddd3077fc045751a55bb3226802b15d5510Steve Naroff CXCursor_InvalidFile = 70, 10277128ddd3077fc045751a55bb3226802b15d5510Steve Naroff CXCursor_NoDeclFound = 71, 10377128ddd3077fc045751a55bb3226802b15d5510Steve Naroff CXCursor_NotImplemented = 72, 10477128ddd3077fc045751a55bb3226802b15d5510Steve Naroff CXCursor_LastInvalid = 72 105600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff}; 106600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 10789922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff/* A cursor into the CXTranslationUnit. */ 108fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff 10989922f86f4e7da383af2a62ef04ad8b93b941220Steve Narofftypedef struct { 11089922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff enum CXCursorKind kind; 11189922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff CXDecl decl; 112fb5704295c6137685a7b90b92cd6b958028740c8Steve Naroff CXStmt stmt; /* expression reference */ 11389922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff} CXCursor; 114600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 11550398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff/* A unique token for looking up "visible" CXDecls from a CXTranslationUnit. */ 116e56b4baeba5097852e04bc41ca2e0396cf729955Steve Narofftypedef void *CXEntity; 117600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 118ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff/** 119ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff * For functions returning a string that might or might not need 120ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff * to be internally allocated and freed. 121ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff * Use clang_getCString to access the C string value. 122ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff * Use clang_disposeString to free the value. 123ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff * Treat it as an opaque type. 124ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff */ 125ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Narofftypedef struct { 126ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff const char *Spelling; 127ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff /* A 1 value indicates the clang_ indexing API needed to allocate the string 128ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff (and it must be freed by clang_disposeString()). */ 129ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff int MustFreeString; 130ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff} CXString; 131ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 132ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff/* Get C string pointer from a CXString. */ 133ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE const char *clang_getCString(CXString string); 134ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 135ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff/* Free CXString. */ 136ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE void clang_disposeString(CXString string); 137ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 138e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff/** 139e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief clang_createIndex() provides a shared context for creating 140e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * translation units. It provides two options: 141e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 142e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" 143e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * declarations (when loading any new translation units). A "local" declaration 144e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * is one that belongs in the translation unit itself and not in a precompiled 145e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * header that was used by the translation unit. If zero, all declarations 146e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * will be enumerated. 147e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 148e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * - displayDiagnostics: when non-zero, diagnostics will be output. If zero, 149e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * diagnostics will be ignored. 150b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 151b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * Here is an example: 152b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 153b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // excludeDeclsFromPCH = 1, displayDiagnostics = 1 154b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * Idx = clang_createIndex(1, 1); 155b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 156b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // IndexTest.pch was produced with the following command: 157b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" 158b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); 159b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 160b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // This will load all the symbols from 'IndexTest.pch' 161b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_loadTranslationUnit(TU, TranslationUnitVisitor, 0); 162b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_disposeTranslationUnit(TU); 163b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 164b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // This will load all the symbols from 'IndexTest.c', excluding symbols 165b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // from 'IndexTest.pch'. 166b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch", 0 }; 167b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args); 168b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_loadTranslationUnit(TU, TranslationUnitVisitor, 0); 169b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_disposeTranslationUnit(TU); 170b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 171b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * This process of creating the 'pch', loading it separately, and using it (via 172b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks 173b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * (which gives the indexer the same performance benefit as the compiler). 174e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff */ 1752e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, 176e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff int displayDiagnostics); 1772e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE void clang_disposeIndex(CXIndex); 178ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); 179af08ddc8f1c53fed8d8d0ad82aa2a0bb7d654bd1Steve Naroff 180e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff/* 181e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief Create a translation unit from an AST file (-emit-ast). 182e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff */ 1832e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit( 184e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff CXIndex, const char *ast_filename 185600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff); 1861374598619f83e6b2de91341a326eae564ece2cbTed Kremenek/** 1871374598619f83e6b2de91341a326eae564ece2cbTed Kremenek * \brief Destroy the specified CXTranslationUnit object. 1881374598619f83e6b2de91341a326eae564ece2cbTed Kremenek */ 1892e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); 1901374598619f83e6b2de91341a326eae564ece2cbTed Kremenek 1911374598619f83e6b2de91341a326eae564ece2cbTed Kremenek/** 192e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief Return the CXTranslationUnit for a given source file and the provided 193e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * command line arguments one would pass to the compiler. 194e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 195139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * Note: The 'source_filename' argument is optional. If the caller provides a NULL pointer, 196139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * the name of the source file is expected to reside in the specified command line arguments. 197139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * 198139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * Note: When encountered in 'clang_command_line_args', the following options are ignored: 199139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * 200139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * '-c' 201139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * '-emit-ast' 202139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * '-fsyntax-only' 203139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * '-o <output file>' (both '-o' and '<output file>' are ignored) 204139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek * 2051374598619f83e6b2de91341a326eae564ece2cbTed Kremenek */ 2062e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( 2075b7d8e254f6c2855b37b5521c0aee0a560dab237Steve Naroff CXIndex CIdx, 208139ba86a362593da2e350f881e5c7003917aa5a7Ted Kremenek const char *source_filename /* specify NULL if the source file is in clang_command_line_args */, 2095b7d8e254f6c2855b37b5521c0aee0a560dab237Steve Naroff int num_clang_command_line_args, 210e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff const char **clang_command_line_args 2115b7d8e254f6c2855b37b5521c0aee0a560dab237Steve Naroff); 212600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 213600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff/* 214600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff Usage: clang_loadTranslationUnit(). Will load the toplevel declarations 215600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff within a translation unit, issuing a 'callback' for each one. 216600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 217600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff void printObjCInterfaceNames(CXTranslationUnit X, CXCursor C) { 218600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff if (clang_getCursorKind(C) == Cursor_Declaration) { 219600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff CXDecl D = clang_getCursorDecl(C); 220600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff if (clang_getDeclKind(D) == CXDecl_ObjC_interface) 221600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff printf("@interface %s in file %s on line %d column %d\n", 222600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff clang_getDeclSpelling(D), clang_getCursorSource(C), 223600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff clang_getCursorLine(C), clang_getCursorColumn(C)); 224600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 225600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 226600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff static void usage { 227600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff clang_loadTranslationUnit(CXTranslationUnit, printObjCInterfaceNames); 228600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 229600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff*/ 2302b8ee6c2994f738e5162ff46b638974870f51662Steve Narofftypedef void *CXClientData; 2312b8ee6c2994f738e5162ff46b638974870f51662Steve Narofftypedef void (*CXTranslationUnitIterator)(CXTranslationUnit, CXCursor, 2322b8ee6c2994f738e5162ff46b638974870f51662Steve Naroff CXClientData); 2332e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE void clang_loadTranslationUnit(CXTranslationUnit, CXTranslationUnitIterator, 2342b8ee6c2994f738e5162ff46b638974870f51662Steve Naroff CXClientData); 235600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 236600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff/* 237600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff Usage: clang_loadDeclaration(). Will load the declaration, issuing a 238600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 'callback' for each declaration/reference within the respective declaration. 239600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 240600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff For interface declarations, this will index the super class, protocols, 241600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff ivars, methods, etc. For structure declarations, this will index the fields. 242600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff For functions, this will index the parameters (and body, for function 243600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff definitions), local declarations/references. 244600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 245600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff void getInterfaceDetails(CXDecl X, CXCursor C) { 246600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff switch (clang_getCursorKind(C)) { 247600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff case Cursor_ObjC_ClassRef: 248600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff CXDecl SuperClass = clang_getCursorDecl(C); 249600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff case Cursor_ObjC_ProtocolRef: 250600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff CXDecl AdoptsProtocol = clang_getCursorDecl(C); 251600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff case Cursor_Declaration: 252600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff CXDecl AnIvarOrMethod = clang_getCursorDecl(C); 253600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 254600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 255600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff static void usage() { 256600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff if (clang_getDeclKind(D) == CXDecl_ObjC_interface) { 257600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff clang_loadDeclaration(D, getInterfaceDetails); 258600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 259600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff } 260600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff*/ 261c857ea4d22e1e6dd9ede1f0e84d48b157c6924fdSteve Narofftypedef void (*CXDeclIterator)(CXDecl, CXCursor, CXClientData); 26289922f86f4e7da383af2a62ef04ad8b93b941220Steve Naroff 2632e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE void clang_loadDeclaration(CXDecl, CXDeclIterator, CXClientData); 264600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 26550398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff/* 26688145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff * CXFile Operations. 26788145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff */ 26808b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE const char *clang_getFileName(CXFile SFile); 26908b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); 27088145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff 27188145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff/* 27250398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff * CXEntity Operations. 27350398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */ 2742e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE const char *clang_getDeclarationName(CXEntity); 2752e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE const char *clang_getURI(CXEntity); 2762e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXEntity clang_getEntity(const char *URI); 27750398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff/* 27850398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff * CXDecl Operations. 27950398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */ 2802e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXCursor clang_getCursorFromDecl(CXDecl); 2812e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXEntity clang_getEntityFromDecl(CXDecl); 282ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE CXString clang_getDeclSpelling(CXDecl); 2832e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_getDeclLine(CXDecl); 2842e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_getDeclColumn(CXDecl); 28588145034694ed5267fa6fa5febc54fadc02bd479Steve NaroffCINDEX_LINKAGE const char *clang_getDeclSource(CXDecl); /* deprecate */ 28688145034694ed5267fa6fa5febc54fadc02bd479Steve NaroffCINDEX_LINKAGE CXFile clang_getDeclSourceFile(CXDecl); 287699a07d8a0b1579c5178b3baf4bcf9edb6b38108Steve Naroff 28850398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff/* 28950398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff * CXCursor Operations. 29050398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */ 2916a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff/** 2926a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff Usage: clang_getCursor() will translate a source/line/column position 2936a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff into an AST cursor (to derive semantic information from the source code). 2946a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff */ 2952e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, const char *source_name, 296fbcb2b716bee88c754684bd189913ed9f8c09086Ted Kremenek unsigned line, unsigned column); 297fbcb2b716bee88c754684bd189913ed9f8c09086Ted Kremenek 2982e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); 2992e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); 3002e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); 3012e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_isDefinition(enum CXCursorKind); 3022e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); 303600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 3042e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_getCursorLine(CXCursor); 3052e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE unsigned clang_getCursorColumn(CXCursor); 306ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); 30788145034694ed5267fa6fa5febc54fadc02bd479Steve NaroffCINDEX_LINKAGE const char *clang_getCursorSource(CXCursor); /* deprecate */ 30888145034694ed5267fa6fa5febc54fadc02bd479Steve NaroffCINDEX_LINKAGE CXFile clang_getCursorSourceFile(CXCursor); 309f334b4e3eda5a39f041fe13f805dbb53535daa2fSteve Naroff 3104ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff/* for debug/testing */ 3112e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE const char *clang_getCursorKindSpelling(enum CXCursorKind Kind); 3122e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, 3134ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff const char **startBuf, 3144ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff const char **endBuf, 3154ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *startLine, 3164ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *startColumn, 3174ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *endLine, 3184ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *endColumn); 319600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 32050398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff/* 321459789b8d2e3235e2f3342c393b7a78bd73c1347Chris Lattner * If CXCursorKind == Cursor_Reference, then this will return the referenced 322459789b8d2e3235e2f3342c393b7a78bd73c1347Chris Lattner * declaration. 32350398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff * If CXCursorKind == Cursor_Declaration, then this will return the declaration. 32450398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */ 3252e06fc877a633abea3b40a64950c7316dac29ca8John ThompsonCINDEX_LINKAGE CXDecl clang_getCursorDecl(CXCursor); 326d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 3270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 3280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A semantic string that describes a code-completion result. 3290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A semantic string that describes the formatting of a code-completion 3310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * result as a single "template" of text that should be inserted into the 3320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * source buffer when a particular code-completion result is selected. 3330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Each semantic string is made up of some number of "chunks", each of which 3340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * contains some text along with a description of what that text means, e.g., 3350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the name of the entity being referenced, whether the text chunk is part of 3360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the template, or whether it is a "placeholder" that the user should replace 3370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * with actual code,of a specific kind. See \c CXCompletionChunkKind for a 3380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * description of the different kinds of chunks. 3390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 3400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef void *CXCompletionString; 3410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 3420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 3430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A single result of code completion. 3440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 3450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef struct { 3460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 3470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief The kind of entity that this completion refers to. 3480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The cursor kind will be a macro, keyword, or a declaration (one of the 3500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * *Decl cursor kinds), describing the entity that the completion is 3510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * referring to. 3520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \todo In the future, we would like to provide a full cursor, to allow 3540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the client to extract additional information from declaration. 3550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 3560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor enum CXCursorKind CursorKind; 3570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 3580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 3590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief The code-completion string that describes how to insert this 3600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion result into the editing buffer. 3610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 3620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionString CompletionString; 3630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor} CXCompletionResult; 3640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 3650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 3660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Describes a single piece of text within a code-completion string. 3670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Each "chunk" within a code-completion string (\c CXCompletionString) is 3690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * either a piece of text with a specific "kind" that describes how that text 3700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be interpreted by the client or is another completion string. 3710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 3720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorenum CXCompletionChunkKind { 3730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 3740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A code-completion string that describes "optional" text that 3750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * could be a part of the template (but is not required). 3760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The Optional chunk is the only kind of chunk that has a code-completion 3780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * string for its representation, which is accessible via 3790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c clang_getCompletionChunkCompletionString(). The code-completion string 3800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * describes an additional part of the template that is completely optional. 3810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * For example, optional chunks can be used to describe the placeholders for 3820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * arguments that match up with defaulted function parameters, e.g. given: 3830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \code 3850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * void f(int x, float y = 3.14, double z = 2.71828); 3860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \endcode 3870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 3880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The code-completion string for this function would contain: 3890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a TypedText chunk for "f". 3900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a LeftParen chunk for "(". 3910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "int x" 3920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - an Optional chunk containing the remaining defaulted arguments, e.g., 3930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Comma chunk for "," 3940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "float x" 3950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - an Optional chunk containing the last defaulted argument: 3960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Comma chunk for "," 3970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "double z" 3980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a RightParen chunk for ")" 3990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * There are many ways two handle Optional chunks. Two simple approaches are: 4010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - Completely ignore optional chunks, in which case the template for the 4020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * function "f" would only include the first parameter ("int x"). 4030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - Fully expand all optional chunks, in which case the template for the 4040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * function "f" would have all of the parameters. 4050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Optional, 4070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that a user would be expected to type to get this 4090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion result. 4100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * There will be exactly one "typed text" chunk in a semantic string, which 4120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * will typically provide the spelling of a keyword or the name of a 4130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * declaration that could be used at the current code point. Clients are 4140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * expected to filter the code-completion results based on the text in this 4150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * chunk. 4160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_TypedText, 4180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that should be inserted as part of a code-completion result. 4200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "text" chunk represents text that is part of the template to be 4220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * inserted into user code should this particular code-completion result 4230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * be selected. 4240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Text, 4260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Placeholder text that should be replaced by the user. 4280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "placeholder" chunk marks a place where the user should insert text 4300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * into the code-completion template. For example, placeholders might mark 4310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the function parameters for a function declaration, to indicate that the 4320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * user should provide arguments for each of those parameters. The actual 4330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * text in a placeholder is a suggestion for the text to display before 4340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the user replaces the placeholder with real code. 4350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Placeholder, 4370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Informative text that should be displayed but never inserted as 4390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * part of the template. 4400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * An "informative" chunk contains annotations that can be displayed to 4420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * help the user decide whether a particular code-completion result is the 4430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * right option, but which is not part of the actual template to be inserted 4440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * by code completion. 4450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Informative, 4470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that describes the current parameter when code-completion is 4490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * referring to function call, message send, or template specialization. 4500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "current parameter" chunk occurs when code-completion is providing 4520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * information about a parameter corresponding to the argument at the 4530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion point. For example, given a function 4540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \code 4560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * int add(int x, int y); 4570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \endcode 4580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 4590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * and the source code \c add(, where the code-completion point is after the 4600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "(", the code-completion string will contain a "current parameter" chunk 4610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * for "int x", indicating that the current argument will initialize that 4620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * parameter. After typing further, to \c add(17, (where the code-completion 4630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * point is after the ","), the code-completion string will contain a 4640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "current paremeter" chunk to "int y". 4650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_CurrentParameter, 4670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left parenthesis ('('), used to initiate a function call or 4690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * signal the beginning of a function parameter list. 4700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftParen, 4720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right parenthesis (')'), used to finish a function call or 4740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * signal the end of a function parameter list. 4750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightParen, 4770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left bracket ('['). 4790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftBracket, 4810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right bracket (']'). 4830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightBracket, 4850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left brace ('{'). 4870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftBrace, 4890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right brace ('}'). 4910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightBrace, 4930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left angle bracket ('<'). 4950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 4960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftAngle, 4970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 4980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right angle bracket ('>'). 4990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightAngle, 5010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 5020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A comma separator (','). 5030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Comma 5050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor}; 5060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 5070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 5080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Callback function that receives a single code-completion result. 5090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * This callback will be invoked by \c clang_codeComplete() for each 5110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion result. 5120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_result a pointer to the current code-completion result, 5140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * providing one possible completion. The pointer itself is only valid 5150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * during the execution of the completion callback. 5160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param client_data the client data provided to \c clang_codeComplete(). 5180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef void (*CXCompletionIterator)(CXCompletionResult *completion_result, 5200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXClientData client_data); 5210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 5220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 5230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Determine the kind of a particular chunk within a completion string. 5240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 5260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 5280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the kind of the chunk at the index \c chunk_number. 5300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE enum CXCompletionChunkKind 5320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkKind(CXCompletionString completion_string, 5330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 5340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 5350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 5360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the text associated with a particular chunk within a 5370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion string. 5380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 5400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 5420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the text associated with the chunk at index \c chunk_number. 5440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE const char * 5460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkText(CXCompletionString completion_string, 5470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 5480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 5490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 5500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the completion string associated with a particular chunk 5510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * within a completion string. 5520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 5540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 5560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the completion string associated with the chunk at index 5580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c chunk_number, or NULL if that chunk is not represented by a completion 5590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * string. 5600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE CXCompletionString 5620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkCompletionString(CXCompletionString completion_string, 5630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 5640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 5650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 5660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the number of chunks in the given code-completion string. 5670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 5680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE unsigned 5690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getNumCompletionChunks(CXCompletionString completion_string); 5700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 5710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 5720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Perform code completion at a given location in a source file. 5730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * This function performs code completion at a particular file, line, and 5750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * column within source code, providing results that suggest potential 5760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code snippets based on the context of the completion. The basic model 5770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * for code completion is that Clang will parse a complete source file, 5780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * performing syntax checking up to the location where code-completion has 5790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * been requested. At that point, a special code-completion token is passed 5800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * to the parser, which recognizes this token and determines, based on the 5810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * current location in the C/Objective-C/C++ grammar and the state of 5820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * semantic analysis, what completions to provide. These completions are 5830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * enumerated through a callback interface to the client. 5840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 5850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Code completion itself is meant to be triggered by the client when the 5860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * user types punctuation characters or whitespace, at which point the 5870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion location will coincide with the cursor. For example, if \c p 5880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * is a pointer, code-completion might be triggered after the "-" and then 5890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * after the ">" in \c p->. When the code-completion location is afer the ">", 5900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the completion results will provide, e.g., the members of the struct that 5910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "p" points to. The client is responsible for placing the cursor at the 5920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * beginning of the token currently being typed, then filtering the results 5930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * based on the contents of the token. For example, when code-completing for 5940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the expression \c p->get, the client should provide the location just after 5950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the 5960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * client can filter the results based on the current token text ("get"), only 5970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * showing those results that start with "get". The intent of this interface 5980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * is to separate the relatively high-latency acquisition of code-competion 5990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * results from the filtering of results on a per-character basis, which must 6000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * have a lower latency. 6010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param CIdx the \c CXIndex instance that will be used to perform code 6030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion. 6040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param source_filename the name of the source file that should be parsed 6060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * to perform code-completion. This source file must be the same as or 6070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * include the filename described by \p complete_filename, or no code-completion 6080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * results will be produced. 6090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param num_command_line_args the number of command-line arguments stored in 6110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \p command_line_args. 6120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param command_line_args the command-line arguments to pass to the Clang 6140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * compiler to build the given source file. This should include all of the 6150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * necessary include paths, language-dialect switches, precompiled header 6160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * includes, etc., but should not include any information specific to 6170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code completion. 6180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_filename the name of the source file where code completion 6200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be performed. In many cases, this name will be the same as the 6210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * source filename. However, the completion filename may also be a file 6220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * included by the source file, which is required when producing 6230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion results for a header. 6240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_line the line at which code-completion should occur. 6260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_column the column at which code-completion should occur. 6280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Note that the column should point just after the syntactic construct that 6290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * initiated code completion, and not in the middle of a lexical token. 6300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_iterator a callback function that will receive 6320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion results. 6330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 6340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param client_data client-specific data that will be passed back via the 6350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion callback function. 6360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 6370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE void clang_codeComplete(CXIndex CIdx, 6380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor const char *source_filename, 6390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor int num_command_line_args, 6400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor const char **command_line_args, 6410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor const char *complete_filename, 6420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned complete_line, 6430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned complete_column, 6440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionIterator completion_iterator, 6450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXClientData client_data); 6460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 6470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 648d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus 649d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek} 650d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 651d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 652d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 653