Skip to content

Commit c7219fa

Browse files
committed
feat(Corpus): location objects include column number
1 parent c8816a5 commit c7219fa

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

include/mrdocs/Metadata/Info/Location.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ struct MRDOCS_DECL
3939
*/
4040
unsigned LineNumber = 0;
4141

42+
/** Column number within the line
43+
*/
44+
unsigned ColumnNumber = 0;
45+
4246
/** Whether this location has documentation.
4347
*/
4448
bool Documented = false;
@@ -51,11 +55,13 @@ struct MRDOCS_DECL
5155
std::string_view const short_path = {},
5256
std::string_view const source_path = {},
5357
unsigned const line = 0,
58+
unsigned const col = 0,
5459
bool const documented = false)
5560
: FullPath(full_path)
5661
, ShortPath(short_path)
5762
, SourcePath(source_path)
5863
, LineNumber(line)
64+
, ColumnNumber(col)
5965
, Documented(documented)
6066
{
6167
}

src/lib/AST/ASTVisitor.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,21 +580,28 @@ populate(
580580
bool const definition,
581581
bool const documented)
582582
{
583-
unsigned line = source_.getPresumedLoc(
584-
loc, false).getLine();
583+
auto presLoc = source_.getPresumedLoc(loc, false);
584+
unsigned line = presLoc.getLine();
585+
unsigned col = presLoc.getColumn();
585586
FileInfo* file = findFileInfo(loc);
586587

587588
// No file is not an error, it just typically means it has been generated
588589
// in the virtual filesystem.
589590
MRDOCS_CHECK_OR(file);
590591

592+
Location Loc(file->full_path,
593+
file->short_path,
594+
file->source_path,
595+
line,
596+
col,
597+
documented);
591598
if (definition)
592599
{
593600
if (I.DefLoc)
594601
{
595602
return;
596603
}
597-
I.DefLoc.emplace(file->full_path, file->short_path, file->source_path, line, documented);
604+
I.DefLoc = std::move(Loc);
598605
}
599606
else
600607
{
@@ -609,7 +616,7 @@ populate(
609616
{
610617
return;
611618
}
612-
I.Loc.emplace_back(file->full_path, file->short_path, file->source_path, line, documented);
619+
I.Loc.push_back(std::move(Loc));
613620
}
614621
}
615622

src/lib/Metadata/Source.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ tag_invoke(
111111
io.map("shortPath", loc.ShortPath);
112112
io.map("sourcePath", loc.SourcePath);
113113
io.map("line", loc.LineNumber);
114+
io.map("column", loc.ColumnNumber);
114115
io.map("documented", loc.Documented);
115116
}
116117

0 commit comments

Comments
 (0)