summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/symbolfinder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge CppTools into CppEditorChristian Kandeler2021-09-011-535/+0
| | | | | | | | | | | | | | | | There was no proper separation of responsibilities between these plugins. In particular, CppTools had lots of editor-related functionality, so it's not clear why it was separated out in the first place. In fact, for a lot of code, it seemed quite arbitrary where it was put (just one example: switchHeaderSource() was in CppTools, wheras switchDeclarationDefinition() was in CppEditor). Merging the plugins will enable us to get rid of various convoluted pseudo-abstractions that were only introduced to keep up the artificial separation. Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppTools: Use only const pointers for ProjectInfo and ProjectPartChristian Kandeler2021-08-271-1/+1
| | | | | | | | All members were already const, but this makes it clear at all points of use that these data structures are immutable. Change-Id: Iea615c090bde462c445d15223caccc561b0c713d Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* CppTools: Add missing null pointer checkChristian Kandeler2021-06-031-0/+3
| | | | | | | | | Prevents a crash trying to look for decl/def matches in non-applicable locations. Fixes: QTCREATORBUG-25806 Change-Id: I70961109267a2955bef0434a92f1d913b8c0c9c1 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Support decl/def switch for conversion operatorsChristian Kandeler2020-11-231-9/+17
| | | | | | Fixes: QTCREATORBUG-21168 Change-Id: I515fe146a679e007c96fa8d23f1457dadf07db3c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppTools: More consistent fuzzy matching behaviorChristian Kandeler2020-08-141-67/+52
| | | | | | | | | | | | | | | | | | | | | | | | | There were annoying inconsistencies, for instance: - A not fully matching declaration was found from the definition, but not vice versa. - An implementation MyClass::foo(int) would fall back to a declaration foo(), but an implementation MyClass::foo() would not fall back to a declaration foo(int). These cases behave consistently now. To this end, the clang code model now forwards to the built-in code model if a function lookup has failed. Fuzzy matching for free functions has been limited, as the cons appear to outweigh the pros. For instance: void foo(int); void foo(double) {} Following the definition would lead to the non-matching declaration, which the user most likely does not want. As a side effect, redundant code has been removed in the SymbolFinder class. Fixes: QTCREATORBUG-20279 Change-Id: Ib97d6710c7e12fb0fdbc30b51a0067e09bfc2190 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppTools: Also look up definitions for variablesChristian Kandeler2020-06-181-0/+122
| | | | | | | | | ... not just functions. This includes global variables and static members. Fixes: QTCREATORBUG-18828 Change-Id: Iee9f83a4f955a859c6fc4038c61997b30afdaec8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppTools: modernizeAlessandro Portale2019-01-211-15/+13
| | | | | | Change-Id: Iaf02e4d026f1ac8b216833d83cd7a735e21ff60a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Prefer using 'override' instead of 'virtual'Alessandro Portale2018-07-111-2/+2
| | | | | | | | warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override] Change-Id: I6dac7a62b627fa1353b4455e1af92f869c2571cc Reviewed-by: Marco Benelli <marco.benelli@qt.io>
* Update License according to agreement with Free Qt FoundationTobias Hunger2016-01-191-17/+12
| | | | | | | * Update files in src/plugins Change-Id: Ia5d77fad7d19d4bb3498e78661982f68729adb22 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* C++: Revert lookup to 3.4.2Nikolai Kosjar2015-11-191-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...which was least buggy. The bugs fixed by the changes we revert here (highlighting/completion for code involving templates) were minor compared to ones we currently have. Those bugs will be addressed by the clang code model anyway. Relevant commits were collected via: $ cd ${QTC}/src/libs/cplusplus $ git log \ --no-merges \ --format=oneline \ v3.4.2..HEAD \ -- LookupContext.* ResolveExpression.* TypeResolver.* TypeOfExpression.* \ ../../plugins/cpptools/cppcompletion_test.cpp From this list the following were skipped due to irrelevance: 88c5b47e535d91f3db99882d5b50b263b46f223c # CppTools: Minor cleanup in completion tests e5255a1f5cac284c4f0d4a85203878c84da86e85 # CppTools: Add a test for ObjC not replacing dot with arrow 5b12c8d63a30e281274cdc267efabead2c736bd8 # CppTools: Support ObjC in member access operator tests 9fef4fb9ca4e65e20ff13b98bcf15e3c6232fdfb # CPlusPlus: Fix warnings about overriding visit(...) methods There were only minor conflicts while reverting those. This changes touches so many files because there were quite some cleanups and renames after the 3.4.2 release. Task-number: QTCREATORBUG-14889 Task-number: QTCREATORBUG-15211 Task-number: QTCREATORBUG-15213 Task-number: QTCREATORBUG-15257 Task-number: QTCREATORBUG-15264 Task-number: QTCREATORBUG-15291 Task-number: QTCREATORBUG-15329 Change-Id: I01f759f8f35ecb4228928a4f22086e279c1a5435 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
* CppTools: Make FollowSymbol respect projectsNikolai Kosjar2015-10-121-17/+26
| | | | | | | | | | | | | | | | | | | | Finding the class definition for a forward declaration or finding the function definition from its declaration is mostly determined by the file iteration order. Documents with the most common path prefix are checked first. This works fine as long as the files of your project have a common ancestor. If that's not the case, FollowSymbol might take you to the definition within another project. Fix that issue by considering the project part id when constructing the file iteration order. Since the cached file iteration order now depends on the projects, ensure to clear it if projects are added, changed or removed. Task-number: QTCREATORBUG-15116 Change-Id: I529166bac363959c9fee0b946747fd0370a88809 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
* C++: Fix lookup for instantiation by class objectOrgad Shaneh2015-05-151-3/+9
| | | | | | Task-number: QTCREATORBUG-14352 Change-Id: I2ce4bc1d0dba2414afe050e80607b581686081a9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Rename ClassOrNamespace -> LookupScopeOrgad Shaneh2015-04-201-3/+3
| | | | | Change-Id: Ide74482b133dd1fec40a725d9aa81bd749385f37 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* Update LicenseEike Ziller2015-01-161-6/+6
| | | | | Change-Id: I711d5fb475ef814a1dc9d2822740e827f3f67125 Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
* License updateEike Ziller2014-10-091-7/+8
| | | | | Change-Id: I3c22ef2685d7aa589f5d0ab74d693653a4c32082 Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
* C++: Check for Function::name() before using itNikolai Kosjar2014-07-171-1/+1
| | | | | | | | Lambdas do not have a name. Change-Id: Ifda4816c62dcfe19bdbb1649dc1caf408e056b37 Task-number: QTCREATORBUG-12686 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
* C++: Get rid of {Name,Type}::isEqualTo()Nikolai Kosjar2014-05-231-6/+6
| | | | | | | | | ...since it's superseded by the class Matcher. For consistency, rename FullySpecifiedType::isEqualTo() to match(). Change-Id: I07640f9218d814e0350265de45f05929e5d595a9 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* CppTools: Avoid matching function by name onlyOrgad Shaneh2014-03-041-3/+2
| | | | | | | | Compare full function signature, or at least argument count. Task-number: QTCREATORBUG-10295 Change-Id: Iead4d067209a8aea77cfcea2cd1ca5d08f87b165 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* Incremented year in copyright infoRobert Loehning2014-01-081-1/+1
| | | | | | Change-Id: Ib5423fdd064e4546f848c0b640b0ed0514c26d3a Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* CppEditor: fix "follow symbol under cursor" for operatorsJoerg Bornemann2013-10-011-14/+39
| | | | | | | | | | | | | | Like for functions we can call attemptFuncDeclDef for operators. The check for function names has been enhanced to take operators into account. For the switch from definition to declaration SymbolFinder::findMatchingDeclaration has been enriched with operator knowledge. Task-number: QTCREATORBUG-7485 Change-Id: I29eebee337e26c8bf67dc8b4a15c43883045589d Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* CppTools: Fix "! condition" coding styleNikolai Kosjar2013-07-251-17/+19
| | | | | | Change-Id: Ic7e634e4249fb64edbc2daceb65ec8e9b5f0f8b9 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
* Fix coding style for else statementsOrgad Shaneh2013-07-171-7/+3
| | | | | Change-Id: I1309db70e98d678e150388c76ce665e988fdf081 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
* CppTools: findMatchingDefinition handles const and volatileLorenz Haas2013-05-151-3/+6
| | | | | | | | | | | Strict set to true, SymbolFinder::findMatchingDefinition will now also check, if const and volatile matches. Changed return type from 'Symbol *' to 'Function *' since only functions are returned. Change-Id: Ib55cb12b6c404e94fcefd0613b964e8caa425690 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* Clean headers in CppTools.Friedemann Kleint2013-04-101-5/+0
| | | | | | | | Ran script to remove inludes on a trial-and-error basis and manually corrected it. Change-Id: Ic8464ea084ca1ab401e9f4a7d0183b92b4038902 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* fix include style relating to cplusplus librariesOswald Buddenhagen2013-04-031-8/+8
| | | | | | | | | | | ... and adjust INCLUDEPATH accordingly. while i'm at messing with include statements, also re-order the include blocks according to policy and sort them within bigger blocks. Change-Id: I7762abfd7c4ecf59432b99db2f424e4fa25733a5 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
* C++: use argumentCount in loops in initializer.Erik Verbruggen2013-03-151-5/+6
| | | | | | | | argumentCount is a more expensive function, so try to call it only once, esp. in loops. Change-Id: I6f0d420352743ec444487ce3f506ef28e5282d1e Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* Incremented year in copyright infov2.6.2Robert Loehning2013-01-291-1/+1
| | | | | Change-Id: Ic6a9ff0359625021ebc061d22db6811814534205 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* Fix: Switch Between Method Declaration/Definition issue when has ↵raidsan2012-12-121-0/+3
| | | | | | | | | implementation in header file Task-number: QTCREATORBUG-8393 Change-Id: Ie390e3151e6edc68287e5e0241365d128e6e2c4c Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Adjust license headershjk2012-10-051-21/+20
| | | | | Change-Id: Ice592c6de9951ee3b2c4cb52ed0bb3b6770e0825 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
* Contact -> qt-project.orgEike Ziller2012-07-191-3/+1
| | | | | Change-Id: I7134d7de30bcf9f9dcfad42520dd45ee083a852d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Add missing copyright headersTobias Hunger2012-03-051-0/+32
| | | | | Change-Id: I71f9050a7de9c7b07bcd7d96c8e5fc64a8565fb0 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
* C++: Fixed crash.Erik Verbruggen2012-02-231-0/+3
| | | | | Change-Id: Idec56cfced6e6eb2e0a78c4f242e7c81fec08692 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
* Removed module names from #include directives.Erik Verbruggen2012-02-151-1/+1
| | | | | | | | Getting the #include directives ready for Qt5. This includes the new-project wizards. Change-Id: Ia9261f1e8faec06b9285b694d2b7e9a095978d2b Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
* C++: Share symbol finder across editor instancesLeandro Melo2012-01-241-2/+2
| | | | | Change-Id: I75880597d237bbbe1393dd02153cedba1165bed6 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Replace non-absolute-critical asserts for soft onesLeandro Melo2012-01-241-1/+3
| | | | | Change-Id: I021074a78d90929b4e83b8aff9db1ae7995e8c6a Reviewed-by: hjk <qthjk@ovi.com>
* C++: Remaining fixes in symbol finderLeandro Melo2012-01-231-3/+5
| | | | | | | Should have gone in the previous fix commit... Change-Id: Ibca55cbd6fd58caee7d61f5e8f8c37f67391c597 Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
* C++: Fix "reference" file in symbol finderLeandro Melo2012-01-231-28/+44
| | | | | | | | | | Througout the initial review the singleton was transformed into an ordinary class, but a error was introduced: The "reference" file was incorrectly assumed to be the editors file, which is wrong, since it should be the declaration file. Change-Id: Iad3e25a690fa8bd07a18184b24b10f8dea965332 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Improve file accuracy when finding symbolsLeandro Melo2012-01-231-0/+338
This patch introduces a priority-based mechanism when searching for certains symbols in the snapshot. The priority corresponds to how similar the file path from the "reference" symbol is to the file path from the "candidate" symbol. This solves a variety of issues when matching "equivalent" symbols but that are in another file/project, such as when following a function declaration, a forward class declaration, or adding a definition through a quickfix. There's now a symbol finder which will compute the "best" search order and cache the most recent results. A consequence is that following symbols in some cases is slower, but not apparently significatly. Note: The "find" functions were moved from the Snapshot to the new SymbolFinder class. Task-number: QTCREATORBUG-6697 Task-number: QTCREATORBUG-6792 Change-Id: Ia518f014275fec1f4d0cb3224bd4e06a9df6d557 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>