Eclipse Luna and Class with Large number of methods - eclipse

I needed to 'wrap' (for academic purposes) the GL2 interface in a class of mine that uses delegation to the current GLContext, something like:
public abstract class GL2Wrapper implements GL2 {
private GL2 current() {
return GLContext.getCurrentGL().getGL2();
}
// delegated methods here
public void glEnableClientState(int arrayName) {
current().glEnableClientState(arrayName);
}
// ... (2000+ methods to go)
}
// Somewhere else
public class GlWindow extends GLWrapper {
public GlWindow() {
glBegin(GL_TRIANGLES);
glVertex3f( 1, 0, 0);
glVertex3f( 0, 1, 0);
glVertex3f(-1, 0, 0);
glEnd();
}
}
It all works fine in runtime, but the class ends up with 2000+ methods.
I don't have a doubt that the code design is 'arguable', my question is more Eclipse Luna related.
Eclipse Luna hangs every time I use any type of auto-completion in the GlWindow class. It gets worst if I need to add something in GL2Wrapper.
I didn't have this problem (at least not this bad) in Eclipse Kepler and before.
Is there any eclipse configuration (maybe compiler related) that can help me leverage the problem?
Thanks in advance,
Regards,
LL

It looks like an Eclipse bug 433515 - Eclipse freezes every few minutes.
Same kind of issue for me when calling autocompletion in Javascript code into a JSP page or Javascript file, or even just hovering with the mouse a JavaScript code. The memory usage is playing the yoyo and Eclipse freezes.

Related

Eclipse missing warning if variable used before assigned

We found a bug in old code which could be easily found if there would be a warning,
The issue was that inner class member was used but not assigned or initialized. Sample code minimized. Problem is that url is always null.
public class Main {
public class Sender {
private String url;
public Sender() {
}
public void send() {
OtherClass.send(url);
}
}
}
In intellij it warns about variable never assigned. In eclipse I didn't find such warning.
The code is more complex and adding a warning at any level will reduce time to find similar bugs.
Is it possible in eclipse to warn in some way if variable is used before assigned/initialized ?
You can use SpotBugs(successor of findbugs) eclipse plugin. Right click on project Spotbugs->find bugs this will find these types of bugs.
I suggest also installing sonarlint plugin which has good static analysis capabilities.
https://marketplace.eclipse.org/content/spotbugs-eclipse-plugin
https://marketplace.eclipse.org/content/sonarlint

Run As TestNG is not shown for class extending AbstractTestNGCucumberTests

Please note that I've searched for this particular question & found couple of them but none of them had scenario related to cucumber integration.
I've a test runner class extending AbstractTestNGCucumberTests.
I've also installed Eclipse TestNG plugin as well 6.12
Also adding entry under TestNG under Run Configuration, didn't help to solve the issue.
Mac + Eclipse 4.7.0
#CucumberOptions(features={"src/test/resources/WunderlistAndroid.feature"}, strict = false, format = { "pretty","json:target/cucumber.json" }, tags = { "~#ignore" })
public class WLSignIn extends AbstractTestNGCucumberTests{
#BeforeClass
public void launchAppiumServer(){
//code doing desired action
}
#AfterClass
public void killAppiumServer(){
//code doing desired action
}
}
The problem is due to the fact that the eclipse TestNG plugin doesn't see any #Test methods in your class. I believe the plugin is contextual in nature and hence shows the Run As > TestNG Test only when it sees atleast one #Test method in your test class. Since the #Test method resides in your base class, the plugin doesnt see that and hence you don't see it.
To get past this, you can perhaps add a dummy test method such as the one below and that should bring back the Run as > TestNG test option.
#Test(enabled=false)
public void dummyTestMethod() {}
On a side note: You might want to file this as an issue in the TestNG project and see if its worth getting fixed.
Details that can be used for the bug :
If the base class resides within a jar (and has one or more #Test annotated test methods) then the eclipse testng plugin doesn't see the child class (WLSignIn) the first time. But after one adds a disabled #Test method to the child class (WLSignIn) the option shows up. This happens irrespective of whether the child class extends from another class in the same project or from another class which resides in a jar (in your case cucumber.api.testng.AbstractTestNGCucumberTests)

Breakpoints in Provides method get remapped in Eclipse to ProvidesAdapter instead

I am having an issue in Eclipse (with Dagger 1 still).
In dagger, for dependency injection (javax.inject), you create a Module class, with provides methods, like this:
#dagger.Module
class FooModule {
#dagger.Provides
Something provideSomething() {
return new Something();
}
}
And this will generate a class (using annotation processing) called FooModule$$ModuleAdapter$ProvideSomethingProvidesAdapter.
If I set a breakpoint in a provideSomething method in FooModule class (my code), Eclipse almost always actually stops on that same line number in the FooModule$$ModuleAdapter$ProvideSomethingProvidesAdapter class instead.
Does anyone know how to avoid this problem? I suspect this is likely an Eclipse issue where it is somehow is mapping the generated file to what it thinks is the "source" file, but that's of course not what I want.
Is there perhaps some setting in eclipse to avoid this problem?

eclipse autocomplete fails in PHP when using parentheses

I'm using eclipse Juno with PDT. Autocomplete works fine except in a specific situation.
If I do this it works fine
class Example {
public function doit() {
$v = new Example();
}
}
I can control-click the Example() object fine and also I see the doit() method when autocompleting $v->.
Now see this example
class Example2 {
public function doit() {
$v = (new Example2());
}
}
Now the autocompleter is broken, I cannot control-click anything but also the outline view is now empty. Eclipse cannot see any methods or anything. There is nothing in the eclipse logs.
Of course this is a stupid example but I've seen this construction happening in statements with the ternary operator in external frameworks. This is pretty annoying because the objects from such classes cannot be used anymore with the autocompleter.
This call relates to Eclipse PHP autocomplete acting funny, some files complete some don't btw where I also replied with the actual issue. Please don't shoot me for re-posting.

Eclipse EclEmma missed instructions

I'm using Eclipse-STS + EclEmma plugin to see coverage of my code. In all my abstract util classes (with only static methods) I see 3 missed instructions (Instructions Counter report) at the class definition line:
No marker available at the left of the red line, so I do not know exactly what are these instructions. Maybe some constructors? What can I do to cover them?
One way I found to achieve 100% covering is to write a test method like this:
#Test
public void coverage(){
KeyEscaper a = new KeyEscaper() {
};
}
As soon as the issue touches only utils classes with all static methods, it's not a problem to instantiate them anonimously in such way.