| 1187 | } |
| 1188 | |
| 1189 | const char* ClangHelper::Autocomplete(const StringImpl& fileName, BfSourceClassifier::CharData* charData, int charLen, int cursorIdx) |
| 1190 | { |
| 1191 | gClangPerfManager.StartRecording(); |
| 1192 | |
| 1193 | //Sleep(500); |
| 1194 | |
| 1195 | BfLogClang("%d Clang Autocomplete %s\n", ::GetCurrentThreadId(), fileName.c_str()); |
| 1196 | |
| 1197 | static int gACCount = 0; |
| 1198 | gACCount++; |
| 1199 | |
| 1200 | gClangPerfManager.ZoneStart("GetTranslationUnit"); |
| 1201 | ClangTranslationUnit* clangTransUnit = NULL; |
| 1202 | /*if (headerFileName != NULL) |
| 1203 | { |
| 1204 | GetTranslationUnit(headerFileName, NULL, charData, charLen, NULL, 0, false, true); |
| 1205 | clangTransUnit = GetTranslationUnit(fileName, NULL, NULL, 0, NULL, 0, true); |
| 1206 | } |
| 1207 | else*/ |
| 1208 | { |
| 1209 | bool noReparse = false; |
| 1210 | clangTransUnit = GetTranslationUnit(fileName, NULL, charData, charLen, NULL, 0, false, false, noReparse); |
| 1211 | } |
| 1212 | //const char* cursorFileName = (headerFileName != NULL) ? headerFileName : fileName.c_str(); |
| 1213 | const char* cursorFileName = clangTransUnit->mTransFileName.c_str(); |
| 1214 | |
| 1215 | CXTranslationUnit transUnit = clangTransUnit->mTransUnit; |
| 1216 | gClangPerfManager.ZoneEnd(); |
| 1217 | if (transUnit == NULL) |
| 1218 | return NULL; |
| 1219 | |
| 1220 | gClangPerfManager.ZoneStart("Autocomplete"); |
| 1221 | |
| 1222 | String namespaceFind; |
| 1223 | String filter; |
| 1224 | int startIdx = std::max(0, cursorIdx - 1); |
| 1225 | bool isInvocation = false; |
| 1226 | int parenPos = -1; |
| 1227 | int lastCharIdx = -1; |
| 1228 | while (startIdx > 0) |
| 1229 | { |
| 1230 | char c = charData[startIdx].mChar; |
| 1231 | if (charData[startIdx].mDisplayTypeId == BfSourceElementType_Comment) |
| 1232 | { |
| 1233 | startIdx--; |
| 1234 | continue;; |
| 1235 | } |
| 1236 | |
| 1237 | if ((c == '(') && (filter.length() == 0)) |
| 1238 | { |
| 1239 | isInvocation = true; |
| 1240 | mInvokeString.clear(); |
| 1241 | startIdx--; |
| 1242 | cursorIdx--; |
| 1243 | parenPos = startIdx; |
| 1244 | |
| 1245 | while (startIdx > 0) |
| 1246 | { |
no test coverage detected