Automatic converting loops into streams in Eclipse - eclipse

Is there a way to refactor a loop over collections into Collection.forEach using refactoring or code inspection (problem severity) using eclipse ?
example :
howto convert this :
for(Person person : personenListe) {
System.out.println(person);
}
into this :
personenListe.forEach(System.out::println);
using a refactoring action in eclipse ?

It doesn't seem to exist yet but there is a bug created for it #431967

Related

How to import test execution results using REST API and XRay for JIRA and Cucumber + Xray

I am trying to import test execution results for my project but am having difficulty associating tests with the test execution using the REST API. I have tried to emulate the instructions found at http://xray.xpand-it.com/display/XRAY/REST+API but it does not seem to be working. I can import a test execution without any associated tests.
Here is my request which I am posting to http:////rest/api/2/issue
"{""fields"": {""project"":{""key"": ""ET""}, ""summary"": ""Test execution"", ""description"":""Description"", ""issuetype"":{""id"":""10302""}, ""tests"":[{""testKey"" : ""ET-879"",""comment"" : ""Successful execution"",""status"" : ""PASS""},{""testKey"" : ""ET-880"",""comment"" : ""Execution failed"",""status"" : ""FAIL""},{""testKey"" : ""ET-881"",""comment"" : ""Successful execution"",""status"" : ""PASS""}]}}"
The "tests" field is not recognised, but I can't find the appropriate replacement to get this to work.
Any help you can give would be appreciated.
If you look here for the documentation it appears you have misspelled the values for you "status" field in your tests section. It appears you are looking for PASSED/FAILED as opposed to PASS/FAIL.
Relevant documentation : https://confluence.xpand-it.com/plugins/servlet/mobile?contentId=32806690#ImportExecutionResults-XrayJSONformat

How to retrieve Handle of a State block ? Matlab

I'm actually trying to build a Stateflow with Matlab code
I would like to know if it's possible to retrieve the Handle of a State block. I tried to use get_param() :
state_handle = get_param('System/Chart/State_ON', 'Handle');
But it returns me :
No block called 'State_ON' could be found.
Is there another solution to get Handle using the name of the state?
Edit : i found and post a solution
Ok after many research there are 2 solutions :
For version R2017b and after
StateHandle = StateFinder(Chart Handle)
For versions before R2017b
state_handle = ch.find('-isa','Stateflow.State','-and','Name', 'State_ON');

Automatic text adding in Eclipse editor from xtext dsl project

Here is a small code section I made from the DSL grammar generated using Xtext.
start
{
alpha
{
prev : alpha
next : beta
}
}
In this, I want that as soon as I write next :beta, automatically the code should change to this
start
{
alpha
{
prev : null
next : beta
}
beta
{
prev : alpha
}
}
What code do I need to add?
I think we can achieve this via some listener to the editor which listen for the changes in the editor and thus add code. But there isn't much support available so that I can clearly understand.
You should be able to achieve it by customizing content assist: https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#content-assist

How to apply a simple filter with Flink in Scala

I was using an old version of Flink. I upgrade to 1.2.0 and I have some issues with filters.
I have a DataStream of Log which works just fine :
val logs: DataStream[Log] = env.addSource(new LogSource(
data, delay, factor))
// DISPLAY TUPLE IN CONSOLE
logs.print()
// EXECUTE SCRIPT
env.execute("stream")
I have of course read the documentation which shows :
dataStream.filter { _ != 0 }
I tried a bunch of things like this :
val cleanLogs = logs.filter { _.isComplete }
But I got the following error :
Type mismatch, expected: FilterFunction[Log], actual: (Any) => An
So I don't see the link between the documentation and this error.
Any help ? Examples ?
Thanks
The problem was first a wrong import of StreamExecutionEnvironment which lead to this problem with basic functions like filter.
Then as I used an old version of Flink I was using LocalExecutionEnvironment class which is no longer available in Flink 1.X.
Instead : StreamExecutionEnvironment.createLocalEnvironment(1)

CKEditor: how to remove a plugin that has been added?

I'm just beginning to use CKEditor, but have a hard time understanding the plugins system.
I was able to add a simple button that says 'Test' when you click on it with :
var myplugin_function = function () {
alert('Test');
}
var plugin_name='myplugin';
CKEDITOR.plugins.add(plugin_name,
{
init:function(c) {
c.addCommand(plugin_name,myplugin_function);
c.ui.addButton(plugin_name,
{
label:'This is my plugin',
command:plugin_name,
icon:this.path+'myplugin.png'
});
}
});
I know this code should be executed only once, for example in a plugin.js, but that's not how I use it. The CKEditor instance, including my plugin code is executed each time the Ajax-page is loaded.
That's why I use this to remove the instance, if it exists :
if (CKEDITOR.instances['mytextarea']) {
CKEDITOR.remove(CKEDITOR.instances['mytextarea']);
}
Then I use the jquery way to create the ckeditor from a textarea:
$('#mytextarea').ckeditor();
But the 2nd time the ajax-page loads, I get an error about the plugin already being registered. So I need a way to remove the plugin and be able to add it again.
Is this even possible?
UPDATE
This seems to work :
I now check if the plugin is already registered with :
if (!CKEDITOR.plugins.registered[plugin_name]) {
}
around the CKEDITOR.plugins.add(b, ... part
You are not showing how you are adding the plugin, so it's hard to tell what's your exact problem; but from the code that you have provided I can suggest that you use variable names better than "a", "b" and "c". It's quite harder to understand the code this way.
Also, CKEDITOR.remove just removes the instance from the instances array, but it doesn't really clear the used resources, you should use CKEDITOR.instances['mytextarea'].destroy( true ) instead