* check if the currently reached open-bracket (i.e. '{') * opens a: * - a definition type block (such as a class or namespace), * - a command block (such as a method block) * - a static array * this method takes for granted that the current character * is an opening bracket. * * @return the type of the opened block. */
| 2443 | * @return the type of the opened block. |
| 2444 | */ |
| 2445 | BracketType ASFormatter::getBracketType() |
| 2446 | { |
| 2447 | assert(currentChar == '{'); |
| 2448 | |
| 2449 | BracketType returnVal; |
| 2450 | |
| 2451 | if ((previousNonWSChar == '=' |
| 2452 | || isBracketType(bracketTypeStack->back(), ARRAY_TYPE)) |
| 2453 | && previousCommandChar != ')') |
| 2454 | returnVal = ARRAY_TYPE; |
| 2455 | else if (foundPreDefinitionHeader && previousCommandChar != ')') |
| 2456 | { |
| 2457 | returnVal = DEFINITION_TYPE; |
| 2458 | if (foundNamespaceHeader) |
| 2459 | returnVal = (BracketType)(returnVal | NAMESPACE_TYPE); |
| 2460 | else if (foundClassHeader) |
| 2461 | returnVal = (BracketType)(returnVal | CLASS_TYPE); |
| 2462 | else if (foundStructHeader) |
| 2463 | returnVal = (BracketType)(returnVal | STRUCT_TYPE); |
| 2464 | else if (foundInterfaceHeader) |
| 2465 | returnVal = (BracketType)(returnVal | INTERFACE_TYPE); |
| 2466 | } |
| 2467 | else |
| 2468 | { |
| 2469 | bool isCommandType = (foundPreCommandHeader |
| 2470 | || foundPreCommandMacro |
| 2471 | || (currentHeader != NULL && isNonParenHeader) |
| 2472 | || (previousCommandChar == ')') |
| 2473 | || (previousCommandChar == ':' && !foundQuestionMark) |
| 2474 | || (previousCommandChar == ';') |
| 2475 | || ((previousCommandChar == '{' || previousCommandChar == '}') |
| 2476 | && isPreviousBracketBlockRelated) |
| 2477 | || isInObjCMethodDefinition |
| 2478 | || isInObjCInterface |
| 2479 | || isJavaStaticConstructor |
| 2480 | || isSharpDelegate); |
| 2481 | |
| 2482 | // C# methods containing 'get', 'set', 'add', and 'remove' do NOT end with parens |
| 2483 | if (!isCommandType && isSharpStyle() && isNextWordSharpNonParenHeader(charNum + 1)) |
| 2484 | { |
| 2485 | isCommandType = true; |
| 2486 | isSharpAccessor = true; |
| 2487 | } |
| 2488 | |
| 2489 | if (isInExternC) |
| 2490 | returnVal = (isCommandType ? COMMAND_TYPE : EXTERN_TYPE); |
| 2491 | else |
| 2492 | returnVal = (isCommandType ? COMMAND_TYPE : ARRAY_TYPE); |
| 2493 | } |
| 2494 | |
| 2495 | int foundOneLineBlock = isOneLineBlockReached(currentLine, charNum); |
| 2496 | // this assumes each array definition is on a single line |
| 2497 | // (foundOneLineBlock == 2) is a one line block followed by a comma |
| 2498 | if (foundOneLineBlock == 2 && returnVal == COMMAND_TYPE) |
| 2499 | returnVal = ARRAY_TYPE; |
| 2500 | |
| 2501 | if (foundOneLineBlock > 0) // found one line block |
| 2502 | returnVal = (BracketType)(returnVal | SINGLE_LINE_TYPE); |
nothing calls this directly
no outgoing calls
no test coverage detected