diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-12-23 09:25:22 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-12-23 09:25:22 +0000 |
| commit | 2a74651cf75dbb9db5c1b16a70433aee3ed5c01d (patch) | |
| tree | d52819763c9cd24888016ad2c15f6748e9fb0aa9 /src/main/java | |
| parent | c4cddcf037a57078452fe282b8527bffb4edde4e (diff) | |
Allow construction of file source with Path
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/ShedCompiler.java | 2 | ||||
| -rw-r--r-- | src/main/java/org/shedlang/compiler/sources/Sources.java | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/ShedCompiler.java b/src/main/java/org/shedlang/compiler/ShedCompiler.java index 45c189bf..0efbe1d5 100644 --- a/src/main/java/org/shedlang/compiler/ShedCompiler.java +++ b/src/main/java/org/shedlang/compiler/ShedCompiler.java @@ -131,7 +131,7 @@ public class ShedCompiler { var namespaceName = new NamespaceName(namespaceNameParts); var sourceContents = Files.readString(sourceFilePath, StandardCharsets.UTF_8); - var source = Sources.file(sourceFilePath.toString(), sourceContents); + var source = Sources.file(sourceFilePath, sourceContents); var tokens = tokenise(source); diff --git a/src/main/java/org/shedlang/compiler/sources/Sources.java b/src/main/java/org/shedlang/compiler/sources/Sources.java index 5fb6a3b0..9a556aff 100644 --- a/src/main/java/org/shedlang/compiler/sources/Sources.java +++ b/src/main/java/org/shedlang/compiler/sources/Sources.java @@ -1,9 +1,15 @@ package org.shedlang.compiler.sources; +import java.nio.file.Path; + public class Sources { public static Source NULL = NullSource.INSTANCE; public static Source RUNTIME = RuntimeSource.INSTANCE; + public static Source file(Path path, String contents) { + return FileFragmentSource.file(path.toString(), contents); + } + public static Source file(String filename, String contents) { return FileFragmentSource.file(filename, contents); } |
