diff --git a/dub.json b/dub.json index abbf4c9..25a46cc 100644 --- a/dub.json +++ b/dub.json @@ -4,6 +4,6 @@ "targetType": "executable", "license": "BSL-1.0", "dependencies": { - "libdparse": "~>0.5.0" + "libdparse": "~>0.7.0-alpha5" } } diff --git a/libdparse b/libdparse index 5da4616..a03641d 160000 --- a/libdparse +++ b/libdparse @@ -1 +1 @@ -Subproject commit 5da4616d11efb5b788baadc421f0444d4b4776dd +Subproject commit a03641db1bfa109d860eeb6e2ffdf3c81fd9e712 diff --git a/src/dfmt/editorconfig.d b/src/dfmt/editorconfig.d index cee0000..b4e5501 100644 --- a/src/dfmt/editorconfig.d +++ b/src/dfmt/editorconfig.d @@ -2,7 +2,7 @@ module dfmt.editorconfig; import std.regex : ctRegex; static if (__VERSION__ >= 2067) - import std.traits : FieldNameTuple; + public import std.traits : FieldNameTuple; else { private enum NameOf(alias T) = T.stringof; diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 1d34eff..93abaa3 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -7,6 +7,7 @@ module dfmt.formatter; import dparse.lexer; import dparse.parser; +import dparse.rollback_allocator; import dfmt.config; import dfmt.ast_info; import dfmt.indentation; @@ -25,8 +26,9 @@ void format(OutputRange)(string source_desc, ubyte[] buffer, OutputRange output, parseConfig.whitespaceBehavior = WhitespaceBehavior.skip; StringCache cache = StringCache(StringCache.defaultBucketCount); ASTInformation astInformation; + RollbackAllocator allocator; auto parseTokens = getTokensForParser(buffer, parseConfig, &cache); - auto mod = parseModule(parseTokens, source_desc); + auto mod = parseModule(parseTokens, source_desc, &allocator); auto visitor = new FormatVisitor(&astInformation); visitor.visit(mod); astInformation.cleanup(); diff --git a/src/dfmt/main.d b/src/dfmt/main.d index 53fedee..229b193 100644 --- a/src/dfmt/main.d +++ b/src/dfmt/main.d @@ -121,7 +121,7 @@ else // On Windows, set stdout to binary mode (needed for correct EOL writing) // See Phobos' stdio.File.rawWrite { - import std.stdio; + import std.stdio:fileno, _O_BINARY, setmode; immutable fd = fileno(output.getFP()); setmode(fd, _O_BINARY); @@ -148,7 +148,7 @@ else else break; } - dfmt.formatter.format("stdin", buffer, output.lockingTextWriter(), &config); + format("stdin", buffer, output.lockingTextWriter(), &config); } else { @@ -174,7 +174,7 @@ else f.rawRead(buffer); if (inplace) output = File(path, "wb"); - dfmt.formatter.format(path, buffer, output.lockingTextWriter(), &config); + format(path, buffer, output.lockingTextWriter(), &config); } } return 0;