MCPcopy Create free account
hub / github.com/KDE/kdevelop / formatDocument

Method formatDocument

kdevplatform/shell/sourceformattercontroller.cpp:720–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718}
719
720void SourceFormatterController::FileFormatter::formatDocument(IDocument& doc) const
721{
722 Q_ASSERT(m_formatter);
723 Q_ASSERT(doc.url() == m_url);
724
725 qCDebug(SHELL) << "Running" << m_formatter->name() << "on" << m_url;
726
727 // We don't use KTextEditor::Document directly, because CodeRepresentation transparently works
728 // around a possible tab-replacement incompatibility between kate and kdevelop
729 auto code = KDevelop::createCodeRepresentation(IndexedString{m_url});
730
731 const auto cursor = doc.cursorPosition();
732
733 QString text = format(code->text());
734 text = addModeline(text);
735 code->setText(text);
736
737 doc.setCursorPosition(cursor);
738}
739
740void SourceFormatterController::settingsChanged()
741{

Callers 2

formatFileMethod · 0.80
beautifySourceMethod · 0.80

Calls 8

createCodeRepresentationFunction · 0.85
formatFunction · 0.85
urlMethod · 0.45
nameMethod · 0.45
cursorPositionMethod · 0.45
textMethod · 0.45
setTextMethod · 0.45
setCursorPositionMethod · 0.45

Tested by

no test coverage detected