Skip to content

Commit

Permalink
removed superfluous public modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 5, 2024
1 parent 7b5cb57 commit daf8d28
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions src/org/rascalmpl/library/util/IDEServices.rsc
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
module util::IDEServices

extend analysis::diff::edits::TextEdits;
import analysis::diff::edits::ExecuteTextEdits;
extend Content;
extend Message;

@synopsis{Open a browser for a given location.}
@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
java void browse(loc uri, str title = "<uri>", int viewColumn=1);


@synopsis{Open an editor for file at a given location.}
@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
java void edit(loc uri);


@synopsis{Let the IDE apply a list of document edits.}
@description{
Asks the IDE to apply document edits as defined in the standard library module
Expand All @@ -26,24 +25,23 @@ Typically a call to this IDE service method is included in the implementation
of refactoring and quick-fix features of the language service protocol.
}
@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
public java void applyDocumentsEdits(list[DocumentEdit] edits);

java void applyDocumentsEdits(list[DocumentEdit] edits);

@synopsis{Asks the IDE to show a "browser window" with the given interactive Content.}
@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
public java void showInteractiveContent(Content content, str title=content.title, int viewColumn=content.viewColumn);
java void showInteractiveContent(Content content, str title=content.title, int viewColumn=content.viewColumn);

@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
public java void showMessage(Message message);
java void showMessage(Message message);

@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
public java void logMessage(Message message);
java void logMessage(Message message);

@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
public java void registerDiagnostics(list[Message] messages);
java void registerDiagnostics(list[Message] messages);

@javaClass{org.rascalmpl.library.util.IDEServicesLibrary}
public java void unregisterDiagnostics(list[loc] resources);
java void unregisterDiagnostics(list[loc] resources);

@synopsis{Fixes are an extension to error messages that allow for interactive code fixes in the IDE.}
@description{
Expand All @@ -69,3 +67,35 @@ via a ((CodeAction)), and then have it executed by the respective language serve
}
data Command(str title="")
= noop();

@synopsis{Utility function for testing code actions.}
@benefits{
* test code actions outside of the IDE context, for example while running unit tests.
* this function is synchronous and blocks until the IO is finished. After running it you
can test for changed file contents without waiting, in most cases (see pitfalls).
}
@description{
* `action` is the action to execute
* `evaluator` is used to evaluate action.command if it is present.
* the return value is the return value of the evaluated command, or `true` if no command is present.
}
@pitfalls{
* ((CodeAction))s may use the other features of ((util::IDEServices)), and thus start editors or browsers as side-effects.
* ((CodeAction))s code actions with ((DocumentEdit))s will write to disk and change the original files.
* ((IDEServices-Command))s can only be executed by a parametrized command `evaluator``; if you do not provide it then
this test function will throw ((CallFailed)) exceptions for every unsupported ((IDEServices-Command)).
* ((Command))s can start asynchronous effects by calling non-blocking functions that schedule other effects.
An axamples is the starting and running of web ((Content)) via ((showInteractiveContent)). Testing properties of the
rendered content will require the use of asynchronous testing frameworks, like Selenium.
}
value testCodeAction(CodeAction action, value (Command _) evaluator = value (noop()) { return true; }) {
if (action.edits?) {
executeDocumentEdits(action.edits);
}

if (action.command?) {
return evaluator(action.command);
}

return true;
}

0 comments on commit daf8d28

Please sign in to comment.