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

Method isBeforeAnyLineEndComment

astyle/src/ASFormatter.cpp:1979–2001  ·  view source on GitHub ↗

* check if current placement is before a comment or line-comment * if a block comment it must be at the end of the line * * @return is before a comment or line-comment. */

Source from the content-addressed store, hash-verified

1977 * @return is before a comment or line-comment.
1978 */
1979bool ASFormatter::isBeforeAnyLineEndComment(int startPos) const
1980{
1981 bool foundLineEndComment = false;
1982 size_t peekNum = currentLine.find_first_not_of(" \t", startPos + 1);
1983
1984 if (peekNum != string::npos)
1985 {
1986 if (currentLine.compare(peekNum, 2, "//") == 0)
1987 foundLineEndComment = true;
1988 else if (currentLine.compare(peekNum, 2, "/*") == 0)
1989 {
1990 // comment must be closed on this line with nothing after it
1991 size_t endNum = currentLine.find("*/", peekNum + 2);
1992 if (endNum != string::npos)
1993 {
1994 size_t nextChar = currentLine.find_first_not_of(" \t", endNum + 2);
1995 if (nextChar == string::npos)
1996 foundLineEndComment = true;
1997 }
1998 }
1999 }
2000 return foundLineEndComment;
2001}
2002
2003/**
2004 * check if current placement is before a comment followed by a line-comment

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected