Skip to content

Commit af75600

Browse files
committed
Add lines to json LOC
Currently LOC outputted from graphql_ast_to_json() only contains columns. The PHP extension for libgraphqlparser is using graphql_ast_to_json() to reduce the amount of c code required to integrate with PHP. The outcome being that I have no way of getting to the line information. I suppose I could write a better PHP extension, but wondering if you guys would be amenable to simply add the information to the json blob?
1 parent 8fd351b commit af75600

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

JsonVisitor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ void JsonVisitor::NodeFieldPrinter::printLocation(
8989
std::ostringstream &out,
9090
const yy::location &location)
9191
{
92-
out << "{\"start\":" << location.begin.column
93-
<< ",\"end\":" << location.end.column << '}';
92+
out << "{\"start\": {\"line\": " << location.begin.line
93+
<< ",\"column\":" << location.begin.column
94+
<< "}, \"end\": {\"line\":" << location.end.line
95+
<< ",\"column\":" << location.end.column
96+
<< "}}";
9497
}
9598

9699
void JsonVisitor::NodeFieldPrinter::printChildList(

0 commit comments

Comments
 (0)