summaryrefslogtreecommitdiffstats
path: root/lib/Sema/CodeCompleteConsumer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Synchronize code-completion cursor kinds with indexing cursorDouglas Gregor2010-09-031-87/+5
| | | | | | | kinds. How shameful that this code was duplicated! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113033 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify code-completion result sorting a bitDouglas Gregor2010-09-031-8/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112968 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename DeclContext::getLookupContext to getRedeclContext and change its ↵Sebastian Redl2010-08-311-1/+1
| | | | | | semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112563 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-261-1/+8
| | | | | | | | | | | | into the clients, e.g., the printing code-completion consumer and c-index-test. Clients may want to re-sort the results anyway. Provide a libclang function that sorts the results. 3rd try. How embarrassing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112180 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r112149, "Move the sorting of code-completion results out of the mainDaniel Dunbar2010-08-261-8/+1
| | | | | | path and ...", it is failing tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112161 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-261-1/+8
| | | | | | | | | | into the clients, e.g., the printing code-completion consumer and c-index-test. Clients may want to re-sort the results anyway. Provide a libclang function that sorts the results. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112149 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-261-8/+1
| | | | | | | | into the clients", because the C standard library sucks. Where's my stable sort, huh? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112121 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-251-1/+8
| | | | | | | | into the clients, e.g., the printing code-completion consumer and c-index-test. Clients may want to re-sort the results anyway. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112095 91177308-0d34-0410-b5e6-96231b3b80d8
* When combining the code-completion results from Sema long with theDouglas Gregor2010-08-251-0/+56
| | | | | | | | | code-completion results cached by ASTUnit, sort the resulting result set. This makes testing far, far easier, so this commit also includes tests for the previous few fixes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112070 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach Sema to live without CodeCompleteConsumer.h.John McCall2010-08-251-12/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112028 91177308-0d34-0410-b5e6-96231b3b80d8
* Move more stuff out of Sema.h.John McCall2010-08-251-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112026 91177308-0d34-0410-b5e6-96231b3b80d8
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111904 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce new libclang API functions that determine the availabilityDouglas Gregor2010-08-231-1/+14
| | | | | | | | | of a cursor or code-completion result, e.g., whether that result refers to an unavailable, deleted, or deprecated declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111858 91177308-0d34-0410-b5e6-96231b3b80d8
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-1/+1
| | | | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111667 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement caching of code-completion results for macro definitionsDouglas Gregor2010-08-131-75/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when the CXTranslationUnit_CacheCompletionResults option is given to clang_parseTranslationUnit(). Essentially, we compute code-completion results for macro definitions after we have parsed the file, then store an ASTContext-agnostic version of those results (completion string, cursor kind, priority, and active contexts) in the ASTUnit. When performing code completion in that ASTUnit, we splice the macro definition results into the results provided by the actual code-completion (which has had macros turned off) before libclang gets those results. We use completion context information to only splice in those results that make sense for that context. With a completion involving all of the macros from Cocoa.h and a few other system libraries (totally ~8500 macro definitions) living in a precompiled header, we get about a 9% performance improvement from code completion, since we no longer have to deserialize all of the macro definitions from the precompiled header. Note that macro definitions are merely the canary; the cache is designed to also support other top-level declarations, which should be a bigger performance win. That optimization will be next. Note also that there is no mechanism for determining when to throw away the cache and recompute its contents. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111051 91177308-0d34-0410-b5e6-96231b3b80d8
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110945 91177308-0d34-0410-b5e6-96231b3b80d8
* Once code completion has completed, pass a "completion context" on toDouglas Gregor2010-08-111-0/+2
| | | | | | | | the code-completion consumer. The consumer can use this information to augument, filter, or display the code-completion results. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110858 91177308-0d34-0410-b5e6-96231b3b80d8
* Add code-completion support directly to ASTUnit, which performs codeDouglas Gregor2010-08-041-54/+46
| | | | | | | | | | | | | | | | completion within the translation unit using the same command-line arguments for parsing the translation unit. Eventually, we'll reuse the precompiled preamble to improve code-completion performance, and this also gives us a place to cache results. Expose this function via the new libclang function clang_codeCompleteAt(), which performs the code completion within a CXTranslationUnit. The completion occurs in-process (clang_codeCompletion() runs code completion out-of-process). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110210 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code simplification.Dan Gohman2010-07-261-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109443 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce priorities into the code-completion results.Douglas Gregor2010-05-261-13/+34
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104751 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve code completion in failure cases in two ways:Douglas Gregor2010-05-251-20/+0
| | | | | | | | | | | | | | | 1) Suppress diagnostics as soon as we form the code-completion token, so we don't get any error/warning spew from the early end-of-file. 2) If we consume a code-completion token when we weren't expecting one, go into a code-completion recovery path that produces the best results it can based on the context that the parser is in. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104585 91177308-0d34-0410-b5e6-96231b3b80d8
* Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer2010-04-171-1/+1
| | | | | | | | | users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101632 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement code completion for Objective-C method declarations andDouglas Gregor2010-04-071-1/+1
| | | | | | | | | | | | | | | | | | definitions, e.g., after - or - (id) we'll find all of the "likely" instance methods that one would want to declare or define at this point. In the latter case, we only produce results whose return types match "id". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100587 91177308-0d34-0410-b5e6-96231b3b80d8
* Code completion results that refer to macros now get the cursor kindDouglas Gregor2010-04-051-2/+5
| | | | | | | | of macro definitions when passed to CIndex. Add test for code completion of macros via CIndex. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100431 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused headers.Duncan Sands2010-03-081-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97941 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate cursor kinds used to express definitions. Instead, provideDouglas Gregor2010-01-191-2/+2
| | | | | | | | | | | | | | CIndex functions that (1) map from a reference or declaration to the corresponding definition, if available, and (2) determine whether a given declaration cursor is also a definition. This eliminates a lot of duplication in the cursor kinds, and maps more closely to the Clang ASTs. This is another API + ABI breaker with no deprecation. Yay, progress. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93893 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve the sorting of code-completion results. We now always sort byDouglas Gregor2010-01-131-6/+5
| | | | | | | | | | the "typed" text, first, then take into account nested-name-specifiers, name hiding, etc. This means that the resulting sort is actually alphabetical :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93370 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve code completion by introducing patterns for the various C andDouglas Gregor2010-01-101-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | C++ grammatical constructs that show up in top-level (namespace-level) declarations, member declarations, template declarations, statements, expressions, conditions, etc. For example, we now provide a pattern for static_cast<type>(expr) when we can have an expression, or using namespace identifier; when we can have a using directive. Also, improves the results of code completion at the beginning of a top-level declaration. Previously, we would see value names (function names, global variables, etc.); now we see types, namespace names, etc., but no values. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
* Extend code-completion results with the type of each resultDouglas Gregor2009-12-181-1/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91702 91177308-0d34-0410-b5e6-96231b3b80d8
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-1/+1
| | | | | | | no extra safety anyway. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91207 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the clang-to-CIndex interface for code-completion to a binary format, ↵Douglas Gregor2009-12-011-319/+172
| | | | | | for a massive speedup git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90209 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90044 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve code-completion results for the flags in an @propertyDouglas Gregor2009-11-191-0/+61
| | | | | | | | | | declaration by providing patterns for "getter = <method>" and "setter = <method>". As part of this, invented a new "pattern" result kind that is merely a semantic string. The "pattern" result kind should help with other kinds of code templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89277 91177308-0d34-0410-b5e6-96231b3b80d8
* StringRef'ify CodeCompletionStringDouglas Gregor2009-11-171-4/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89102 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework Sema code completion interface.Daniel Dunbar2009-11-131-4/+8
| | | | | | | | | | | | | - Provide Sema in callbacks, instead of requiring it in constructor. This eliminates the need for a factory function. Clients now just pass the object to consume the results in directly. - CodeCompleteConsumer is cheap to construct, so building it whenever we are doing code completion is reasonable. Doug, please review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87099 91177308-0d34-0410-b5e6-96231b3b80d8
* Spell empty StringRef correctly (0 is a null StringRef, which is not the same).Daniel Dunbar2009-11-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87011 91177308-0d34-0410-b5e6-96231b3b80d8
* Various improvements to Clang's code-completion infrastructure:Douglas Gregor2009-11-071-8/+465
| | | | | | | | | | | | | | | - Introduce more code-completion string "chunk" kinds that describe symbols, the actual text that the user is expected to type, etc. - Make the generation of macro results optional, since it can be slow - Make code-completion accessible through the C API, marshalling the code-completion results through a temporary file (ick) to maintain process separation. The last doesn't have tests yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86306 91177308-0d34-0410-b5e6-96231b3b80d8
* Include macros in code-completion resultsDouglas Gregor2009-10-301-0/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85594 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor tweaks for code-completion:Douglas Gregor2009-10-091-1/+2
| | | | | | | | | | | | | - Filter out unnamed declarations - Filter out declarations whose names are reserved for the implementation (e.g., __bar, _Foo) - Place OVERLOAD: or COMPLETION: at the beginning of each code-completion result, so we can easily separate them from other compilation results. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83680 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure to flush raw_string_ostream, from John ThompsonDouglas Gregor2009-09-291-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83066 91177308-0d34-0410-b5e6-96231b3b80d8
* Print the results of code-completion for overloading by displaying theDouglas Gregor2009-09-231-20/+4
| | | | | | | | signature of the function with the current parameter highlighted as a placeholder. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82593 91177308-0d34-0410-b5e6-96231b3b80d8
* Separate the code-completion results for call completion from theDouglas Gregor2009-09-231-0/+64
| | | | | | | | | results for other, textual completion. For call completion, we now produce enough information to show the function call argument that we are currently on. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82592 91177308-0d34-0410-b5e6-96231b3b80d8
* Tweak the code-completion results ranking and formation, so thatDouglas Gregor2009-09-221-16/+28
| | | | | | | | | | | | members found in base classes have the same ranking as members found in derived classes. However, we will introduce an informative note for members found in base classes, showing (as a nested-name-specifier) the qualification to name the base class, to make it clear which members are from bases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82586 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor and simplify the CodeCompleteConsumer, so that all of theDouglas Gregor2009-09-211-846/+5
| | | | | | | | real work is performed within Sema. Addresses Chris's comments, but still retains the heavyweight list-of-multimaps data structure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82459 91177308-0d34-0410-b5e6-96231b3b80d8
* In C++ code completion, only suggest the "template" keyword after ".",Douglas Gregor2009-09-181-4/+18
| | | | | | | | "->", or "::" if we will be looking into a dependent context. It's not wrong to use the "template" keyword, but it's to needed, either. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82307 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the construction of the code-completion string for a functionDouglas Gregor2009-09-181-8/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | template smarter, by taking into account which function template parameters are deducible from the call arguments. For example, template<typename RandomAccessIterator> void sort(RandomAccessIterator first, RandomAccessIterator last); will have a code-completion string like sort({RandomAccessIterator first}, {RandomAccessIterator last}) since the template argument for its template parameter is deducible. On the other hand, template<class X, class Y> X* dyn_cast(Y *Val); will have a code-completion string like dyn_cast<{class X}>({Y *Val}) since the template type parameter X is not deducible from the function call. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82306 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce code completion patterns for templates, which provide theDouglas Gregor2009-09-181-0/+88
| | | | | | | angle brackets < > along with placeholder template arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82304 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce code completion strings, which describe how to *use* theDouglas Gregor2009-09-181-2/+131
| | | | | | | | | results of code completion, e.g., by providing function call syntax with placeholders for each of the parameters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82293 91177308-0d34-0410-b5e6-96231b3b80d8
* C++ code completion after the "operator" keyword. Provide overloadedDouglas Gregor2009-09-181-1/+76
| | | | | | | | operators, type specifiers, type names, and nested-name-specifiers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82264 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce four new code-completion hooks for C++:Douglas Gregor2009-09-181-0/+68
| | | | | | | | | | | | - after "using", show anything that can be a nested-name-specifier. - after "using namespace", show any visible namespaces or namespace aliases - after "namespace", show any namespace definitions in the current scope - after "namespace identifier = ", show any visible namespaces or namespace aliases git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82251 91177308-0d34-0410-b5e6-96231b3b80d8