use of org.eclipse.n4js.ide.tests.helper.server.AbstractCodeActionTest.N4JSTestCodeActionConfiguration in project n4js by eclipse.
the class AbstractCodeActionTest method performTest.
@Override
protected void performTest(Project project, String moduleName, N4JSTestCodeActionConfiguration tcac) throws InterruptedException, ExecutionException {
CodeActionParams codeActionParams = new CodeActionParams();
Range range = new Range();
Position posStart = new Position(tcac.getLine(), tcac.getColumn());
Position posEnd = tcac.getEndLine() >= 0 && tcac.getEndColumn() >= 0 ? new Position(tcac.getEndLine(), tcac.getEndColumn()) : posStart;
range.setStart(posStart);
range.setEnd(posEnd);
codeActionParams.setRange(range);
CodeActionContext context = new CodeActionContext();
FileURI uri = getFileURIFromModuleName(moduleName);
context.setDiagnostics(Lists.newArrayList(getIssuesInFile(uri)));
codeActionParams.setContext(context);
TextDocumentIdentifier textDocument = new TextDocumentIdentifier();
textDocument.setUri(uri.toString());
codeActionParams.setTextDocument(textDocument);
CompletableFuture<List<Either<Command, CodeAction>>> future = languageServer.codeAction(codeActionParams);
List<Either<Command, CodeAction>> result = future.get();
if (tcac.getAssertCodeActions() != null) {
tcac.getAssertCodeActions().apply(result);
} else {
String resultStr = result.stream().map(cmdOrAction -> getStringLSP4J().toString3(cmdOrAction)).collect(Collectors.joining("\n-----\n"));
assertEquals(tcac.getExpectedCodeActions().trim(), resultStr.trim());
}
}
Aggregations