use of org.eclipse.lsp4j.Command in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method createImportCommand.
private Command createImportCommand(IDefinition definition) {
String packageName = definition.getPackageName();
if (packageName == null || packageName.isEmpty() || packageName.startsWith(PACKAGE_NAME_NO_IMPORT)) {
return null;
}
String qualifiedName = definition.getQualifiedName();
Command importCommand = new Command();
importCommand.setTitle("Import " + qualifiedName);
importCommand.setCommand(COMMAND_IMPORT);
importCommand.setArguments(Arrays.asList(qualifiedName, importStartIndex, importEndIndex));
return importCommand;
}
use of org.eclipse.lsp4j.Command 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.lsp4j.Command in project xtext-core by eclipse.
the class CodeActionService method getCodeActions.
@Override
public List<? extends Command> getCodeActions(final Document document, final XtextResource resource, final CodeActionParams params, final CancelIndicator indicator) {
final ArrayList<Command> commands = CollectionLiterals.<Command>newArrayList();
List<Diagnostic> _diagnostics = params.getContext().getDiagnostics();
for (final Diagnostic d : _diagnostics) {
String _code = d.getCode();
if (_code != null) {
switch(_code) {
case TestLanguageValidator.INVALID_NAME:
Command _fixInvalidName = this.fixInvalidName(d, document, resource, params);
commands.add(_fixInvalidName);
break;
case TestLanguageValidator.UNSORTED_MEMBERS:
Command _fixUnsortedMembers = this.fixUnsortedMembers(d, document, resource, params);
commands.add(_fixUnsortedMembers);
break;
}
}
}
return commands;
}
use of org.eclipse.lsp4j.Command in project xtext-core by eclipse.
the class CodeActionService method fixInvalidName.
private Command fixInvalidName(final Diagnostic d, final Document doc, final XtextResource res, final CodeActionParams params) {
final String string = doc.getSubstring(d.getRange());
Command _command = new Command();
final Procedure1<Command> _function = (Command it) -> {
it.setCommand("my.textedit.command");
StringConcatenation _builder = new StringConcatenation();
_builder.append("Make \'");
_builder.append(string);
_builder.append("\' upper case");
it.setTitle(_builder.toString());
WorkspaceEdit _workspaceEdit = new WorkspaceEdit();
final Procedure1<WorkspaceEdit> _function_1 = (WorkspaceEdit it_1) -> {
TextEdit _textEdit = new TextEdit();
final Procedure1<TextEdit> _function_2 = (TextEdit it_2) -> {
it_2.setNewText(StringExtensions.toFirstUpper(string));
it_2.setRange(d.getRange());
};
TextEdit _doubleArrow = ObjectExtensions.<TextEdit>operator_doubleArrow(_textEdit, _function_2);
it_1.getChanges().put(params.getTextDocument().getUri(), Collections.<TextEdit>unmodifiableList(CollectionLiterals.<TextEdit>newArrayList(_doubleArrow)));
};
WorkspaceEdit _doubleArrow = ObjectExtensions.<WorkspaceEdit>operator_doubleArrow(_workspaceEdit, _function_1);
it.setArguments(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList(_doubleArrow)));
};
return ObjectExtensions.<Command>operator_doubleArrow(_command, _function);
}
use of org.eclipse.lsp4j.Command in project xtext-core by eclipse.
the class CodeLensService method resolveCodeLens.
@Override
public CodeLens resolveCodeLens(final Document document, final XtextResource resource, final CodeLens codeLens, final CancelIndicator indicator) {
Command _command = codeLens.getCommand();
String _title = codeLens.getCommand().getTitle();
String _plus = (_title + "(RESOLVED)");
_command.setTitle(_plus);
return codeLens;
}
Aggregations