@@ -132,7 +132,7 @@ void CodeDocument::deleteSymbol(const Symbol &symbol)
132
132
*/
133
133
Core::SymbolList CodeDocument::symbols () const
134
134
{
135
- LOG (" CodeDocument::symbols " );
135
+ LOG ();
136
136
return m_treeSitterHelper->symbols ();
137
137
}
138
138
@@ -199,7 +199,7 @@ QString CodeDocument::hover(int position, std::function<void(const QString &)> a
199
199
std::pair<QString, std::optional<RangeMark>> CodeDocument::hoverWithRange (
200
200
int position, std::function<void (const QString &, std::optional<RangeMark>)> asyncCallback /* = {} */ ) const
201
201
{
202
- spdlog::debug (" CodeDocument::hover " );
202
+ spdlog::debug (" {} " , FUNCTION_NAME );
203
203
204
204
if (!checkClient ())
205
205
return {" " , {}};
@@ -226,8 +226,10 @@ std::pair<QString, std::optional<RangeMark>> CodeDocument::hoverWithRange(
226
226
if (const auto *content = std::get_if<Lsp::MarkupContent>(&hover.contents )) {
227
227
return {QString::fromStdString (content->value ), range};
228
228
} else {
229
- spdlog::warn (" LSP returned deprecated MarkedString type which is unsupported by Knut\n - Consider updating "
230
- " your LSP server" );
229
+ spdlog::warn (
230
+ " {}: LSP returned deprecated MarkedString type which is unsupported by Knut\n - Consider updating "
231
+ " your LSP server" ,
232
+ FUNCTION_NAME);
231
233
return {" " , {}};
232
234
}
233
235
};
@@ -245,7 +247,7 @@ std::pair<QString, std::optional<RangeMark>> CodeDocument::hoverWithRange(
245
247
// a Tooltip is requested.
246
248
// See: TextView::eventFilter.
247
249
if (!std::holds_alternative<Lsp::Hover>(result.value ())) {
248
- spdlog::debug (" LSP server returned no result for Hover" );
250
+ spdlog::debug (" {}: LSP server returned no result for Hover" , FUNCTION_NAME );
249
251
}
250
252
return convertResult (result.value ());
251
253
}
@@ -256,7 +258,7 @@ std::pair<QString, std::optional<RangeMark>> CodeDocument::hoverWithRange(
256
258
257
259
RangeMarkList CodeDocument::references (int position) const
258
260
{
259
- spdlog::debug (" CodeDocument::references " );
261
+ spdlog::debug (" {} " , FUNCTION_NAME );
260
262
261
263
if (!checkClient ()) {
262
264
return {};
@@ -271,10 +273,10 @@ RangeMarkList CodeDocument::references(int position) const
271
273
if (const auto *locations = std::get_if<std::vector<Lsp::Location>>(&value)) {
272
274
return Utils::lspToRangeMarkList (*locations);
273
275
} else {
274
- spdlog::warn (" CodeDocument::references: Language server returned unsupported references type!" );
276
+ spdlog::warn (" {}: Language server returned unsupported references type!" , FUNCTION_NAME );
275
277
}
276
278
} else {
277
- spdlog::warn (" CodeDocument::references: LSP call to references returned nothing!" );
279
+ spdlog::warn (" {}: LSP call to references returned nothing!" , FUNCTION_NAME );
278
280
}
279
281
280
282
return {};
@@ -283,7 +285,7 @@ RangeMarkList CodeDocument::references(int position) const
283
285
// Follows the symbol under the cursor.
284
286
Document *CodeDocument::followSymbol ()
285
287
{
286
- spdlog::debug (" CodeDocument::followSymbol " );
288
+ spdlog::debug (" {} " , FUNCTION_NAME );
287
289
if (!checkClient ())
288
290
return {};
289
291
@@ -332,7 +334,7 @@ Document *CodeDocument::followSymbol(int pos)
332
334
return nullptr ;
333
335
334
336
if (locations.size () > 1 )
335
- spdlog::warn (" CodeDocument::followSymbol: Multiple locations returned!" );
337
+ spdlog::warn (" {}: Multiple locations returned!" , FUNCTION_NAME );
336
338
// Heuristic: If multiple locations were found, use the last one.
337
339
auto location = locations.back ();
338
340
@@ -347,8 +349,7 @@ Document *CodeDocument::followSymbol(int pos)
347
349
if (auto *codeDocument = qobject_cast<CodeDocument *>(document)) {
348
350
codeDocument->selectRange (Utils::lspToRange (*codeDocument, location.range ));
349
351
} else {
350
- spdlog::warn (" CodeDocument::followSymbol: Opened document '{}' is not an CodeDocument" ,
351
- document->fileName ());
352
+ spdlog::warn (" {}: Opened document '{}' is not an CodeDocument" , FUNCTION_NAME, document->fileName ());
352
353
}
353
354
}
354
355
@@ -358,7 +359,7 @@ Document *CodeDocument::followSymbol(int pos)
358
359
// Switches between the function declaration or definition.
359
360
Document *CodeDocument::switchDeclarationDefinition ()
360
361
{
361
- spdlog::debug (" CodeDocument::switchDeclarationDefinition " );
362
+ spdlog::debug (" {} " , FUNCTION_NAME );
362
363
if (!checkClient ())
363
364
return {};
364
365
@@ -371,7 +372,7 @@ Document *CodeDocument::switchDeclarationDefinition()
371
372
});
372
373
373
374
if (!currentFunction) {
374
- spdlog::info (" CodeDocument::switchDeclarationDefinition: Cursor is currently not within a function!" );
375
+ spdlog::info (" {}: Cursor is currently not within a function!" , FUNCTION_NAME );
375
376
return nullptr ;
376
377
}
377
378
@@ -390,7 +391,7 @@ Document *CodeDocument::switchDeclarationDefinition()
390
391
*/
391
392
void CodeDocument::selectSymbol (const QString &name, int options)
392
393
{
393
- LOG (" CodeDocument::selectSymbol " , LOG_ARG (" text" , name), options);
394
+ LOG (LOG_ARG (" text" , name), options);
394
395
395
396
if (auto symbol = findSymbol (name, options))
396
397
selectRange (symbol->selectionRange ());
@@ -405,7 +406,7 @@ void CodeDocument::selectSymbol(const QString &name, int options)
405
406
*/
406
407
int CodeDocument::selectLargerSyntaxNode (int count /* = 1*/ )
407
408
{
408
- LOG_AND_MERGE (" CodeDocument::selectLargerSyntaxNode " , LOG_ARG (" count" , count));
409
+ LOG_AND_MERGE (LOG_ARG (" count" , count));
409
410
410
411
auto currentNode = m_treeSitterHelper->nodeCoveringRange (selectionStart (), selectionEnd ());
411
412
@@ -444,7 +445,7 @@ int CodeDocument::selectLargerSyntaxNode(int count /* = 1*/)
444
445
*/
445
446
int CodeDocument::selectSmallerSyntaxNode (int count /* = 1*/ )
446
447
{
447
- LOG_AND_MERGE (" CodeDocument::selectSmallerSyntaxNode " , LOG_ARG (" count" , count));
448
+ LOG_AND_MERGE (LOG_ARG (" count" , count));
448
449
449
450
auto smallerNodes =
450
451
kdalgorithms::filtered (m_treeSitterHelper->nodesInRange (createRangeMark ()), [](const auto &node) {
@@ -469,8 +470,7 @@ int CodeDocument::selectSmallerSyntaxNode(int count /* = 1*/)
469
470
if (node.has_value ()) {
470
471
selectRegion (node->startPosition (), node->endPosition ());
471
472
} else {
472
- spdlog::warn (
473
- " CodeDocument::selectSmallerSyntaxNode: No smaller node found! Do you currently not have a selection?" );
473
+ spdlog::warn (" {}: No smaller node found! Do you currently not have a selection?" , FUNCTION_NAME);
474
474
}
475
475
476
476
LOG_RETURN (" pos" , position ());
@@ -513,7 +513,7 @@ findSibling(const treesitter::Node &start, treesitter::Node (treesitter::Node::*
513
513
*/
514
514
int CodeDocument::selectNextSyntaxNode (int count /* = 1*/ )
515
515
{
516
- LOG_AND_MERGE (" CodeDocument::selectNextSyntaxNode " , LOG_ARG (" count" , count));
516
+ LOG_AND_MERGE (LOG_ARG (" count" , count));
517
517
518
518
auto node = m_treeSitterHelper->nodeCoveringRange (selectionStart (), selectionEnd ());
519
519
@@ -540,7 +540,7 @@ int CodeDocument::selectNextSyntaxNode(int count /*= 1*/)
540
540
*/
541
541
int CodeDocument::selectPreviousSyntaxNode (int count /* = 1*/ )
542
542
{
543
- LOG_AND_MERGE (" CodeDocument::selectPreviousSyntaxNode " , LOG_ARG (" count" , count));
543
+ LOG_AND_MERGE (LOG_ARG (" count" , count));
544
544
545
545
auto node = m_treeSitterHelper->nodeCoveringRange (selectionStart (), selectionEnd ());
546
546
@@ -566,7 +566,7 @@ int CodeDocument::selectPreviousSyntaxNode(int count /*= 1*/)
566
566
*/
567
567
Symbol *CodeDocument::findSymbol (const QString &name, int options) const
568
568
{
569
- LOG (" CodeDocument::findSymbol " , LOG_ARG (" text" , name), options);
569
+ LOG (LOG_ARG (" text" , name), options);
570
570
571
571
auto symbols = this ->symbols ();
572
572
const auto regexp =
@@ -681,7 +681,7 @@ Core::QueryMatchList CodeDocument::query(const std::shared_ptr<treesitter::Query
681
681
*/
682
682
Core::QueryMatchList CodeDocument::query (const QString &query)
683
683
{
684
- LOG (" CodeDocument::query " , LOG_ARG (" query" , query));
684
+ LOG (LOG_ARG (" query" , query));
685
685
686
686
return this ->query (m_treeSitterHelper->constructQuery (query));
687
687
}
@@ -701,7 +701,7 @@ Core::QueryMatchList CodeDocument::query(const QString &query)
701
701
*/
702
702
Core::QueryMatch CodeDocument::queryFirst (const QString &query)
703
703
{
704
- LOG (" CodeDocument::queryOne " , LOG_ARG (" query" , query));
704
+ LOG (LOG_ARG (" query" , query));
705
705
706
706
return this ->queryFirst (m_treeSitterHelper->constructQuery (query));
707
707
}
@@ -715,20 +715,20 @@ Core::QueryMatch CodeDocument::queryFirst(const QString &query)
715
715
*/
716
716
Core::QueryMatchList CodeDocument::queryInRange (const Core::RangeMark &range, const QString &query)
717
717
{
718
- LOG (" CodeDocument::queryInRange " , LOG_ARG (" range" , range), LOG_ARG (" query" , query));
718
+ LOG (LOG_ARG (" range" , range), LOG_ARG (" query" , query));
719
719
720
720
if (!range.isValid ()) {
721
- spdlog::warn (" CodeDocument::queryInRange: Range is not valid" );
721
+ spdlog::warn (" {}: Range is not valid" , FUNCTION_NAME );
722
722
return {};
723
723
}
724
724
725
725
const auto nodes = m_treeSitterHelper->nodesInRange (range);
726
726
727
727
if (nodes.isEmpty ()) {
728
- spdlog::warn (" CodeDocument::queryInRange: No nodes in range" );
728
+ spdlog::warn (" {}: No nodes in range" , FUNCTION_NAME );
729
729
return {};
730
730
}
731
- spdlog::debug (" CodeDocument::queryInRange: Found {} nodes in range" , nodes.size ());
731
+ spdlog::debug (" {}: Found {} nodes in range" , FUNCTION_NAME , nodes.size ());
732
732
733
733
auto tsQuery = m_treeSitterHelper->constructQuery (query);
734
734
if (!tsQuery)
@@ -755,7 +755,7 @@ bool CodeDocument::checkClient() const
755
755
{
756
756
Q_ASSERT (textEdit ());
757
757
if (!client ()) {
758
- spdlog::error (" CodeDocument {} has no LSP client - API not available" , fileName ());
758
+ spdlog::error (" {}: CodeDocument {} has no LSP client - API not available" , FUNCTION_NAME , fileName ());
759
759
return false ;
760
760
}
761
761
return true ;
@@ -770,14 +770,16 @@ void CodeDocument::changeContentLsp(int position, int charsRemoved, int charsAdd
770
770
// TODO: Keep copy of previous string around, so we can find the oldEndPosition.
771
771
// const auto document = textEdit()->document();
772
772
// const auto startblock = document->findBlock(position);
773
- // spdlog::warn("start point: {}, {}", startblock.blockNumber(), position - startblock.position());
773
+ // spdlog::warn("{} - start point: {}, {}", FUNCTION_NAME, startblock.blockNumber(), position -
774
+ // startblock.position());
774
775
775
776
// const auto newEndPosition = position + charsAdded;
776
777
// const auto newEndBlock = document->findBlock(newEndPosition);
777
- // spdlog::warn("new end point: {}, {}", newEndBlock.blockNumber(), newEndPosition - newEndBlock.position());
778
+ // spdlog::warn("{} - new end point: {}, {}", FUNCTION_NAME, newEndBlock.blockNumber(), newEndPosition -
779
+ // newEndBlock.position());
778
780
779
781
// const auto plain = document->toPlainText();
780
- // spdlog::warn("added: {}", plain.sliced(position, charsAdded));
782
+ // spdlog::warn("{} - added: {}", FUNCTION_NAME , plain.sliced(position, charsAdded));
781
783
782
784
if (!checkClient ()) {
783
785
return ;
@@ -811,7 +813,7 @@ void CodeDocument::changeContentLsp(int position, int charsRemoved, int charsAdd
811
813
812
814
client ()->didChange (std::move (params));
813
815
} else {
814
- spdlog::error (" LSP server does not support Document changes!" );
816
+ spdlog::error (" {}: LSP server does not support Document changes!" , FUNCTION_NAME );
815
817
}
816
818
}
817
819
0 commit comments