* format a line comment opener * the line comment opener will be appended to the current formattedLine or a new formattedLine as necessary * the calling function should have a continue statement after calling this method */
| 4906 | * the calling function should have a continue statement after calling this method |
| 4907 | */ |
| 4908 | void ASFormatter::formatLineCommentOpener() |
| 4909 | { |
| 4910 | assert(isSequenceReached("//")); |
| 4911 | |
| 4912 | if ((int)currentLine.length() > charNum + 2 |
| 4913 | && currentLine[charNum + 2] == '\xf2') // check for windows line marker |
| 4914 | isAppendPostBlockEmptyLineRequested = false; |
| 4915 | |
| 4916 | isInLineComment = true; |
| 4917 | isCharImmediatelyPostComment = false; |
| 4918 | if (previousNonWSChar == '}') |
| 4919 | resetEndOfStatement(); |
| 4920 | |
| 4921 | // Check for a following header. |
| 4922 | // For speed do not check multiple comment lines more than once. |
| 4923 | // For speed do not check shouldBreakBlocks if previous line is empty, a comment, or a '{'. |
| 4924 | const string* followingHeader = NULL; |
| 4925 | if ((lineIsLineCommentOnly |
| 4926 | && !isImmediatelyPostCommentOnly |
| 4927 | && isBracketType(bracketTypeStack->back(), COMMAND_TYPE)) |
| 4928 | && (shouldBreakElseIfs |
| 4929 | || isInSwitchStatement() |
| 4930 | || (shouldBreakBlocks |
| 4931 | && !isImmediatelyPostEmptyLine |
| 4932 | && previousCommandChar != '{'))) |
| 4933 | followingHeader = checkForHeaderFollowingComment(currentLine.substr(charNum)); |
| 4934 | |
| 4935 | // do not indent if in column 1 or 2 |
| 4936 | if (!shouldIndentCol1Comments && !lineCommentNoIndent) |
| 4937 | { |
| 4938 | if (charNum == 0) |
| 4939 | lineCommentNoIndent = true; |
| 4940 | else if (charNum == 1 && currentLine[0] == ' ') |
| 4941 | lineCommentNoIndent = true; |
| 4942 | } |
| 4943 | // move comment if spaces were added or deleted |
| 4944 | if (lineCommentNoIndent == false && spacePadNum != 0 && !isInLineBreak) |
| 4945 | adjustComments(); |
| 4946 | formattedLineCommentNum = formattedLine.length(); |
| 4947 | |
| 4948 | // must be done BEFORE appendSequence |
| 4949 | // check for run-in statement |
| 4950 | if (previousCommandChar == '{' |
| 4951 | && !isImmediatelyPostComment |
| 4952 | && !isImmediatelyPostLineComment) |
| 4953 | { |
| 4954 | if (bracketFormatMode == NONE_MODE) |
| 4955 | { |
| 4956 | if (currentLineBeginsWithBracket) |
| 4957 | formatRunIn(); |
| 4958 | } |
| 4959 | else if (bracketFormatMode == RUN_IN_MODE) |
| 4960 | { |
| 4961 | if (!lineCommentNoIndent) |
| 4962 | formatRunIn(); |
| 4963 | else |
| 4964 | isInLineBreak = true; |
| 4965 | } |
nothing calls this directly
no outgoing calls
no test coverage detected