Race conditions in AnnotationModel? Error annotations lost in Reconciler - eclipse-plugin

I have an Eclipse custom editor and I implemented 'report errors as you type', but every now and then my error squigglies (using JFace annotations) are not shown or linger after they should be removed.
I am using MonoReconciler with my implementation of IReconcilingStrategy. During the reconcile step I call annotationModel.replaceAnnotations to remove the old errors and add the new ones. Most of the times this works fine. Every now and then the updates are lost, and I notice the following:
the red stamp on the left ruler disappears, but the red underlines stay
on the next character I type, the underline disappears
I verified in the debugger that the annotations are correctly calculated. The underline disappears immediately after typing a character, and not after the 500ms delay of the reconciler. It looks like a lost UI update/redraw.
There must be a race condition somewhere (the reconciler runs in its own thread). What am I doing wrong? I couldn't find any documentation about this use-case.
Edit: To reproduce, checkout the scala-worksheet and create a new one. Type
object Test {
val m = Map( 't' -> 1 )
}
Now edit the arrow: remove the >. The underline is missing. Type a space, it comes back. Add it back, the underline is still there until you type another space.
I fixed it by calling invalidateTextPresentation on the underling SourceViewer, but it seems to me that shouldn't be necessary. I'd like to understand what is the correct way to use editor annotations.
PS. The lost updates can also be seen in this screencast.

It's hard to tell from a distance, typically in eclipse, any changes that impact the ui should be executed on the ui thread (and eclipse will not always warn about this).
Normally you use Display.getDefault().asyncExec(...) to execute something on the ui thread but you probably already know this. It can happen that 2 queued up changes cause a race.
(I have implemented semantic highlighting, error highlighting etc several times for the company I work for, Sigasi. If you can point me to your implementation I may be able to figure out what's going wrong.)

Related

How to keep IntelliSense Complete Word option off?

IntelliSense has a mode where if you hit the spacebar, it will automatically type out the suggested auto-complete word. In order to prevent this from happening, you can hit the Escape key before pressing Space. This will close the autocomplete popup, so that the suggested word is not automatically typed.
I prefer the alternative setting, where I actually have to hit the Enter key to accept the suggested autocompletion. If I just type Space, I want a space to follow the characters that I actually typed.
I know that I can toggle between the undesired mode and the second mode I describe, which I do want. To do this, I click Edit -> IntelliSence -> Toggle Completion Mode.
My problem is that this setting never sticks. It constantly reverts to the wrong mode. I'm not sure exactly when it's changing, but it seems to revert back several times a day. If I change this for one Solution, it won't apply to my other Solutions. Even if I apply it to a solution, close VS, reopen, and start working again, it will have reverted.
Does this happen to everyone else, or is this unique to me? Is there some global setting that forces this feature to stay off always? Do I have a corrupted file somewhere that's causing this?
No, this is normal behavior and this setting behaves like what you described in the previous VS versions.
However, thanks to those members who is reporting this issue and Microsoft has fixed this behavior in the latest VS2019 version.
Since VS2015 is not supported by Microsoft so far, so this behavior cannot be fixed on VS2015 and I suggest you could install the latest VS2019 Community and get what you want.
Once you click the Toggle Completion Mode under Edit-->Intellisense, no matter you close VS, create a new project or a solution, use other c# file editor, it will never revert back.

Is there a way to make IDEs (IntelliJ, PyCharm, VS Code) have fewer popups but still have completion?

I learned to program 30 years ago with Emacs. I'm starting to learn moderns IDEs such as "IntelliJ IDEA", "PyCharm", and "VS Code".
It's hard to adjust to how visually "busy" they are, with constant pop-up menus appearing every character I type.
Of course I want to be able to get suggestions for completion or parameter hints or other popups when necessary. I just don't want them to appear by default.
Some people are asking why popups are annoying. The main problem is that popups cover code above or below where I'm typing.
Emacs has completion. But it doesn't need a popup. For instance, dynamic completion works just fine 90% of the time, even though it's not smart enough to parse syntax or look up function and method definitions.
So I'd like to know if there are settings in JetBrains or VS Code IDE's that would help.
I'm aware of two kinds of popups.
(1) An offer to complete my typing, which appears below.
(2) Annotation of argument names and definitions, which appears above.
There may be other popups as well.
I'm aware that a popup can be dismissed with ESC. But often they just come back the moment you type another character.
What would be great is if the popup would not appear by default, but I could cause it to appear with a single keystroke. Or I could dismiss it and it would stay dismissed.
For PyCharm You can also try writing in "Disctraction Free Mode"
View -> Enter Distraction Free Mode
Which should give you a little screen of calm which will feel a lot more like emacs to you.
It's possible to adjust the behaviour via "Settings".
In IntelliJ IDEA, goto Menu File --> Settings ... , then navigate to Editor --> General --> Code Completion , or type something in the search field (upper left).
Perhaps you find more settings when you browse through Settings dialog.
To be honest, I didn't make a lot of tests with these settings, because I find the helper popups very useful.
Another option to get rid of some "noise" is to adjust settings for displaying parameter names in the code editor.
I switched this off completely.
Go to Settings --> Editor --> General --> Appearance
The new IDEs are really busy looking for libraries, checking/auto closing balanced parentheses, indenting, surrounding methods/functions/procedures/classes as you type. Sometimes I feel the same, but these IDEs are not plain text editors anymore. Every key stroke triggers something which can be time consuming. When the project gets larger and when it has lots of libraries, it can get even slower. Some IDEs have options to turn some of these options off. Every feature turned off will have some positive effect on responsiveness to some degree
But I think, instead of turning these features off, the best way to have these features on a responsive modern IDE is to use a computer with a fast cpu, an ssd drive and sufficient memory.

Is VS2015 intellisense broken with enums?

Just upgraded from VS2013 to VS2015 Enterprise Update 3 and discovered that intellisense seems broken with enums.
With VS2013, typing space after, for instance:
dim myEnum as MyEnumType =
... would immediately give a choice of enum values of the correct type.
This was also true with more complex situations, where, when choosing from a number of overloaded versions of a method, you could down-arrow through the overloads till you got to the right overload, then type space again, and it would give you a choice of the right enum values of the correct type, for the argument you had got to in the list.
Here's what VS2013 did, for instance:
However, this is the VS2015 equivalent, on the exact same line of code, after scrolling through to the correct overload:
As you can see, it gives a completely wrong list of possible options.
There was a similar problem with a previous version of Studio that eventually got fixed after the whole community howled in pain.
It seems to be back with VS2015 - a significant retrograde step. Now you have to know the exact type it's expecting before it will give you options.
A similar issue seems to have been reported a year ago re the Community Edition but it, or a more subtle version of it is clearly also affecting Update 3 of Enterprise.
Is there any way to reproduce the Common/All tabs behaviour of VS2013?
Edit: here are my selected options:
They're the same as I had in VS2013.
What the intellisense shows is the list of member according to the current signature (or what the compiler thinks it could be), not according to the overload tooltip.
For example see this
It shows the same overall behaviour as in your post.
But to obtain it, after having written the comma after "caption" I changed the current overload tooltip manually using up/down arrow on keyboard.
Note, it was not mandatory to change it manually even without that it was proposing me some overload which takes an IWin32Window for first argument even with an already present string as first argument
Then I pressed space and the intellisense showed what is appropriate given the context not the tooltip.
In your post we can see it's not the same overload in both screen.
I can't say for sure it is what happened for you (given I changed the overload tooltip on purpose) but if I had to bet, I would go that way.

Typo in IntelliJ manual?

From IntelliJ 14 help:
There are certain cases when IntelliJ IDEA will not stop at a
breakpoint. Consider the following situation: Two breakpoints are set
at the different methods of a class, and there suspend policy is set
to All. When one of the breakpoints is hit, some step actions are
performed. If at the time of stepping another thread hits the second
breakpoint, profuct will not stop there.
I thought it's a typo but "product will not stop there" still doesn't make sense.
I'm pretty sure they mean that the execution will not stop there, but I was wondering what the word there was supposed to be?
The word was supposed to be "IntelliJ IDEA" (it's a macro which gets replaced with the actual product name when the help is generated).

Does IntelliJ IDEA reveal the method body when folding anonymous classes?

Based on IntelliJ's documentation, when folding an anonymous class you should still be able to see the contents of the inner method. See image below taken from their documentation:
This isn't the behavior I'm seeing though. Here is what I see:
I can only seem to collapse the inner method contents or the entire anonymous class body. Is this just an error in their documentation or is there a way to actually achieve this behavior?
======= UPDATE =========
I've accepted the answer from Peter Gromov, but there still seems to be something amiss with my version. When I have files open and set folding closures by default (File -> Settings -> Editor -> Code Folding -> Select 'Closures' under 'Collapse by default:'), it does seem to fold correctly as seen in the following image:
Notice that the expanded Because shows a single collapsible region in the margin. Closing the file and reopening produces the following (after I collapse the first one):
When first opening the file, both of these statements are expanded (issue #1). After collapsing the outer most region for the first statement, it folds over the entire anonymous class (issue #2) rather than how it worked before I closed the file. Notice also that the second statement that I've left open has an additional collapsible region for the method of the anonymous class (issue #3). This is how it behaves with the default folding settings for closures are turned off. There's definitely something buggy here. Since I've posted this question, there has been a new version released so perhaps the issue is only with the version I have (10.0.3), but as far as I know this is a fairly old feature. I'd welcome any explanation as to why I might be seeing these issues (including "Works on my machine").
What you want is called 'Closure folding' and can be turned on in the Code Folding settings.