summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/baseeditordocumentparser.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge CppTools into CppEditorChristian Kandeler2021-09-011-116/+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 override consistentlyTobias Hunger2018-05-071-1/+1
| | | | | | | clang-tidy fixes from modernize-use-override check. Change-Id: I0e6d6a9df3e87b8042ccc5ea0adc70070a3821d6 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* CppTools: Fix choosing project part after project openNikolai Kosjar2017-01-261-4/+4
| | | | | | | | | As long as there are project parts for a source file, always determine the best project part, instead of trying to stick to the previous one. This ensures the best project part at all times and simplifies the code. Change-Id: I25ea3eb43a5a3e6d93688d4b8965f596dc9ae22b Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Fix using updated project partNikolai Kosjar2017-01-261-2/+2
| | | | | | | | | | | | | | | 1. Open a project consisting of two subprojects referencing the same source file. 2. Open the source file. 3. Click '#' in the editor toolbar and select the second project (part). 4. Update the project file, e.g. add a define ==> Editor does not reflect the added define This is due to comparing project part pointers. Fix by using the project part id that remains stable across project manager updates. Change-Id: Ifd1a113e55ebe2ecf036cd7caafdbfd6e4cdf415 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Use fallback project part if project is closedNikolai Kosjar2017-01-261-4/+2
| | | | | | | | | ...instead of sticking to the old one. If a project is closed, the editor should reflect that. It also simplifies the code. Change-Id: I9b8a94513d3b06a238cfc4ee60c11c0d0da3d93f Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Provide hints about chosen project part for editor documentNikolai Kosjar2017-01-241-9/+13
| | | | | | | | | | | | Parse issues can have multiple reasons (invalid kit, not a project file, actual parse issue) and we should be able to tell them apart. With this change, we can distinguish between the fallback project part and a ambiguous project part. Follow up changes will use this to display more accurate diagnostics. Change-Id: Icc8767607cc17dc14d6227b07f34e81ba5525a96 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Allow interpreting ambiguous headers as C headersNikolai Kosjar2017-01-161-0/+5
| | | | | | | | | | | | | | ...instead of C++ headers. For the Clang Code Model this results in using "-x c-header" instead of "-x c++-header". This introduces a new option in Options > C++ > "Code Model" to configure this. Change-Id: I8a0ce8fa6155f5ef58743ebc7f1d0b500fbf6599 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* CppTools: Reparse editor documents after active project changeNikolai Kosjar2016-12-161-2/+6
| | | | | Change-Id: I010709c866291bf59c27f4a05765e1ab0efd28af Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Remove some duplicationNikolai Kosjar2016-12-161-7/+15
| | | | | Change-Id: I8c84660b28c3e76b2cedd08ff3b44a38583f38a0 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Rename updateHelper -> updateImplNikolai Kosjar2016-12-161-3/+3
| | | | | Change-Id: If1a1fb97aa2bcfad186c013f2b2cc4b94c66001e Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Prioritize project parts from active projectNikolai Kosjar2016-12-161-4/+11
| | | | | | | ...when selecting one for the editor document. Change-Id: I85066aaa0862870cb2db2fb2cb40c2b2c23b2cac Reviewed-by: David Schulz <david.schulz@qt.io>
* CppTools: Cancel parsing if editor is closedNikolai Kosjar2016-07-291-2/+5
| | | | | | | | | | | | The m_parserFuture.cancel() in ~BuiltinEditorDocumentProcessor() did not cancel anything. Thus, closing a document while the parser was running led to a blocking UI thread. Now it cancels at the next include directive it encounters. Change-Id: I092fddbbd747e0bc95265b6e9b4fcc26b3f76cb3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
* Wholesale conversion to #pragma oncehjk2016-03-301-4/+1
| | | | | | | Kudos to cgmb and https://github.com/cgmb/guardonce Change-Id: Ifa8970734b8d43fd08c9260c645bdb0228633791 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* 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>
* CppTools: Remove cpptools/cppprojects.[h|cpp]Marco Bubke2016-01-131-1/+1
| | | | | Change-Id: Ida0e8552d371972c141cf561b28667f4428c6fff Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* CppTools/Clang: Remove InMemoryInfoNikolai Kosjar2015-12-161-8/+2
| | | | | | | ...nowadays we only need the working copy. Change-Id: I30924b3c5dc68b428d6c10f6ba015b0640b476d2 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
* CppTools/Clang: Clean-up of includesNikolai Kosjar2015-12-161-1/+2
| | | | | Change-Id: I0ba340dcf0ee23e61588f17262d07e7088751836 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
* C++: Fix crash after triggering completion and closing editorNikolai Kosjar2015-09-021-1/+2
| | | | | | | | | | | | | | | | | | | | | Fix use-after-free for the following case: 1. Open an editor 2. Trigger a long processing completion (e.g. simulate with QThread::msleep in CppCompletionAssistInterface::getCppSpecifics) 3. ...and immediately close the editor (e.g. with Ctrl+W) 4. Wait until it crashes. The completion thread relied on the BuiltinEditorDocumentParser object, which is deleted once the editor is closed. Fixed by sharing the ownership of that object between the *EditorDocumentProcessor and the completion assist interface. This case came up when doing tests for the bug report below. Task-number: QTCREATORBUG-14991 Change-Id: I0b009229e68fc6b7838740858cdc41a32403fe6f Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
* Clang: Fix sending (un)register translation unitNikolai Kosjar2015-07-201-0/+1
| | | | | | | | | | | | | | | | Handle the following use cases: 1. Editor is opened --> Register file at backend. 2. Close editor for which a project part exists --> Unregister file with project part. 3. Close editor for which no project part exists (anymore) --> Unregister file with empty/default project part. Change-Id: I2b253004a920cccef989876538ab552eacf6b45c Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
* Clang: Do not call DocumentManager::modifiedDocuments() from worker threadNikolai Kosjar2015-07-101-2/+9
| | | | | | | This is unsafe. Change-Id: I8ac075a7289afa0d84785e37b1325d186a153000 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* CppTools: Let BaseEditorDocumentParser acquire the mutexNikolai Kosjar2015-07-101-5/+4
| | | | | | | ...so derived classes are freed from doing this. Change-Id: I73f3eca54be14cfd6542a466f0e9c024457bef07 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* CppTools: Avoid unnecessary blocking of main threadNikolai Kosjar2015-07-101-22/+26
| | | | | | | | | | | | | | | | Among others, BaseEditorDocumentParser::projectPart() was a blocking operation in case the parser was running. This led to noticeable GUI freezes for the ClangCodeModel since the function was called from the main thread. Rework *EditorDocumentParser to clearly separate the configuration data (input) from the actual object state. Querying/setting configuration or (last) state does not block anymore. update() is supposed to get the necessary configuration and the last state at the beginning and to set the new state at end. Change-Id: Ib4b534fa6ff373c3059826726b3f10ece95acc21 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* CppTools: Make updateProjectPart() constNikolai Kosjar2015-07-101-2/+2
| | | | | | | | | | ...and rename to "determineProjectPart". This is in preparation for a follow-up change. determineProjectPart() should not set any state. Change-Id: Iad7be8638fd97a79a4227a944896ac9af0a36862 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* CppTools: Remove some pointless declarationsNikolai Kosjar2015-07-081-2/+0
| | | | | | | | * Unneeded private declared constructors * Q_DISABLE_COPY for classes deriving from QObject (not copyable) Change-Id: I89669e8bb062cda16bab5812e2ac591f9dcf4af2 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
* Update LicenseEike Ziller2015-01-161-6/+6
| | | | | Change-Id: I711d5fb475ef814a1dc9d2822740e827f3f67125 Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
* License update.Eike Ziller2014-10-151-7/+8
| | | | | Change-Id: I0acde2c3b995693de682679471f03af85bdd0a61 Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
* CppTools: Change CppModelManager implementation patternhjk2014-09-191-1/+1
| | | | | | | | | Replace the CppModelManagerInterface/derived CppModelManager combo by a more common CppModelManager/CppModelManagerPrivate pimpl pattern. Change-Id: Ia4582845ed94d5ef60b8571bab9b2260c6290287 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Base parsing on editor document instead of widgetNikolai Kosjar2014-08-251-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mainly takes CppEditorSupport apart. * Parsing is now invoked by CPPEditorDocument itself by listening to QTextDocument::contentsChanged(). * Upon construction and destruction CPPEditorDocument creates and deletes an EditorDocumentHandle for (un)registration in the model manager. This handle provides everything to generate the working copy and to access the editor document processor. * A CPPEditorDocument owns a BaseEditorDocumentProcessor instance that controls parsing, semantic info recalculation and the semantic highlighting for the document. This is more or less what is left from CppEditorSupport and can be considered as the backend of a CPPEditorDocument. CPPEditorDocument itself is quite small. * BuiltinEditorDocumentProcessor and ClangEditorDocumentProcessor derive from BaseEditorDocumentProcessor and implement the gaps. * Since the semantic info calculation was bound to the widget, it also calculated the local uses, which depend on the cursor position. This calculation got moved into the extracted class UseSeletionsUpdater in the cppeditor plugin, which is run once the cursor position changes or the semantic info document is updated. * Some more logic got extracted: - SemanticInfoUpdater (logic was in CppEditorSupport) - SemanticHighlighter (logic was in CppEditorSupport) * The *Parser and *Processor classes can be easily accessed by the static function get(). * CppHighlightingSupport is gone since it turned out to be useless. * The editor dependency in CompletionAssistProviders is gone since we actually only need the file path now. Change-Id: I49d3a7bd138c5ed9620123e34480772535156508 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* CppTools: Extract BaseEditorDocumentParser out of SnapshotUpdaterNikolai Kosjar2014-08-201-0/+83
Change-Id: If89e81eec6d600d3d39cc09203cf434d0768c1b4 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>