MCPcopy Create free account
hub / github.com/KDE/kdevelop / getBraceType

Method getBraceType

plugins/astyle/3rdparty/libastyle/ASFormatter.cpp:2967–3054  ·  view source on GitHub ↗

* check if the currently reached open-brace (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 brace. * * @return the type of the opened block. */

Source from the content-addressed store, hash-verified

2965 * @return the type of the opened block.
2966 */
2967BraceType ASFormatter::getBraceType()
2968{
2969 assert(currentChar == '{');
2970
2971 BraceType returnVal = NULL_TYPE;
2972
2973 if ((previousNonWSChar == '='
2974 || isBraceType(braceTypeStack->back(), ARRAY_TYPE))
2975 && previousCommandChar != ')'
2976 && !isNonParenHeader)
2977 returnVal = ARRAY_TYPE;
2978 else if (foundPreDefinitionHeader && previousCommandChar != ')')
2979 {
2980 returnVal = DEFINITION_TYPE;
2981 if (foundNamespaceHeader)
2982 returnVal = (BraceType)(returnVal | NAMESPACE_TYPE);
2983 else if (foundClassHeader)
2984 returnVal = (BraceType)(returnVal | CLASS_TYPE);
2985 else if (foundStructHeader)
2986 returnVal = (BraceType)(returnVal | STRUCT_TYPE);
2987 else if (foundInterfaceHeader)
2988 returnVal = (BraceType)(returnVal | INTERFACE_TYPE);
2989 }
2990 else if (isInEnum)
2991 {
2992 returnVal = (BraceType)(ARRAY_TYPE | ENUM_TYPE);
2993 }
2994 else
2995 {
2996 bool isCommandType = (foundPreCommandHeader
2997 || foundPreCommandMacro
2998 || (currentHeader != nullptr && isNonParenHeader)
2999 || (previousCommandChar == ')')
3000 || (previousCommandChar == ':' && !foundQuestionMark)
3001 || (previousCommandChar == ';')
3002 || ((previousCommandChar == '{' || previousCommandChar == '}')
3003 && isPreviousBraceBlockRelated)
3004 || (isInClassInitializer
3005 && ((!isLegalNameChar(previousNonWSChar) && previousNonWSChar != '(')
3006 || foundPreCommandHeader))
3007 || foundTrailingReturnType
3008 || isInObjCMethodDefinition
3009 || isInObjCInterface
3010 || isJavaStaticConstructor
3011 || isSharpDelegate);
3012
3013 // C# methods containing 'get', 'set', 'add', and 'remove' do NOT end with parens
3014 if (!isCommandType && isSharpStyle() && isNextWordSharpNonParenHeader(charNum + 1))
3015 {
3016 isCommandType = true;
3017 isSharpAccessor = true;
3018 }
3019
3020 if (isInExternC)
3021 returnVal = (isCommandType ? COMMAND_TYPE : EXTERN_TYPE);
3022 else
3023 returnVal = (isCommandType ? COMMAND_TYPE : ARRAY_TYPE);
3024 }

Callers

nothing calls this directly

Calls 2

backMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected