27{
31 AUTO_TRACE(
"scope={} fileScope={} text={} autoBreak={} external={} keepSpaces={} indentLevel={}",
32 scope?scope->
name():
"",fileScope?fileScope->
name():
"",
34 if (text.
empty())
return;
35
36
37 std::string_view txtStr=text.
view();
38 size_t strLen = txtStr.length();
39 if (strLen==0) return;
40
41 static const reg::Ex regExp(R
"((::)?\a[\w~!\\.:$"]*)");
44
45
46
47
48
49 size_t index=0;
50 size_t skipIndex=0;
51 size_t floatingIndex=0;
52 for (; it!=
end ; ++it)
53 {
54 const auto &
match = *it;
55 size_t newIndex =
match.position();
56 size_t matchLen =
match.length();
57 floatingIndex+=newIndex-skipIndex+matchLen;
58 if (newIndex>0 && txtStr.at(newIndex-1)=='0')
59 {
60 std::string_view part = txtStr.substr(skipIndex,newIndex+matchLen-skipIndex);
62 skipIndex=index=newIndex+matchLen;
63 continue;
64 }
65
66
67 bool insideString=false;
68 for (size_t i=index;i<newIndex;i++)
69 {
70 if (txtStr.at(i)=='"') insideString=!insideString;
71 if (txtStr.at(i)=='\\') i++;
72 }
73
74
77 {
78 std::string_view splitText = txtStr.substr(skipIndex,newIndex-skipIndex);
79 size_t splitLength = splitText.length();
80 size_t offset=1;
81 size_t i = splitText.find(',');
82 if (i==std::string::npos) { i=splitText.find('<'); if (i!=std::string::npos) offset=0; }
83 if (i==std::string::npos) { i=splitText.find("||"); if (i!=std::string::npos) offset=2; }
84 if (i==std::string::npos) { i=splitText.find("&&"); if (i!=std::string::npos) offset=2; }
85 if (i==std::string::npos) { i=splitText.find(">>"); if (i!=std::string::npos) offset=2; }
86 if (i==std::string::npos) i=splitText.find('>');
87 if (i==std::string::npos) i=splitText.find(' ');
88
89 if (i!=std::string::npos)
90 {
91 std::string_view part1 = splitText.substr(0,i+offset);
94 std::string_view part2 = splitText.substr(i+offset);
96 floatingIndex=splitLength-i-offset+matchLen;
97 }
98 else
99 {
100 out.writeString(splitText,options.
keepSpaces());
101 }
102 }
103 else
104 {
105
106 std::string_view part = txtStr.substr(skipIndex,newIndex-skipIndex);
108 }
109
110 std::string_view word=txtStr.substr(newIndex,matchLen);
112 bool found=false;
113
115 {
117 {
118 if (it1->name == matchWord)
119 {
121 found = true;
122 break;
123 }
124 }
125 }
126
127
128 if (!insideString)
129 {
133
134
136 cd=resolver.resolveClass(scope,matchWord);
137 const MemberDef *typeDef = resolver.getTypedef();
138 if (typeDef)
139 {
141 {
143 {
144
148 word);
149 found=true;
150 }
151 }
152 }
153 auto writeCompoundName = [&](const auto *cd_) {
154 if (options.
external() ? cd_->isLinkable() : cd_->isLinkableInProject())
155 {
156 if (self==
nullptr || cd_->qualifiedName()!=self->
qualifiedName())
157 {
158
159 out.writeLink(cd_->getReference(),cd_->getOutputFileBase(),cd_->anchor(),word);
160 found=true;
161 }
162 }
163 };
164
165 if (found)
166 {
167
168 }
170 {
171 writeCompoundName(cd);
172 }
173 else if ((cd=
getClass(matchWord+
"-p")))
174 {
175 writeCompoundName(cd);
176 }
178 {
179 writeCompoundName(cnd);
180 }
181 else if ((d=resolver.resolveSymbol(scope,matchWord)))
182 {
183 writeCompoundName(d);
184 }
185 else
186 {
187
188 }
189
190 size_t m = matchWord.
rfind(
"::");
192 if (scope &&
195 )
196 )
197 {
198 scopeName=scope->
name();
199 }
201 {
202 scopeName = matchWord.
left(m);
203 matchWord = matchWord.
mid(m+2);
204 }
205
206
207
208 if (!found)
209 {
212 if (result.
found && result.
md &&
214 )
215 {
216
217
218
219 if (result.
md!=self && (self==
nullptr || result.
md->
name()!=self->
name()))
220
221 {
222
223
224
225 if (!(scope &&
229 )
230 )
231 {
232
235 found=true;
236 }
237 }
238 }
239 }
240 }
241
242 if (!found)
243 {
245 }
246
247
248 skipIndex=index=newIndex+matchLen;
249 }
250
251 std::string_view lastPart = txtStr.substr(skipIndex);
252 out.writeString(lastPart,options.
keepSpaces());
253}
A abstract class representing of a compound symbol.
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
size_t rfind(char c, size_t pos=npos) const
DString mid(size_t index, size_t len=npos) const
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
std::string_view view() const
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
DString left(size_t len) const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
The common base class of all entity definitions found in the sources.
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual bool isLinkable() const =0
virtual DefType definitionType() const =0
virtual const DString & name() const =0
virtual bool isLinkableInProject() const =0
virtual DString qualifiedName() const =0
virtual DString anchor() const =0
virtual DString getReference() const =0
virtual Definition * getOuterScope() const =0
virtual DString getOutputFileBase() const =0
A model of a file symbol.
A model of a class/file/namespace member symbol.
virtual bool isVariable() const =0
ClassDef * getClass(const DString &n)
Class representing a regular expression.
Class to iterate through matches.
ConceptDef * getConcept(const DString &n)
DirIterator end(const DirIterator &) noexcept
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
bool match(std::string_view str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
const ArgumentList * argumentList() const
const Definition * scope() const
const Definition * self() const
size_t breakThreshold() const
const FileDef * fileScope() const
GetDefResult getDefs(const GetDefInput &input)