MCPcopy Create free account
hub / github.com/KDE/kdiff3 / processChar

Method processChar

src/CommentParser.cpp:19–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include <QString>
18
19void DefaultCommentParser::processChar(const QString &line, const QChar &inChar)
20{
21 if(!bIsEscaped)
22 {
23 switch(inChar.unicode())
24 {
25 case '\\':
26 if(bInString)
27 bIsEscaped = true;
28 break;
29 case '\'':
30 case '"':
31 if(!inComment())
32 {
33 if(!bInString)
34 {
35 bInString = true;
36 mStartChar = inChar;
37 }
38 else if(mStartChar == inChar)
39 {
40 bInString = false;
41 }
42 }
43 break;
44 case '/':
45 if(bInString)
46 break;
47
48 if(!inComment() && mLastChar == '/')
49 {
50 mCommentType = singleLine;
51 mIsPureComment = mIsCommentOrWhite = line.startsWith(u8"//");
52 lastComment.startOffset = offset - 1;
53 if(lastComment.startOffset != 0) //whitespace at begining
54 {
55 mIsPureComment = false;
56 }
57 }
58 else if(mLastChar == '*' && mCommentType == multiLine)
59 {
60 //ending multi-line comment
61 mCommentType = none;
62 lastComment.endOffset = offset + 1; //include last char in offset
63 comments.push_back(lastComment);
64 if(!isFirstLine)
65 mIsPureComment = mIsCommentOrWhite = line.endsWith(u8"*/") ? true : mIsCommentOrWhite;
66 }
67 break;
68 case '*':
69 if(bInString)
70 break;
71
72 if(mLastChar == '/' && !inComment())
73 {
74 mCommentType = multiLine;
75 mIsPureComment = mIsCommentOrWhite = line.startsWith(u8"/*") ? true : mIsCommentOrWhite;
76 isFirstLine = true;

Callers 1

stringTestMethod · 0.80

Calls 1

push_backMethod · 0.80

Tested by

no test coverage detected