Is there a quick way to add all undefined methods? - eclipse

Lately I've been using a lot of JUnit tests which have the predefined names for methods I will need to implement in my code. I find the "Create method 'x'" tool very useful but I was wondering if there was a tool that creates all the undefined methods, would anyone happen to know? This really isn't a huge problem but it would be very convenient for me to just add all of the missing methods at once as opposed to one by one.

I'm afraid that is not possible. Eclipse is able to generate all methods which you need to implement an interface, but you do not seem to have an interface here. If I understand your scenario right, you get Unit-Tests which do not compile because your class does not provide the tested methods yet.
When the class exists already, then Eclipse should suggest you to create a method with the needed signature. That is what you probably mean with "one by one".
In your case the fastest way is:
create the class
go into your unit test
jump through all non-compiling methods using command + . and create the methods using auto-suggest

Related

Eclipse and Intellij showing wrong java method declaration. How can I fix it?

in java the Thread.join(long millis) method is not a synchronized method. also you can see this method declaration form this link: https://docs.oracle.com/javase/9/docs/api/java/lang/Thread.html#join-long- but eclipse and idea showing this method as synchronized. you can look at the following picture to what I want to mean. by the way, I am using java 9 in eclipse
how can I fix this problem in eclipse ?
Eclipse and IntelliJ are showing you the actual code, and thus are correct by defintion. The apparent mismatch is because Javadoc doesn't show whether a method is synchronized.
This was a deliberate design decision; see this bug report. Quoting:
It's important for the developer to know whether it's safe for multiple threads
to operate on an object concurrently, However, this synchronization can be
done either in public methods or in private methods, and the Java Platform API
spec should not declare one to be preferred over the other. A licensee should
be able to achieve synchronization internally if they wish.
Therefore, the general description of a class should mention whether the class is thread-safe or not. Individual method descriptions that are exceptions should mention that they are exceptions.
The TL;DR is that synchronized is an implementation detail, not part of the method contract. So Javadoc doesn't show it.

Restricting Java package access

Ie. I have a GUI package, and a Logic package.
How can I prevent the Logic classes from importing GUI classes? Others(or myself) working on the same project might do that, which I want to prevent.
A solution could for example be a check in JUnit, that fails if its done, or a runtime check that throws an exception. Something along these lines, but how to do it?
You can write such a test using JDepend or DependencyFinder or Degraph.
Degraph is the only of the three tools that explicitly is intended to actually write tests for cases like this. Also AFAIK JDepend does not find all dependencies in more recent Java Versions (like classes mentioned in Annotations).
I'm the author of Degraph so I'm obivously biased.
I created the JabSaw project. It allows you to define modules by using annotated classes and to express the relationships between the modules. By default, a module contains all classes in a single package.The restrictions can be checked using a Maven plugin, from the command line or from a unit test. This should solve your problem.
One solution which comes to my mind is make GUI classes package private. Although you cannot isolate only one package and say, only Logic classes cannot use GUI, but other can.

Is there a way to deobfuscate already obfuscated GWT javascript code, that was obfuscated by me?

I want to have a possibility to decode error stacktraces that appear in the production environment.
If you kept your symbolMap around, yes; e.g. check out
http://code.google.com/p/speedtracer/wiki/ResymbolizationProtocol
(disclaimer: never tried it, myself)
you need to use the JsEmulateStackTrace class. Its seemly very complex and have never really gotten around to implementing it fully myself.
http://code.google.com/p/google-web-toolkit/wiki/WebModeExceptions
this hypothetically remaps your symbol map for you, but honestly i doubt it works fully as i haven't seen a library/module yet that provides proper stack tracing for gwt. So that tells me its pretty hard or not fully working.
honestly it might be better to create some code to inject at compile time that provides stack trace support, that allows you to generate your own stack trace rather then using the actual java script stack trace. IE.. you might be able to create a single base class for all of your classes that you compile. With maybe an annotation or something. Then have your build script extend all of your classes pre compile so they are transparent to the dev, but included with the compiled cache file. You could have your base class grab the class name and or method name or something. and manage it with a simple stack that you can pop.

Scala Help needed - Code completion

I am working on writing an IDE for Scala and need some help. I would like to implement coding assistance so that I could present a list of options when a user presses a period (".") or a space (" "). e.g. if projects is a List, as soon as user types "projects." or "projects ", I would like to show all methods of scala.List that he could use (regular IDE stuff). I know that scala.tools.nsc.interactive package provides this capability, but I am unable to figure out how to do it. Besides, it seems that the interactive package would use REPL and would be slow for this purpose. Is that a fair assumption, and if yes, are there any alternatives?
Also, is there a way I could get a call reference tree for a literal/ method (where all is the method referred to in a code base) ?
Thanks and Best regards
Aishwarya
Well, your best bet is going through the same set of links I provided in answer to this question, even though the questions are different.
Yes, the presentation compiler under scala.tools.nsc.interactive is where the reusable functionality would be.
The presentation compiler is used by Eclipse and ENSIME. May be ENSIME itself which in addition to providing emacs support also provides a server as a backend for an editor would be a good avenue.
The presentation compiler is not slow. It was designed from the ground up to provide good performance for Eclipse and it has largely delivered on this goal.
For some of the presentation compiler capabilities, see scala.tools.nsc.interactive.CompilerControl.
For another project using ENSIME, look at Daniel Spiewak's plugin for jEdit.

Does Eclipse have the ability to remove all references to a class when the class is removed?

I'm working in Java and implementing a basic tree (yes, for homework, but hear me out!). I discovered that I made an error and had an iterator class inherit from an iterator superclass, where both needed an internal reference to the same node in the tree. Now every time I reference the node in the subclass and make a change, I have to make the same change in the superclass, or they will be out of sync.
I don't have many classes in the package and I could do it by hand; however, I wondered if Eclipse has the ability to remove references when a class is deleted from a package. I've done something similar before and I don't think it does automatically, so perhaps the answer is simply no; however, it would be nice. Hoping that some SO wisdom can help here.
I don't see how it could remove references automatically, to be honest - if you're using a variable of that type, it would have to remove all the code using that variable, which is clearly going to affect how things work.
You can just delete the class and fix up the compiler errors though :)