use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testReferences.
protected void testReferences(final Procedure1<? super ReferenceTestConfiguration> configurator) {
try {
@Extension final ReferenceTestConfiguration configuration = new ReferenceTestConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
ReferenceParams _referenceParams = new ReferenceParams();
final Procedure1<ReferenceParams> _function = (ReferenceParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
it.setTextDocument(_textDocumentIdentifier);
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it.setPosition(_position);
boolean _isIncludeDeclaration = configuration.isIncludeDeclaration();
ReferenceContext _referenceContext = new ReferenceContext(_isIncludeDeclaration);
it.setContext(_referenceContext);
};
ReferenceParams _doubleArrow = ObjectExtensions.<ReferenceParams>operator_doubleArrow(_referenceParams, _function);
final CompletableFuture<List<? extends Location>> referencesFuture = this.languageServer.references(_doubleArrow);
final List<? extends Location> references = referencesFuture.get();
Procedure1<? super List<? extends Location>> _assertReferences = configuration.getAssertReferences();
boolean _tripleNotEquals = (_assertReferences != null);
if (_tripleNotEquals) {
configuration.getAssertReferences().apply(references);
} else {
final String actualReferences = this.toExpectation(references);
this.assertEquals(configuration.getExpectedReferences(), actualReferences);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testRangeFormatting.
protected void testRangeFormatting(final Procedure1<? super DocumentRangeFormattingParams> paramsConfigurator, final Procedure1<? super RangeFormattingConfiguration> configurator) {
try {
@Extension final RangeFormattingConfiguration configuration = new RangeFormattingConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final FileInfo fileInfo = this.initializeContext(configuration);
DocumentRangeFormattingParams _documentRangeFormattingParams = new DocumentRangeFormattingParams();
final Procedure1<DocumentRangeFormattingParams> _function = (DocumentRangeFormattingParams it) -> {
String _uri = fileInfo.getUri();
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri);
it.setTextDocument(_textDocumentIdentifier);
it.setRange(configuration.getRange());
if ((paramsConfigurator != null)) {
paramsConfigurator.apply(it);
}
};
DocumentRangeFormattingParams _doubleArrow = ObjectExtensions.<DocumentRangeFormattingParams>operator_doubleArrow(_documentRangeFormattingParams, _function);
final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.rangeFormatting(_doubleArrow);
String _contents = fileInfo.getContents();
final Document result = new Document(Integer.valueOf(1), _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[]) Conversions.unwrapArray(changes.get(), TextEdit.class)))));
this.assertEqualsStricter(configuration.getExpectedText(), result.getContents());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.
the class AbstractLanguageServerTest method close.
protected void close(final String fileUri) {
DidCloseTextDocumentParams _didCloseTextDocumentParams = new DidCloseTextDocumentParams();
final Procedure1<DidCloseTextDocumentParams> _function = (DidCloseTextDocumentParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
it.setTextDocument(_textDocumentIdentifier);
};
DidCloseTextDocumentParams _doubleArrow = ObjectExtensions.<DidCloseTextDocumentParams>operator_doubleArrow(_didCloseTextDocumentParams, _function);
this.languageServer.didClose(_doubleArrow);
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testCodeAction.
protected void testCodeAction(final Procedure1<? super AbstractLanguageServerTest.TestCodeActionConfiguration> configurator) {
try {
@Extension final AbstractLanguageServerTest.TestCodeActionConfiguration configuration = new AbstractLanguageServerTest.TestCodeActionConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String filePath = this.initializeContext(configuration).getUri();
CodeActionParams _codeActionParams = new CodeActionParams();
final Procedure1<CodeActionParams> _function = (CodeActionParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(filePath);
it.setTextDocument(_textDocumentIdentifier);
Range _range = new Range();
final Procedure1<Range> _function_1 = (Range it_1) -> {
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it_1.setStart(_position);
it_1.setEnd(it_1.getStart());
};
Range _doubleArrow = ObjectExtensions.<Range>operator_doubleArrow(_range, _function_1);
it.setRange(_doubleArrow);
CodeActionContext _codeActionContext = new CodeActionContext();
final Procedure1<CodeActionContext> _function_2 = (CodeActionContext it_1) -> {
it_1.setDiagnostics(this.getDiagnostics().get(filePath));
};
CodeActionContext _doubleArrow_1 = ObjectExtensions.<CodeActionContext>operator_doubleArrow(_codeActionContext, _function_2);
it.setContext(_doubleArrow_1);
};
CodeActionParams _doubleArrow = ObjectExtensions.<CodeActionParams>operator_doubleArrow(_codeActionParams, _function);
final CompletableFuture<List<Either<Command, CodeAction>>> result = this.languageServer.codeAction(_doubleArrow);
if ((configuration.assertCodeActions != null)) {
configuration.assertCodeActions.apply(result.get());
} else {
this.assertEquals(configuration.expectedCodeActions, this.toExpectation(result.get()));
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testSignatureHelp.
protected void testSignatureHelp(final Procedure1<? super SignatureHelpConfiguration> configurator) {
try {
@Extension final SignatureHelpConfiguration configuration = new SignatureHelpConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
SignatureHelpParams _signatureHelpParams = new SignatureHelpParams();
final Procedure1<SignatureHelpParams> _function = (SignatureHelpParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
it.setTextDocument(_textDocumentIdentifier);
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it.setPosition(_position);
};
SignatureHelpParams _doubleArrow = ObjectExtensions.<SignatureHelpParams>operator_doubleArrow(_signatureHelpParams, _function);
final CompletableFuture<SignatureHelp> signatureHelpFuture = this.languageServer.signatureHelp(_doubleArrow);
final SignatureHelp signatureHelp = signatureHelpFuture.get();
Procedure1<? super SignatureHelp> _assertSignatureHelp = configuration.getAssertSignatureHelp();
boolean _tripleNotEquals = (_assertSignatureHelp != null);
if (_tripleNotEquals) {
configuration.getAssertSignatureHelp().apply(signatureHelp);
} else {
final String actualSignatureHelp = this.toExpectation(signatureHelp);
this.assertEquals(configuration.getExpectedSignatureHelp().trim(), actualSignatureHelp.trim());
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations