30{
34 AUTO_TRACE(
"scope={} fileScope={} text={} autoBreak={} external={} keepSpaces={} indentLevel={}",
35 scope?scope->
name():
"",fileScope?fileScope->
name():
"",
37 if (text.
empty())
return;
38
39
40 std::string_view txtStr=text.
view();
41 size_t strLen = txtStr.length();
42 if (strLen==0) return;
43
44 static const reg::Ex regExp(R
"((::)?\a[\w~!\\.:$"]*)");
47
48
49
50
51
52 size_t index=0;
53 size_t skipIndex=0;
54 size_t floatingIndex=0;
55 for (; it!=
end ; ++it)
56 {
57 const auto &
match = *it;
58 size_t newIndex =
match.position();
59 size_t matchLen =
match.length();
60 floatingIndex+=newIndex-skipIndex+matchLen;
61 if (newIndex>0 && txtStr.at(newIndex-1)=='0')
62 {
63 std::string_view part = txtStr.substr(skipIndex,newIndex+matchLen-skipIndex);
65 skipIndex=index=newIndex+matchLen;
66 continue;
67 }
68
69
70 bool insideString=false;
71 for (size_t i=index;i<newIndex;i++)
72 {
73 if (txtStr.at(i)=='"') insideString=!insideString;
74 if (txtStr.at(i)=='\\') i++;
75 }
76
77
80 {
81 std::string_view splitText = txtStr.substr(skipIndex,newIndex-skipIndex);
82 size_t splitLength = splitText.length();
83 size_t offset=1;
84 size_t i = splitText.find(',');
85 if (i==std::string::npos) { i=splitText.find('<'); if (i!=std::string::npos) offset=0; }
86 if (i==std::string::npos) { i=splitText.find("||"); if (i!=std::string::npos) offset=2; }
87 if (i==std::string::npos) { i=splitText.find("&&"); if (i!=std::string::npos) offset=2; }
88 if (i==std::string::npos) { i=splitText.find(">>"); if (i!=std::string::npos) offset=2; }
89 if (i==std::string::npos) i=splitText.find('>');
90 if (i==std::string::npos) i=splitText.find(' ');
91
92 if (i!=std::string::npos)
93 {
94 std::string_view part1 = splitText.substr(0,i+offset);
97 std::string_view part2 = splitText.substr(i+offset);
99 floatingIndex=splitLength-i-offset+matchLen;
100 }
101 else
102 {
104 }
105 }
106 else
107 {
108
109 std::string_view part = txtStr.substr(skipIndex,newIndex-skipIndex);
111 }
112
113 std::string_view word=txtStr.substr(newIndex,matchLen);
115 bool found=false;
116
118 {
120 {
121 if (it1->name == matchWord)
122 {
124 found = true;
125 break;
126 }
127 }
128 }
129
130
131 if (!insideString)
132 {
136
137
139 cd=resolver.resolveClass(scope,matchWord);
140 const MemberDef *typeDef = resolver.getTypedef();
141 if (typeDef)
142 {
144 {
146 {
147
151 word);
152 found=true;
153 }
154 }
155 }
156 auto writeCompoundName = [&](const auto *cd_) {
157 if (options.
external() ? cd_->isLinkable() : cd_->isLinkableInProject())
158 {
159 if (self==
nullptr || cd_->qualifiedName()!=self->
qualifiedName())
160 {
161
162 out.
writeLink(cd_->getReference(),cd_->getOutputFileBase(),cd_->anchor(),word);
163 found=true;
164 }
165 }
166 };
167
168 if (found)
169 {
170
171 }
173 {
174 writeCompoundName(cd);
175 }
176 else if ((cd=
getClass(matchWord+
"-p")))
177 {
178 writeCompoundName(cd);
179 }
181 {
182 writeCompoundName(cnd);
183 }
184 else if ((d=resolver.resolveSymbol(scope,matchWord)))
185 {
186 writeCompoundName(d);
187 }
188 else
189 {
190
191 }
192
193 size_t m = matchWord.
rfind(
"::");
195 if (scope &&
198 )
199 )
200 {
201 scopeName=scope->
name();
202 }
204 {
205 scopeName = matchWord.
left(m);
206 matchWord = matchWord.
mid(m+2);
207 }
208
209
210
211 if (!found)
212 {
215 if (result.
found && result.
md &&
217 )
218 {
219
220
221
222 if (result.
md!=self && (self==
nullptr || result.
md->
name()!=self->
name()))
223
224 {
225
226
227
228 if (!(scope &&
232 )
233 )
234 {
235
238 found=true;
239 }
240 }
241 }
242 }
243 }
244
245 if (!found)
246 {
248 }
249
250
251 skipIndex=index=newIndex+matchLen;
252 }
253
254 std::string_view lastPart = txtStr.substr(skipIndex);
256}
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
virtual void writeString(std::string_view, bool) const =0
virtual void writeBreak(int indent) const =0
virtual void writeLink(const DString &extRef, const DString &file, const DString &anchor, std::string_view text) 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)