forked from qt-creator/qt-creator
Clang: Indicate available "fix its" with a light bulb
...at the end of the line, just like for the "Apply Function Signature Changes" refactor action. * Hovering the light bulb shows the tooltip "Inspect available fixits". * Clicking the light bulb leads to the refactoring menu, as if the user hit Alt+Return. Change-Id: Iaf7b3734c43e21fc28e6b0658f517d98858c0e0c Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
#include <cpptools/symbolfinder.h>
|
||||
|
||||
#include <texteditor/completionsettings.h>
|
||||
#include <texteditor/convenience.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/textdocumentlayout.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
@@ -271,11 +272,14 @@ void CppEditorWidget::onCppDocumentUpdated()
|
||||
}
|
||||
|
||||
void CppEditorWidget::onCodeWarningsUpdated(unsigned revision,
|
||||
const QList<QTextEdit::ExtraSelection> selections)
|
||||
const QList<QTextEdit::ExtraSelection> selections,
|
||||
const TextEditor::RefactorMarkers &refactorMarkers)
|
||||
{
|
||||
if (revision != documentRevision())
|
||||
return;
|
||||
|
||||
setExtraSelections(TextEditorWidget::CodeWarningsSelection, selections);
|
||||
setRefactorMarkers(refactorMarkersWithoutClangMarkers() + refactorMarkers);
|
||||
}
|
||||
|
||||
void CppEditorWidget::onIfdefedOutBlocksUpdated(unsigned revision,
|
||||
@@ -428,6 +432,26 @@ unsigned CppEditorWidget::documentRevision() const
|
||||
return document()->revision();
|
||||
}
|
||||
|
||||
static bool isClangFixItAvailableMarker(const RefactorMarker &marker)
|
||||
{
|
||||
return marker.data.toString()
|
||||
== QLatin1String(CppTools::Constants::CPP_CLANG_FIXIT_AVAILABLE_MARKER_ID);
|
||||
}
|
||||
|
||||
RefactorMarkers CppEditorWidget::refactorMarkersWithoutClangMarkers() const
|
||||
{
|
||||
RefactorMarkers clearedRefactorMarkers;
|
||||
|
||||
foreach (const RefactorMarker &marker, refactorMarkers()) {
|
||||
if (isClangFixItAvailableMarker(marker))
|
||||
continue;
|
||||
|
||||
clearedRefactorMarkers.append(marker);
|
||||
}
|
||||
|
||||
return clearedRefactorMarkers;
|
||||
}
|
||||
|
||||
bool CppEditorWidget::isSemanticInfoValidExceptLocalUses() const
|
||||
{
|
||||
return d->m_lastSemanticInfo.doc
|
||||
@@ -631,8 +655,15 @@ QSharedPointer<FunctionDeclDefLink> CppEditorWidget::declDefLink() const
|
||||
|
||||
void CppEditorWidget::onRefactorMarkerClicked(const RefactorMarker &marker)
|
||||
{
|
||||
if (marker.data.canConvert<FunctionDeclDefLink::Marker>())
|
||||
if (marker.data.canConvert<FunctionDeclDefLink::Marker>()) {
|
||||
applyDeclDefLinkChanges(true);
|
||||
} else if (isClangFixItAvailableMarker(marker)) {
|
||||
int line, column;
|
||||
if (Convenience::convertPosition(document(), marker.cursor.position(), &line, &column)) {
|
||||
setTextCursor(marker.cursor);
|
||||
invokeAssist(TextEditor::QuickFix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CppEditorWidget::updateFunctionDeclDefLink()
|
||||
|
||||
Reference in New Issue
Block a user