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

Method containedIn

plugins/quickopen/projectitemquickopen.cpp:40–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 }
39
40 inline int containedIn(const Identifier& id) const
41 {
42 int index = id.index();
43 QHash<int, int>::const_iterator it = cache.constFind(index);
44 if (it != cache.constEnd()) {
45 return *it;
46 }
47
48 const QString idStr = id.identifier().str();
49
50 int result = idStr.lastIndexOf(substring, -1, Qt::CaseInsensitive);
51 if (result < 0 && !idStr.isEmpty() && !substring.isEmpty()) {
52 // no match; try abbreviations
53 result = matchesAbbreviation(idStr, substring) ? 0 : -1;
54 }
55
56 //here we shift the values if the matched string is bigger than the substring,
57 //so closer matches will appear first
58 if (result >= 0) {
59 result = result + (idStr.size() - substring.size());
60 }
61
62 cache[index] = result;
63
64 return result;
65 }
66
67 QString substring;
68 mutable QHash<int, int> cache;

Callers 1

setFilterTextMethod · 0.80

Calls 8

matchesAbbreviationFunction · 0.85
constEndMethod · 0.80
strMethod · 0.80
indexMethod · 0.45
constFindMethod · 0.45
identifierMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected