ReSharper auto-complete behavior with anonymous types in a lambda expression - autocomplete

I am using C# 3.5 and Linq. I have ReSharper 6.1 on VS 2010.
For example, if I enter the following statement in the code editor:
var result = dataContext.Items.Select(i => new {Name = i.ItemName});
As soon as I type the new { it auto-completes to new string{}. Actually, not sure if it is always string or depends on the lambda. But I find I always need to delete it and back up. This happens whenever I am declaring anonymous types in a lambda.
What setting in ReSharper or VS do I need to change in order to be able to enter anonymous types using the above syntax without that occurring? Preferably, I would like to retain auto-completing in all other situations, just not this particular one as it is making an incorrect assumption as to my intent.

Resharper 6.1 added a new feature to control the way the intellisense autopopups act. Go to ReSharper->Options->Environment->IntelliSense->Autopopup and change the "After 'new'" setting to "Display but do not preselect".

Related

Scala: Setting programatically a break-point to be recognized by IntelliJ

In Visual Studio / C# I can easily set programatically a break-point. Is there any similar feature available for IntelliJ/Scala-Plugin and the Scala language ?
To clarify: In C# you can call an API function
System.Diagnostics.Debugger.Break();
and then the Debugger in VS stops like with any breakpoint, set in the IDE.
I am not aware of such a feature, but in any programming environment you can get away with an adhoc solution: just define a method debugBreak, add a breakpoint to it and then use that. By example:
def debugBreak() {
println("Breakpoint hit!") // Manually set a breakpoint here
}
//.... then somwhere in your code base
if (<<some condition>>) {
debugBreak
}
That's it. Everytime the condition is met, the debugger will stop and you just need to go up the stack one frame.
As an aside, most of the time a better and simpler soluttion is to just set a conditional breakpoint in IntelliJ (essentially pasting your condition expression in the "condition" field). See https://www.jetbrains.com/idea/help/configuring-breakpoints.html.
However sometimes IntelliJ is unable to evaluate your expression, so in those cases the adhoc solution described above is a useful substitute.

Eclipse auto completion with method parameter type name

Currently I get this result with Eclipse auto completion.
System.console().printf(format, args)
Of course, Eclipse shows the parameter types as popup, but I want the types to be displayed in front of parameter names too. Like this.
System.console().printf(String format, Object ... args) // `String`, `Object` inserted automatically.
Can I configure Eclipse to show the parameter types too?
Of course not. Eclipse auto completion only suggests valid syntax, while your demand is not valid java code.
An alternative for you might be to open the "Declaration" view or the "JavaDoc" view. Both will always show the declaration/JavaDoc of the currently selected element while you are typing. Therefore you could see the method declaration/javadoc when writing that method call.
Update
Whoever came across this old question. You can use eclipse code mining now:
parameter name hint for Eclipse

Is there a way to get eclipse code completion to filter options on text typed anywhere in a word rather than just the start?

I have just started using eclipse Indigo for Scala development. Is there a setting anywhere in eclipse to change the filter behavior to "anywhere" when I type X. and invoke completion?
If I have an object foo with a field foo.name and methods foo.fullName, foo.capAllNames I would like all three to remain in the selection list when I type foo.name.
Currently the list is filtering on the start of the word so only the foo.name property would remain in the example given. I would like the filter to be based on the text being present anywhere in the word, can this be done in eclipse?
Thanks
John
Looks like Code Recommenders as suggested by moeTi will do the job but I might have to wait for a while until the latest bug fixes filter through to a release that will play nicely with the Scala plug in (it/eclipse threw exceptions when I installed it):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=383395

Auto fix common typo in eclipse

Lets say for example I write many times priavte instead private.
Is there a way to let Eclipse automatically fix my common typo?
Something like construct a map of my common typo to its desire fix,
and then just let Eclipse fix it without asking me about that.
Are there any other IDE\editors that have such support?
There is no builtin support for automatically changing strings. The closest to your request are the templates of the Java editor, but even those must explicitly be activated using CtrlSpace.
To get around your problem, I suggest simply not to write that much yourself. If you want to declare a private field, type just "pr" and hit CtrlSpace to invoke code completion. Eclipse can do code completion quite well, often even without any trigger characters (try it with an empty class file).

Eclipse caret jumps to constructor while typing

While typing in Eclipse (Java) I often have the problem that when I begin to type accessors, the caret jumps down to the beginning of the constructor definition. So in a document like this:
private int mSomeInt;
public
in|public MyClass(){
}
I would like to manually type out the accessor (getter/setter) for mSomeInt, but when I press space after 'public' above, the caret jumps to the beginning of 'public MyClass'.
I often type complete lines to look up and find my methods jumbled with the constructor (like above).
Any help would be appreciated.
Note - this isn't only with accessors but rather any access modifiers that I define before the constructor or another method.
Edit
After unsuccessfully trying Deco's solution below, I've managed to narrow it down a little further.
The problem only happens if I have all the blocks in the file in a collapsed state (ctrl+shift+numPadDivide). I can see the problem is now that the new access modifier I type is then (quickly) collapsed into the below method. i.e. Eclipse is actually taking the first accessor modifier and collapsing everything from there, even though my intention is actually to write a new method.
The only solution I've been able to find is to only edit the source with all the 'fold' elements unfolded.
Under Window -> Preferences -> <Language> (e.g. Java) -> Editor there is a Content Assist menu item where you can configure auto completion and caret placement as well as auto-activation of it and the delay it uses.
Edit:
After your update to the original question I was able to successfully replicate this in Eclipse Indigo. When you have all of the code blocks collapsed it looks like Eclipse assumes that the code you are writing needs to be in that block (rather than as a variable declaration). I'm not sure if this is expected behaviour or not - but the only way around it I've found is to edit the code with the main block open, and then close it after the fact - or turn folding off altogether.
From what I can tell there are various folding plugins/addons that you can get for Eclipse which override the default behaviour and might function better? A quick Google search will be able to get you a list of them quickly.
I'd probably also suggest posting this as an issue on the Eclipse support site for their official answer.
Unfortunately this issue still exists for me in the latest Elcipse version (Kepler).
As the issue only occurs when the document is 'folded', the work around this is to either disable folding in the editor - or disable folding on 'Members' from the :
Preferences -> Java -> Editor -> Folding