forked from qt-creator/qt-creator
LanguageClient: Allow to pre-set the new symbol name
... when renaming. There are contexts which provide the new name in advance. Change-Id: I4bda689405060c343c0654d0aca274f10ee22752 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -288,14 +288,16 @@ bool SymbolSupport::supportsRename(TextEditor::TextDocument *document)
|
|||||||
return LanguageClient::supportsRename(m_client, document, prepareSupported);
|
return LanguageClient::supportsRename(m_client, document, prepareSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolSupport::renameSymbol(TextEditor::TextDocument *document, const QTextCursor &cursor)
|
void SymbolSupport::renameSymbol(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
||||||
|
const QString &newSymbolName)
|
||||||
{
|
{
|
||||||
const TextDocumentPositionParams params = generateDocPosParams(document, cursor);
|
const TextDocumentPositionParams params = generateDocPosParams(document, cursor);
|
||||||
QTextCursor tc = cursor;
|
QTextCursor tc = cursor;
|
||||||
tc.select(QTextCursor::WordUnderCursor);
|
tc.select(QTextCursor::WordUnderCursor);
|
||||||
const QString oldSymbolName = tc.selectedText();
|
const QString oldSymbolName = tc.selectedText();
|
||||||
const QString placeholder = m_defaultSymbolMapper ? m_defaultSymbolMapper(oldSymbolName)
|
QString placeholder = newSymbolName;
|
||||||
: oldSymbolName;
|
if (placeholder.isEmpty())
|
||||||
|
placeholder = m_defaultSymbolMapper ? m_defaultSymbolMapper(oldSymbolName) : oldSymbolName;
|
||||||
|
|
||||||
bool prepareSupported;
|
bool prepareSupported;
|
||||||
if (!LanguageClient::supportsRename(m_client, document, prepareSupported)) {
|
if (!LanguageClient::supportsRename(m_client, document, prepareSupported)) {
|
||||||
|
@@ -42,7 +42,8 @@ public:
|
|||||||
const ResultHandler &handler = {});
|
const ResultHandler &handler = {});
|
||||||
|
|
||||||
bool supportsRename(TextEditor::TextDocument *document);
|
bool supportsRename(TextEditor::TextDocument *document);
|
||||||
void renameSymbol(TextEditor::TextDocument *document, const QTextCursor &cursor);
|
void renameSymbol(TextEditor::TextDocument *document, const QTextCursor &cursor,
|
||||||
|
const QString &newSymbolName = {});
|
||||||
|
|
||||||
static Core::Search::TextRange convertRange(const LanguageServerProtocol::Range &range);
|
static Core::Search::TextRange convertRange(const LanguageServerProtocol::Range &range);
|
||||||
static QStringList getFileContents(const Utils::FilePath &filePath);
|
static QStringList getFileContents(const Utils::FilePath &filePath);
|
||||||
|
Reference in New Issue
Block a user