use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Member in project xtext-core by eclipse.
the class CodeActionService method fixUnsortedMembers.
private Command fixUnsortedMembers(final Diagnostic d, final Document doc, final XtextResource res, final CodeActionParams params) {
final IChangeSerializer.IModification<Resource> _function = (Resource copiedResource) -> {
final Model model = IterableExtensions.<Model>head(Iterables.<Model>filter(copiedResource.getContents(), Model.class));
EList<TypeDeclaration> _types = model.getTypes();
for (final TypeDeclaration type : _types) {
final Comparator<Member> _function_1 = (Member a, Member b) -> {
String _name = a.getName();
String _name_1 = b.getName();
return (_name.compareTo(_name_1));
};
ECollections.<Member>sort(type.getMembers(), _function_1);
}
};
final WorkspaceEdit edit = this.recordWorkspaceEdit(doc, res, _function);
Command _command = new Command();
final Procedure1<Command> _function_1 = (Command it) -> {
it.setCommand("my.textedit.command");
StringConcatenation _builder = new StringConcatenation();
_builder.append("Sort Members");
it.setTitle(_builder.toString());
it.setArguments(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList(edit)));
};
return ObjectExtensions.<Command>operator_doubleArrow(_command, _function_1);
}
use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Member in project xtext-core by eclipse.
the class CodeActionService method fixUnsortedMembers.
private CodeAction fixUnsortedMembers(Diagnostic d, ICodeActionService2.Options options) {
WorkspaceEdit wsEdit = recordWorkspaceEdit(options, (Resource copiedResource) -> {
Model model = Iterables.getFirst(Iterables.filter(copiedResource.getContents(), Model.class), null);
if (model != null) {
for (TypeDeclaration type : Iterables.filter(model.getElements(), TypeDeclaration.class)) {
ECollections.sort(type.getMembers(), (Member a, Member b) -> a.getName().compareTo(b.getName()));
}
}
});
CodeAction codeAction = new CodeAction();
codeAction.setTitle("Sort Members");
codeAction.setDiagnostics(Lists.newArrayList(d));
codeAction.setEdit(wsEdit);
return codeAction;
}
Aggregations