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

Function basePathAndTypeForUrl

plugins/clang/duchain/documentfinderhelpers.cpp:135–157  ·  view source on GitHub ↗

* Generates the base path (without extension) and the file type * for the specified url. * * @returns pair of base path and file type which has been found for @p url. */

Source from the content-addressed store, hash-verified

133 * @returns pair of base path and file type which has been found for @p url.
134 */
135QPair<QString,FileType> basePathAndTypeForUrl(const QUrl &url)
136{
137 QString path = url.toLocalFile();
138 int idxSlash = path.lastIndexOf(QLatin1Char('/'));
139 int idxDot = path.lastIndexOf(QLatin1Char('.'));
140 FileType fileType = Unknown;
141 QString basePath;
142 if (idxSlash >= 0 && idxDot >= 0 && idxDot > idxSlash) {
143 basePath = path.left(idxDot);
144 if (idxDot + 1 < path.length()) {
145 QString extension = path.mid(idxDot + 1);
146 if (ClangHelpers::isHeader(extension)) {
147 fileType = Header;
148 } else if (ClangHelpers::isSource(extension)) {
149 fileType = Source;
150 }
151 }
152 } else {
153 basePath = path;
154 }
155
156 return qMakePair(basePath, fileType);
157}
158
159}
160

Callers 3

areBuddiesFunction · 0.85
buddyOrderFunction · 0.85
potentialBuddiesFunction · 0.85

Calls 3

toLocalFileMethod · 0.80
midMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected