| 398 | } |
| 399 | |
| 400 | std::string clangimport::AstNode::getSpelling() const |
| 401 | { |
| 402 | if (nodeType == CompoundAssignOperator) { |
| 403 | std::size_t typeIndex = 1; |
| 404 | while (typeIndex < mExtTokens.size() && mExtTokens[typeIndex][0] != '\'') |
| 405 | typeIndex++; |
| 406 | // name is next quoted token |
| 407 | std::size_t nameIndex = typeIndex + 1; |
| 408 | while (nameIndex < mExtTokens.size() && mExtTokens[nameIndex][0] != '\'') |
| 409 | nameIndex++; |
| 410 | return (nameIndex < mExtTokens.size()) ? unquote(mExtTokens[nameIndex]) : ""; |
| 411 | } |
| 412 | |
| 413 | if (nodeType == UnaryExprOrTypeTraitExpr) { |
| 414 | std::size_t typeIndex = 1; |
| 415 | while (typeIndex < mExtTokens.size() && mExtTokens[typeIndex][0] != '\'') |
| 416 | typeIndex++; |
| 417 | const std::size_t nameIndex = typeIndex + 1; |
| 418 | return (nameIndex < mExtTokens.size()) ? unquote(mExtTokens[nameIndex]) : ""; |
| 419 | } |
| 420 | |
| 421 | int typeIndex = mExtTokens.size() - 1; |
| 422 | if (nodeType == FunctionDecl || nodeType == CXXConstructorDecl || nodeType == CXXMethodDecl) { |
| 423 | while (typeIndex >= 0 && mExtTokens[typeIndex][0] != '\'') |
| 424 | typeIndex--; |
| 425 | if (typeIndex <= 0) |
| 426 | return ""; |
| 427 | } |
| 428 | if (nodeType == DeclRefExpr) { |
| 429 | while (typeIndex > 0 && std::isalpha(mExtTokens[typeIndex][0])) |
| 430 | typeIndex--; |
| 431 | if (typeIndex <= 0) |
| 432 | return ""; |
| 433 | } |
| 434 | const std::string &str = mExtTokens[typeIndex - 1]; |
| 435 | if (startsWith(str,"col:")) |
| 436 | return ""; |
| 437 | if (startsWith(str,"<invalid")) |
| 438 | return ""; |
| 439 | if (nodeType == RecordDecl && str == "struct") |
| 440 | return ""; |
| 441 | return str; |
| 442 | } |
| 443 | |
| 444 | std::string clangimport::AstNode::getType(int index) const |
| 445 | { |
no test coverage detected