Changeset View
Changeset View
Standalone View
Standalone View
languages/clang/codecompletion/completionhelper.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | { | 69 | { | ||
70 | QStringList types; | 70 | QStringList types; | ||
71 | clang_visitChildren(cursor, templateParamsHelper, &types); | 71 | clang_visitChildren(cursor, templateParamsHelper, &types); | ||
72 | return types; | 72 | return types; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | FuncOverrideInfo processCXXMethod(CXCursor cursor, OverrideInfo* info) | 75 | FuncOverrideInfo processCXXMethod(CXCursor cursor, OverrideInfo* info) | ||
76 | { | 76 | { | ||
77 | QStringList params; | 77 | FuncParameterList params; | ||
78 | 78 | | |||
79 | int numArgs = clang_Cursor_getNumArguments(cursor); | 79 | int numArgs = clang_Cursor_getNumArguments(cursor); | ||
80 | for (int i = 0; i < numArgs; i++) { | 80 | for (int i = 0; i < numArgs; i++) { | ||
81 | CXCursor arg = clang_Cursor_getArgument(cursor, i); | 81 | CXCursor arg = clang_Cursor_getArgument(cursor, i); | ||
82 | QString id = ClangString(clang_getCursorDisplayName(arg)).toString(); | 82 | QString id = ClangString(clang_getCursorDisplayName(arg)).toString(); | ||
83 | QString type = ClangString(clang_getTypeSpelling(clang_getCursorType(arg))).toString(); | 83 | QString type = ClangString(clang_getTypeSpelling(clang_getCursorType(arg))).toString(); | ||
84 | if (info->templateTypeMap.contains(type)) { | 84 | if (info->templateTypeMap.contains(type)) { | ||
85 | type = info->templateTypeMap.value(type); | 85 | type = info->templateTypeMap.value(type); | ||
86 | } | 86 | } | ||
87 | params << type + QLatin1Char(' ') + id; | 87 | FuncParameterInfo param; | ||
88 | param.type = type; | ||||
89 | param.id = id; | ||||
90 | params << param; | ||||
88 | } | 91 | } | ||
89 | 92 | | |||
90 | FuncOverrideInfo fp; | 93 | FuncOverrideInfo fp; | ||
91 | QString retType = ClangString(clang_getTypeSpelling(clang_getCursorResultType(cursor))).toString(); | 94 | QString retType = ClangString(clang_getTypeSpelling(clang_getCursorResultType(cursor))).toString(); | ||
92 | if (info->templateTypeMap.contains(retType)) { | 95 | if (info->templateTypeMap.contains(retType)) { | ||
93 | retType = info->templateTypeMap.value(retType); | 96 | retType = info->templateTypeMap.value(retType); | ||
94 | } | 97 | } | ||
95 | 98 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 139 | if (info->templateTypes.size() > info->templateTypeMap.size()) { | |||
137 | info->templateTypeMap.insert(templateParam, info->templateTypes.at(info->templateTypeMap.size())); | 140 | info->templateTypeMap.insert(templateParam, info->templateTypes.at(info->templateTypeMap.size())); | ||
138 | } | 141 | } | ||
139 | return CXChildVisit_Continue; | 142 | return CXChildVisit_Continue; | ||
140 | case CXCursor_CXXBaseSpecifier: | 143 | case CXCursor_CXXBaseSpecifier: | ||
141 | processBaseClass(cursor, parent, info->functions); | 144 | processBaseClass(cursor, parent, info->functions); | ||
142 | return CXChildVisit_Continue; | 145 | return CXChildVisit_Continue; | ||
143 | case CXCursor_CXXMethod: | 146 | case CXCursor_CXXMethod: | ||
144 | if (clang_CXXMethod_isVirtual(cursor)) { | 147 | if (clang_CXXMethod_isVirtual(cursor)) { | ||
145 | info->functions->append(processCXXMethod(cursor, info)); | 148 | auto methodInfo = processCXXMethod(cursor, info); | ||
149 | const int methodIndex = info->functions->indexOf(methodInfo); | ||||
150 | if (methodIndex == -1) { | ||||
151 | info->functions->append(methodInfo); | ||||
152 | } else { | ||||
153 | // update to subclass override | ||||
154 | auto& listedMethodInfo = (*info->functions)[methodIndex]; | ||||
155 | listedMethodInfo.isPureVirtual = methodInfo.isPureVirtual; | ||||
156 | } | ||||
146 | } | 157 | } | ||
147 | return CXChildVisit_Continue; | 158 | return CXChildVisit_Continue; | ||
148 | default: | 159 | default: | ||
149 | return CXChildVisit_Continue; | 160 | return CXChildVisit_Continue; | ||
150 | } | 161 | } | ||
151 | } | 162 | } | ||
152 | 163 | | |||
153 | CXChildVisitResult findBaseVisitor(CXCursor cursor, CXCursor parent, CXClientData data) | 164 | CXChildVisitResult findBaseVisitor(CXCursor cursor, CXCursor parent, CXClientData data) | ||
154 | { | 165 | { | ||
155 | auto cursorKind = clang_getCursorKind(cursor); | 166 | auto cursorKind = clang_getCursorKind(cursor); | ||
156 | if (cursorKind == CXCursor_CXXBaseSpecifier) { | 167 | if (cursorKind == CXCursor_CXXBaseSpecifier) { | ||
157 | processBaseClass(cursor, parent, static_cast<FunctionOverrideList*>(data)); | 168 | processBaseClass(cursor, parent, static_cast<FunctionOverrideList*>(data)); | ||
158 | } else if (cursorKind == CXCursor_CXXMethod) { | 169 | } else if (cursorKind == CXCursor_CXXMethod) { | ||
159 | if (!clang_CXXMethod_isVirtual(cursor)) { | 170 | if (!clang_CXXMethod_isVirtual(cursor)) { | ||
160 | return CXChildVisit_Continue; | 171 | return CXChildVisit_Continue; | ||
161 | } | 172 | } | ||
162 | 173 | | |||
163 | auto info = static_cast<FunctionOverrideList*>(data); | 174 | auto info = static_cast<FunctionOverrideList*>(data); | ||
164 | 175 | | |||
165 | OverrideInfo overrideInfo {info, {}, {}}; | 176 | OverrideInfo overrideInfo {info, {}, {}}; | ||
166 | auto methodInfo = processCXXMethod(cursor, &overrideInfo); | 177 | auto methodInfo = processCXXMethod(cursor, &overrideInfo); | ||
167 | if (info->contains(methodInfo)) { | 178 | // If this method is already implemented, remove it from the list of methods that can be overridden. | ||
168 | // This method is already implemented, remove it from the list of methods that can be overridden. | 179 | // If not implemented, this is a noop | ||
169 | info->remove(info->indexOf(methodInfo), 1); | 180 | info->removeOne(methodInfo); | ||
170 | } | | |||
171 | } | 181 | } | ||
172 | 182 | | |||
173 | return CXChildVisit_Continue; | 183 | return CXChildVisit_Continue; | ||
174 | } | 184 | } | ||
175 | 185 | | |||
176 | // TODO: make sure we only skip this in classes that actually inherit QObject | 186 | // TODO: make sure we only skip this in classes that actually inherit QObject | ||
177 | bool isQtMocFunction(CXCursor cursor) | 187 | bool isQtMocFunction(CXCursor cursor) | ||
178 | { | 188 | { | ||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |