check if a specific line position contains a header.
| 1225 | |
| 1226 | // check if a specific line position contains a header. |
| 1227 | const string* ASBeautifier::findHeader(const string &line, int i, |
| 1228 | const vector<const string*>* possibleHeaders) const |
| 1229 | { |
| 1230 | assert(isCharPotentialHeader(line, i)); |
| 1231 | // check the word |
| 1232 | size_t maxHeaders = possibleHeaders->size(); |
| 1233 | for (size_t p = 0; p < maxHeaders; p++) |
| 1234 | { |
| 1235 | const string* header = (*possibleHeaders)[p]; |
| 1236 | const size_t wordEnd = i + header->length(); |
| 1237 | if (wordEnd > line.length()) |
| 1238 | continue; |
| 1239 | int result = (line.compare(i, header->length(), *header)); |
| 1240 | if (result > 0) |
| 1241 | continue; |
| 1242 | if (result < 0) |
| 1243 | break; |
| 1244 | // check that this is not part of a longer word |
| 1245 | if (wordEnd == line.length()) |
| 1246 | return header; |
| 1247 | if (isLegalNameChar(line[wordEnd])) |
| 1248 | continue; |
| 1249 | const char peekChar = peekNextChar(line, wordEnd - 1); |
| 1250 | // is not a header if part of a definition |
| 1251 | if (peekChar == ',' || peekChar == ')') |
| 1252 | break; |
| 1253 | // the following accessor definitions are NOT headers |
| 1254 | // goto default; is NOT a header |
| 1255 | // default(int) keyword in C# is NOT a header |
| 1256 | else if ((header == &AS_GET || header == &AS_SET || header == &AS_DEFAULT) |
| 1257 | && (peekChar == ';' || peekChar == '(' || peekChar == '=')) |
| 1258 | break; |
| 1259 | return header; |
| 1260 | } |
| 1261 | return NULL; |
| 1262 | } |
| 1263 | |
| 1264 | // check if a specific line position contains an operator. |
| 1265 | const string* ASBeautifier::findOperator(const string &line, int i, |
nothing calls this directly
no outgoing calls
no test coverage detected