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

Method read

kdevplatform/util/kdevformatfile.cpp:44–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44bool KDevFormatFile::read()
45{
46 constexpr QChar delimiter = QLatin1Char(':');
47
48 QFile formatFile(formatFileName);
49 if (!formatFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
50 qStdOut() << "unable to open \"" << formatFileName << "\"\n";
51 return false;
52 }
53
54 int lineNumber = 0;
55 while (!formatFile.atEnd()) {
56 ++lineNumber;
57
58 QString line = QString::fromUtf8(formatFile.readLine().trimmed());
59 if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
60 continue;
61
62 if (line.indexOf(delimiter) < 0) {
63 // We found the simple syntax without wildcards, and only with the command
64 m_formatLines.append({QStringList{}, std::move(line)});
65 } else {
66 // We found the correct syntax with "wildcards : command"
67
68 QStringList wildcards = line.section(delimiter, 0, 0).split(QLatin1Char(' '), Qt::SkipEmptyParts);
69 QString command = line.section(delimiter, 1).trimmed();
70
71 if (wildcards.isEmpty()) {
72 qStdOut() << formatFileName << ":" << lineNumber
73 << ": error: empty wildcard, skip the line\n";
74 continue;
75 }
76 m_formatLines.append({std::move(wildcards), std::move(command)});
77 }
78 }
79
80 if (m_formatLines.isEmpty()) {
81 qStdOut() << formatFileName << ": error: no commands are found\n";
82 return false;
83 }
84
85 return true;
86}
87
88bool KDevFormatFile::apply()
89{

Callers 7

loadTopDUContextDataFunction · 0.45
loadDataMethod · 0.45
loadMethod · 0.45
DUChainPrivateMethod · 0.45
mainFunction · 0.45
applyFormattingFunction · 0.45
runTestMethod · 0.45

Calls 8

atEndMethod · 0.80
readLineMethod · 0.80
sectionMethod · 0.80
openMethod · 0.45
isEmptyMethod · 0.45
indexOfMethod · 0.45
appendMethod · 0.45
splitMethod · 0.45

Tested by 2

applyFormattingFunction · 0.36
runTestMethod · 0.36