Skip to content

Commit

Permalink
Use new formatting of locations
Browse files Browse the repository at this point in the history
When a location is outputted a new format will now be used:
`<file>:<line>:<column>`.
  • Loading branch information
jacob-carlborg committed Mar 18, 2019
1 parent 9630dcf commit e23e073
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Added a flag, `--frontend-version`, which will print the version of the
frontend DLP is using
* Updated the D frontend DLP is using to DMD 2.085.0+ ([dd94ef465](https://github.com/dlang/dmd/commit/dd94ef465342d47a94f6c587638c49ce42f54590))
* New formatting of locations

### `leaf-funcions`

Expand Down
14 changes: 10 additions & 4 deletions source/dlp/driver/commands/leaf_functions.d
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ class LeafFunctions : Command!(Arguments)

static void printResult(LeafFunction leafFunction)
{
import std.string : fromStringz;
import std.stdio : writefln;
import std.stdio : writeln;

const location = leafFunction.location.toChars.fromStringz;
writefln("%s: %s", location, leafFunction.fullyQualifiedName);
writeln(leafFunction);
}
}

Expand All @@ -87,6 +85,14 @@ private struct LeafFunction

Loc location;
string fullyQualifiedName;

string toString() const pure
{
import std.format : format;
import dlp.driver.utility : toString;

return format!"%s: %s"(location.toString, fullyQualifiedName);
}
}

version (unittest):
Expand Down
14 changes: 14 additions & 0 deletions source/dlp/driver/utility.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module dlp.driver.utility;

import dmd.globals : Loc;

class MissingArgumentException : Exception
{
this(
Expand All @@ -22,3 +24,15 @@ class MissingArgumentException : Exception
super(msg, file, line, nextInChain);
}
}

string toString(const ref Loc location) pure
{
import std.format : format;
import std.string : fromStringz;

return format!"%s:%s:%s"(
location.filename.fromStringz,
location.linnum,
location.charnum
);
}

0 comments on commit e23e073

Please sign in to comment.