MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / isOneLineBlockReached

Method isOneLineBlockReached

astyle/src/ASFormatter.cpp:2917–2994  ·  view source on GitHub ↗

* check if a one-line bracket has been reached, * i.e. if the currently reached '{' character is closed * with a complimentary '}' elsewhere on the current line, *. * @return 0 = one-line bracket has not been reached. * 1 = one-line bracket has been reached. * 2 = one-line bracket has been reached and is followed by a comma. */

Source from the content-addressed store, hash-verified

2915 * 2 = one-line bracket has been reached and is followed by a comma.
2916 */
2917int ASFormatter::isOneLineBlockReached(string &line, int startChar) const
2918{
2919 assert(line[startChar] == '{');
2920
2921 bool isInComment_ = false;
2922 bool isInQuote_ = false;
2923 int bracketCount = 1;
2924 int lineLength = line.length();
2925 char quoteChar_ = ' ';
2926 char ch = ' ';
2927 char prevCh = ' ';
2928
2929 for (int i = startChar + 1; i < lineLength; ++i)
2930 {
2931 ch = line[i];
2932
2933 if (isInComment_)
2934 {
2935 if (line.compare(i, 2, "*/") == 0)
2936 {
2937 isInComment_ = false;
2938 ++i;
2939 }
2940 continue;
2941 }
2942
2943 if (ch == '\\')
2944 {
2945 ++i;
2946 continue;
2947 }
2948
2949 if (isInQuote_)
2950 {
2951 if (ch == quoteChar_)
2952 isInQuote_ = false;
2953 continue;
2954 }
2955
2956 if (ch == '"' || ch == '\'')
2957 {
2958 isInQuote_ = true;
2959 quoteChar_ = ch;
2960 continue;
2961 }
2962
2963 if (line.compare(i, 2, "//") == 0)
2964 break;
2965
2966 if (line.compare(i, 2, "/*") == 0)
2967 {
2968 isInComment_ = true;
2969 ++i;
2970 continue;
2971 }
2972
2973 if (ch == '{')
2974 ++bracketCount;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected