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
1 change: 0 additions & 1 deletion src/org/rascalmpl/uri/URIResolverRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private URIResolverRegistry() {
loadServices();
}


/**
* Use with care! This (expensive) reinitialization method clears all caches of all resolvers by
* reloading them from scratch.
Expand Down
4 changes: 0 additions & 4 deletions src/org/rascalmpl/uri/URIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,4 @@ else if (index != -1) {

return URIUtil.changePath(location, path);
}

public static URI invalidURI() {
return rootScheme("invalid");
}
}
2 changes: 2 additions & 0 deletions src/org/rascalmpl/uri/resolvers.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ org.rascalmpl.uri.file.CurrentWorkingDriveResolver
org.rascalmpl.uri.file.UNCResolver
org.rascalmpl.uri.file.SystemPathURIResolver
org.rascalmpl.uri.libraries.MemoryResolver
org.rascalmpl.uri.unsupported.UnknownURIResolver
org.rascalmpl.uri.unsupported.LibraryURIResolver

7 changes: 7 additions & 0 deletions src/org/rascalmpl/uri/unsupported/LibraryURIResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.rascalmpl.uri.unsupported;

public class LibraryURIResolver extends UnsupportedURIResolver {
public LibraryURIResolver() {
super("lib", "The lib scheme has been removed, please rewrite to mvn scheme or use getResource");
}
}
9 changes: 9 additions & 0 deletions src/org/rascalmpl/uri/unsupported/UnknownURIResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.rascalmpl.uri.unsupported;

import org.rascalmpl.uri.URIUtil;

public class UnknownURIResolver extends UnsupportedURIResolver {
public UnknownURIResolver() {
super(URIUtil.unknownLocation().getScheme(), "The unknown scheme cannot be read/written to, it indicates someone didn't know the location");
}
}
125 changes: 125 additions & 0 deletions src/org/rascalmpl/uri/unsupported/UnsupportedURIResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package org.rascalmpl.uri.unsupported;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.function.Consumer;

import org.rascalmpl.uri.FileAttributes;
import org.rascalmpl.uri.ISourceLocationInputOutput;
import org.rascalmpl.uri.ISourceLocationWatcher;

import io.usethesource.vallang.ISourceLocation;

abstract class UnsupportedURIResolver implements ISourceLocationInputOutput, ISourceLocationWatcher {

private final String scheme;
private final String message;

protected UnsupportedURIResolver(String scheme, String message) {
this.scheme = scheme;
this.message = message;
}

private IOException buildException() {
return new IOException(message);
}

@Override
public InputStream getInputStream(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public boolean exists(ISourceLocation uri) {
return false;
}

@Override
public long lastModified(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public long size(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public boolean isDirectory(ISourceLocation uri) {
return false;
}

@Override
public boolean isFile(ISourceLocation uri) {
return false;
}

@Override
public boolean isReadable(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public String[] list(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public String scheme() {
return this.scheme;
}

@Override
public boolean supportsHost() {
return false;
}

@Override
public FileAttributes stat(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public OutputStream getOutputStream(ISourceLocation uri, boolean append) throws IOException {
throw buildException();
}

@Override
public void mkDirectory(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public void remove(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public void setLastModified(ISourceLocation uri, long timestamp) throws IOException {
throw buildException();
}

@Override
public boolean isWritable(ISourceLocation uri) throws IOException {
throw buildException();
}

@Override
public void watch(ISourceLocation root, Consumer<ISourceLocationChanged> watcher, boolean recursive)
throws IOException {
throw buildException();
}

@Override
public void unwatch(ISourceLocation root, Consumer<ISourceLocationChanged> watcher, boolean recursive)
throws IOException {
throw buildException();
}

@Override
public boolean supportsRecursiveWatch() {
return false;
}

}
2 changes: 1 addition & 1 deletion test/org/rascalmpl/test/repl/JlineParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private ParsedLine completeParser(String input) {
}

private ParsedLine completeParser(String input, int cursor) {
var parser = new RascalLineParser(l -> { throw new ParseError("rascal parser not supported in the test yet", URIUtil.invalidURI(), 0, 0, 0, 0, 0, 0); });
var parser = new RascalLineParser(l -> { throw new ParseError("rascal parser not supported in the test yet", URIUtil.unknownLocation().getURI(), 0, 0, 0, 0, 0, 0); });

return parser.parse(input, cursor, ParseContext.COMPLETE);
}
Expand Down
Loading