Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -37,6 +36,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import javax.annotation.Nullable;
import javax.annotation.WillNotClose;
Expand Down Expand Up @@ -90,7 +90,7 @@ public PathFileObject(Location location, Path rootPath, Path relativePath) {
requireNonNull(relativePath, "relativePath");

if (!rootPath.isAbsolute()) {
throw new IllegalArgumentException("rootPath must be absolute");
throw new IllegalArgumentException("Expected rootPath to be absolute, but got " + rootPath);
}

this.location = location;
Expand All @@ -101,7 +101,7 @@ public PathFileObject(Location location, Path rootPath, Path relativePath) {
: relativePath;

fullPath = rootPath.resolve(relativePath);
name = relativePath.toString();
name = this.relativePath.toString();
uri = fullPath.toUri();
kind = FileUtils.pathToKind(relativePath);
}
Expand Down Expand Up @@ -138,8 +138,8 @@ public boolean equals(@Nullable Object other) {
* Get the class access level, where appropriate.
*
* <p>In this implementation, this class will always return {@code null}, since this
* information is not readily available without preloading the file in question and
* parsing it first.
* information is not readily available without preloading the file in question and parsing it
* first.
*
* <p>At the time of writing, the OpenJDK implementations of the JavaFileObject class
* do not provide an implementation for this method either.
Expand Down Expand Up @@ -227,8 +227,8 @@ public String getName() {
* Determine the class nesting kind, where appropriate.
*
* <p>In this implementation, this class will always return {@code null}, since this
* information is not readily available without preloading the file in question and
* parsing it first.
* information is not readily available without preloading the file in question and parsing it
* first.
*
* <p>At the time of writing, the OpenJDK implementations of the JavaFileObject class
* do not provide an implementation for this method either.
Expand All @@ -255,7 +255,7 @@ public Path getRelativePath() {
*
* @return the root path.
*/
public Path getRoot() {
public Path getRootPath() {
return rootPath;
}

Expand Down Expand Up @@ -295,8 +295,8 @@ public boolean isNameCompatible(String simpleName, Kind kind) {
* <p>The returned implementation will always be buffered.
*
* @return a buffered input stream.
* @throws FileNotFoundException if the file does not exist.
* @throws IOException if an IO error occurs.
* @throws NoSuchFileException if the file does not exist.
* @throws IOException if an IO error occurs.
*/
@Override
@WillNotClose
Expand All @@ -315,7 +315,6 @@ public BufferedInputStream openInputStream() throws IOException {
*
* <p>The returned implementation will always be buffered.
*
*
* @return a buffered output stream.
* @throws IOException if an IO error occurs.
*/
Expand All @@ -336,8 +335,8 @@ public BufferedOutputStream openOutputStream() throws IOException {
* @param ignoreEncodingErrors {@code true} to suppress encoding errors, or {@code false} to throw
* them to the caller.
* @return a buffered reader.
* @throws FileNotFoundException if the file does not exist.
* @throws IOException if an IO error occurs.
* @throws NoSuchFileException if the file does not exist.
* @throws IOException if an IO error occurs.
*/
@Override
@WillNotClose
Expand All @@ -351,7 +350,7 @@ public BufferedReader openReader(boolean ignoreEncodingErrors) throws IOExceptio
/**
* Open a writer to this file using the default charset (UTF-8).
*
* <p>This will Ccreate the file first if it does not already exist. If it does exist,
* <p>This will create the file first if it does not already exist. If it does exist,
* this will first overwrite the file and truncate it.
*
* <p>This input stream must be closed once finished with, otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
Expand Down Expand Up @@ -101,7 +101,7 @@ public ManagedDirectory copiedFromClassPath(ClassLoader classLoader, String reso
return uncheckedIo(() -> {
try (var input = classLoader.getResourceAsStream(resource)) {
if (input == null) {
throw new FileNotFoundException("classpath:" + resource);
throw new NoSuchFileException("classpath:" + resource);
}

return createFile(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,31 @@ public static Path somePath() {
return root.resolve("some-dummy-path");
}

/**
* Get some dummy absolute path.
*
* @return some dummy absolute path.
*/
public static Path someAbsolutePath() {
return somePath().resolve("some-absolute-path").toAbsolutePath();
}

/**
* Get some relative path.
*
* @return some dummy relative path.
*/
public static Path someRelativePath() {
var absolutePath = someAbsolutePath();
var relativePath = absolutePath;

for (var i = 0; i < someInt(1, 4); ++i) {
relativePath = absolutePath.resolve(someText());
}

return absolutePath.relativize(relativePath.resolve("some-relative-path"));
}

/**
* Get some module reference.
*
Expand Down Expand Up @@ -521,7 +546,6 @@ private TempFileSystem() {
.setAttributeViews("basic", "posix")
.setRoots("/")
.setWorkingDirectory("/")
.setPathEqualityUsesCanonicalForm(true)
.build();

fs = Jimfs.newFileSystem(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
import io.github.ascopes.jct.filemanagers.JctFileManagerFactory;
import io.github.ascopes.jct.filemanagers.LoggingMode;
import io.github.ascopes.jct.workspaces.Workspace;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystemException;
import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -511,7 +511,7 @@ void configureInvokesConfigurerOnTheCompiler() throws Throwable {
RuntimeException.class,
IOException.class,
FileSystemException.class,
FileNotFoundException.class,
NoSuchFileException.class,
UnsupportedEncodingException.class,
IndexOutOfBoundsException.class,
SecurityException.class,
Expand Down
Loading