Skip to content
Draft
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 @@ -57,14 +57,11 @@
import org.rascalmpl.vscode.lsp.uri.jsonrpc.VSCodeUriResolverClient;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.VSCodeUriResolverServer;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.VSCodeVFS;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.IOResult;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.ISourceLocationRequest;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.WriteFileRequest;
import org.rascalmpl.vscode.lsp.util.Lazy;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;

import io.usethesource.vallang.ISourceLocation;

public class FallbackResolver implements ISourceLocationInputOutput, ISourceLocationWatcher, ILogicalSourceLocationResolver {
Expand Down Expand Up @@ -100,14 +97,9 @@ private static VSCodeUriResolverClient getClient() throws IOException {
return result;
}

private static <T extends IOResult> T call(Function<VSCodeUriResolverServer, CompletableFuture<T>> target) throws IOException {
private static <T> T call(Function<VSCodeUriResolverServer, CompletableFuture<T>> target) throws IOException {
try {
var waitingForServer = target.apply(getServer());
var result = waitingForServer.get(5, TimeUnit.MINUTES);
if (result.getErrorCode() != 0) {
throw new IOException("" + result.getErrorCode() + ": " + result.getErrorMessage());
}
return result;
return target.apply(getServer()).get(5, TimeUnit.MINUTES);
}
catch (TimeoutException te) {
throw new IOException("VSCode took too long to reply, interruption to avoid deadlocks");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.BooleanResult;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.DirectoryListingResult;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.FileAttributesResult;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.IOResult;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.ISourceLocationRequest;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.NumberResult;
import org.rascalmpl.vscode.lsp.uri.jsonrpc.messages.ReadFileResult;
Expand Down Expand Up @@ -99,32 +98,32 @@ default CompletableFuture<BooleanResult> isWritable(ISourceLocationRequest req)


@JsonRequest("rascal/vfs/output/writeFile")
default CompletableFuture<IOResult> writeFile(WriteFileRequest req) {
default CompletableFuture<Void> writeFile(WriteFileRequest req) {
throw new UnsupportedOperationException();
}

@JsonRequest("rascal/vfs/output/mkDirectory")
default CompletableFuture<IOResult> mkDirectory(ISourceLocationRequest req) {
default CompletableFuture<Void> mkDirectory(ISourceLocationRequest req) {
throw new UnsupportedOperationException();
}

@JsonRequest("rascal/vfs/output/remove")
default CompletableFuture<IOResult> remove(ISourceLocationRequest req) {
default CompletableFuture<Void> remove(ISourceLocationRequest req) {
throw new UnsupportedOperationException();
}

@JsonRequest("rascal/vfs/output/rename")
default CompletableFuture<IOResult> rename(RenameRequest req) {
default CompletableFuture<Void> rename(RenameRequest req) {
throw new UnsupportedOperationException();
}

@JsonRequest("rascal/vfs/watcher/watch")
default CompletableFuture<IOResult> watch(WatchRequest req) {
default CompletableFuture<Void> watch(WatchRequest req) {
throw new UnsupportedOperationException();
}

@JsonRequest("rascal/vfs/watcher/unwatch")
default CompletableFuture<IOResult> unwatch(WatchRequest req) {
default CompletableFuture<Void> unwatch(WatchRequest req) {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;

public class BooleanResult extends IOResult {
private @Nullable Boolean result;
public class BooleanResult {
private Boolean result;

public BooleanResult(@NonNull int errorCode, @Nullable String errorMessage, @Nullable Boolean result) {
super(errorCode, errorMessage);
public BooleanResult(@NonNull int errorCode, String errorMessage, Boolean result) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error... params can be removed here

this.result = result;
}

public BooleanResult() {}

public @Nullable Boolean getResult() {
public Boolean getResult() {
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;

public class DirectoryListingResult extends IOResult {
public class DirectoryListingResult {

private String @Nullable[] entries;
private boolean @Nullable[] areDirectory;
private String[] entries;
private boolean[] areDirectory;

public DirectoryListingResult(int errorCode, @Nullable String errorMessage, String @Nullable[] entries, boolean @Nullable[] areDirectory) {
super(errorCode, errorMessage);
public DirectoryListingResult(String [] entries, boolean [] areDirectory) {
this.entries = entries;
this.areDirectory = areDirectory;
}

public DirectoryListingResult() {}

public String @Nullable[] getEntries() {
public String [] getEntries() {
return entries;
}

public boolean @Nullable[] getAreDirectory() {
public boolean [] getAreDirectory() {
return areDirectory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@
import java.util.Objects;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
import org.rascalmpl.uri.FileAttributes;

public class FileAttributesResult extends IOResult {
private @Nullable Boolean exists;
private @Nullable Integer type;
private @Nullable Long ctime;
private @Nullable Long mtime;
private @Nullable Integer size;
private @Nullable Integer permissions;
public class FileAttributesResult {
private Boolean exists;
private Integer type;
private Long ctime;
private Long mtime;
private Integer size;
private Integer permissions;

public FileAttributesResult(@NonNull int errorCode, @Nullable String errorMessage, @Nullable Boolean exists, @Nullable Integer type, @Nullable Long ctime, @Nullable Long mtime, @Nullable Integer size, @Nullable Integer permissions) {
super(errorCode, errorMessage);
public FileAttributesResult(Boolean exists, Integer type, Long ctime, Long mtime, Integer size, Integer permissions) {
this.exists = exists;
this.type = type;
this.ctime = ctime;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@

import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;

public class NumberResult extends IOResult {
private @Nullable Integer result;
public class NumberResult {
private Integer result;

public NumberResult(@NonNull int errorCode, @Nullable String errorMessage, @Nullable Integer result) {
super(errorCode, errorMessage);
public NumberResult(Integer result) {
this.result = result;
}

public NumberResult() {}

public @Nullable Integer getResult() {
public Integer getResult() {
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;

public class ReadFileResult extends IOResult {
public class ReadFileResult {

private @Nullable String contents;
private String contents;

public ReadFileResult(@NonNull int errorCode, @Nullable String errorMessage, @Nullable String contents) {
super(errorCode, errorMessage);
public ReadFileResult(String contents) {
this.contents = contents;
}

public ReadFileResult() {}

public @Nullable String getContents() {
public String getContents() {
return contents;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;

public class TimestampResult extends IOResult {
private @Nullable Long timestamp;
public class TimestampResult {
private Long timestamp;

public TimestampResult(int errorCode, @Nullable String errorMessage, @Nullable Long timestamp) {
super(errorCode, errorMessage);
public TimestampResult(Long timestamp) {
this.timestamp = timestamp;
}

public TimestampResult() {}

public @Nullable Long getTimestamp() {
public Long getTimestamp() {
return timestamp;
}

Expand Down
4 changes: 2 additions & 2 deletions rascal-vscode-extension/src/RascalTerminalLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class RascalTerminalLinkProvider implements TerminalLinkProvider<Extended
}

function translateRange(sloc: SourceLocation, td: vscode.TextDocument): vscode.Range | undefined {
if (sloc.beginLineColumn && sloc.endLineColumn) {
if (sloc.beginLineColumn !== undefined && sloc.endLineColumn !== undefined) {
const beginLine = sloc.beginLineColumn[0] - 1;
const endLine = sloc.endLineColumn[0] - 1;
return new vscode.Range(
Expand All @@ -102,7 +102,7 @@ function translateRange(sloc: SourceLocation, td: vscode.TextDocument): vscode.R
fixedColumn(td, endLine, sloc.endLineColumn[1]),
);
}
else if (sloc.offsetLength) {
else if (sloc.offsetLength !== undefined) {
const rangePositions = fixedOffsetLengthPositions(td, sloc.offsetLength[0], sloc.offsetLength[1]);
return new vscode.Range(
td.positionAt(rangePositions[0]),
Expand Down
Loading
Loading