Automatic handling of errors/warnings - eclipse

On a linking error, I can raise appropriate diagnostic (say MyDSL.MY_APPROPRIATE_DIAGNOSTIC) and then write, in MyDSLQuickfixProvider, a quick fix for it by annotating it in this way:
#Fix(MyDSL.MY_APPROPRIATE_DIAGNOSTIC)
public void fixMyAppropriateDiagnostic(final Issue issue, final IssueResolutionAcceptor acceptor) {
...
}
What about if I wanted to automatically resolve a diagnostic, i.e. automatically execute an IModification without propose it to the user as quick fix (imagine the quick fix for the diagnostic is unique)?
Is there a way to associate a (immediate) handling code to a diagnostic in a similar manner to what happens for (user-proposed) quick fixes?
Thanks in advance,
Marco

There is no way to set a quick fix to be executed automatically. Your alternatives are:
Invoke the marker resolution code from somewhere else in your code. I.e. while marker resolutions are typically triggered explicitly on user request using the problems view, ruler buttons and similar UI, you could invoke them from anywhere. Be sure that you don't interfere with quickfixes, which are not from your plugin and make sure your users are not surprised by this non-eclipse workflow.
For some issues you may be able to instead create code completion rules or templates. Those are still not fully automatic as requested, but basically you can already "correct" partial user input that way and avoid flagging a violation for the complete input.

Related

How to count LanguageServer completion requests that have occurred from within a VSCode extension?

We have a request to count the number of 'completion' events that have occurred from our LanguageServer in the vscode-python extension. (After a number of these completion events, we want to raise a popup and ask the user for some feedback).
I've not found a way to do this without asking for a change from the LanguageServer itself (have it raise an event that I can hook into). I am wondering if there is such a facility already available though, within VSCode?
I have found the BaseLanguageClient.onNotification from within the vscode-languageclient library. I am not entirely sure what method to hook into with this though, or even if there is an event relevant to my need.
Anyone have any tips for this?
You can inject middleware into your LanguageClient in order to capture events such as these. See here for an example:
https://github.com/Microsoft/vscode-go/blob/e0f8fc2540fecfe964807b97b1e4276c6b6c7a21/src/goMain.ts#L113

MVVM Light : How to remove dependency of System.Windows.MessageBoxResult from DialogMessage

I'm working on a MVVM application, using MVVM Light and on the whole I'm finding it very nice to work with. I have a nagging issue however and hope someone can help.
I'm using sending instances of DialogMessage from VM to the View to display dialogs. The result is sent back to my VM via a callback, all good so far.
However the result of the dialog (OK, Yes, No, Cancel etc) is sent back as a member of the enum System.Windows.MessageBoxResult. This seems to go against the View/ViewModel separation to me, MessageBoxResult is clearly a type from the UI and so the VM shouldn't be dependent upon this or anything from the System.Windows namespace.
What I'm looking for is someway of using DialogMessage with an alternative callback eg Action<UserResult>; rather than Action<System.Windows.MessageBoxResult>;, where UserResult is a type defined by me to represent the users choice without dependency on MessageBoxResult.
Is this possible or am I being too strict in me desire to keep UI concepts out of the VM?
In regards to the second part of your question, when I started working with MVVM Light I too felt that receiving a MessageBoxResult back in the VM seems a little to UI-oriented.
On the other hand, if only the name was different - such as UserResult as you suggested - would that be sufficient for you?
If only the nameing of the class is a problem, I think you can let it slip. The result Ok, Yes, No, Cancel do not give an indication of whether a MessageBox was shown with buttons or whether it was some other kind of UI implementation (lets say a form with a combo box).
If it still bothers you, you can always create a wrapper for the DialogMessage which will raise the Dialog, get the MessageBoxResult and return a UserResult which can be an enum with the same values (think of it as a simple converter).
But as I said, I think it might be an overkill...

how can I improve iPhone UI Automation?

I was googling a lot in order to find a solution for my problems with UI Automation. I found a post that nice summarizes the issues:
There's no way to run tests from the command line.(...)
There's no way to set up or reset state. (...)
Part of the previous problem is that UI Automation has no concept of discrete tests. (...)
There's no way to programmatically retrieve the results of the test run. (...)
source: https://content.pivotal.io/blog/iphone-ui-automation-tests-a-decent-start
Problem no. 3 can be solved with jasmine (https://github.com/pivotal/jasmine-iphone)
How about other problems? Have there been any improvements introduced since that post (July 20, 2010)?
And one more problem: is it true that the only existing method for selecting a particular UI element is adding an accessibility label in the application source code?
While UI Automation has improved since that post was made, the improvements that I've seen have all been related to reliability rather than new functionality.
He brings up good points about some of the issues with using UI Automation for more serious testing. If you read the comments later on, there's a significant amount of discussion about ways to address these issues.
The topic of running tests from the command line is discussed in this question, where a potential solution is hinted at in the Apple Developer Forums. I've not tried this myself.
You can export the results of a test after it is run, which you could parse offline.
Finally, in regards to your last question, you can address UI elements without assigning them an accessibility label. Many common UIKit controls are accessible by default, so you can already target them by name. Otherwise, you can pick out views from their location in the display hierarchy, like in the following example:
var tableView = mainWindow.tableViews()[0];
As always, if there's something missing from the UI Automation tool that is important to you, file an enhancement request so that it might find its way into the next version of the SDK.
Have you tried IMAT? https://code.intuit.com/sf/sfmain/do/viewProject/projects.ginsu . It uses the native javascript sdk that Apple provides and can be triggered via command line or Instruments.
In response to each of your questions:
There's no way to run tests from the command line.(...)
Apple now provides this. With IMAT, you can kick off tests via command line or via Instruments. Before Apple provided the command line interface, we were using AppleScript to bring up Instruments and then kick off the tests - nasty.
There's no way to set up or reset state. (...)
Check out this state diagram: https://code.intuit.com/sf/wiki/do/viewPage/projects.ginsu/wiki/RecoveringFromTestFailures
Part of the previous problem is that UI Automation has no concept of discrete tests. (...)
Agreed. Both IMAT and tuneup.js (https://github.com/alexvollmer/tuneup_js#readme) allow for this.
There's no way to programmatically retrieve the results of the test run. (...)
Reading the trailing plist file is not trivial. IMAT provides a jUnit like report after a test run by reading the plist file and this is picked up by my CI Tool (Teamcity, Jenkins, CruiseControl)
Check out http://lemonjar.com/blog/?p=69
It talks about how to run UIA from the command line
Try to check the element hierarchy, the table can be placed over a UIScrollView.
var tableV = mainWindowTarget.scrollViews()[0].tableViews()[0].scrollToElementWithName("Name of element inside the cell");
the above script will work even the element is in 12th cell(but the name should be exactly the same as mentioned inside the cell)

How to show previous url after user has canceled dialog with message from Activity#mayStop()?

In our app we need to check if the data is saved when we are in a particular place before navigating away from it. So the user should be able to negate a browser back button request. But by the time that the history value change event is received the url has already been changed. The History class doesn't seem to have a way to restore the url back. Anybody have any ideas?
In GWT 2.1 you get Activities and Places. And activity has a maystop method, which is exactly what you want, if I understand you correctly.
Use a window.onunload or window.onbeforeunload javascript callback to confrim/save state.
onbeforeunload example
I haven't actually implemented this behavior yet, but here is my plan and maybe it will work for you.
1) Each time you receive an onHistoryChanged event and decide to allow it, save the current historyToken in an instance variable somewhere.
2) Keep track of activity on the page that should block navigation. Use a data structure that can keep track of multiple activities, like multiple file uploads, multiple edits, etc.
3) When you receive a new onHistoryChanged event, if your data structure from #2 indicates that it's not safe to navigate, avoid changing the page and restore the historyToken that you saved in #1. I'm assuming that you can do this either by:
a) Calling History.newItem(oldHistoryToken, false) or
b) Calling History.newItem(oldHistoryToken, true) and keeping a flag to force the next onHistoryChanged to be ignored.
Again, I haven't actually implemented this so let me know how it works out.
If you have links that allow the user to leave the app and you want to prevent that as well, you'll need to also add an onbeforeunload.
Have a look at the PlaceManagerImpl class from the gwt-platform framework. Especially the onValueChange() method and the methods dealing with the onLeaveQuestion field.
Hope that helps.
In this issue report, t.broyer explains in his comment that such behavior was planned during design of Places framework. The most important part is:
mayStop was a mistake, or it should have only been called when unloading the app, not for internal navigation within the app.
So probably it's better to not use it at all...

Periodically calling TinyMCE's triggerSave function

If anyone knows TinyMCE well, do you know if it has built-in support for periodically calling its triggerSave function?
(This function copies it's content to its "parent" textarea. I want to observe said textarea for changes so I can implement autosave.)
Thanks
Don't try autosave, trust me on this one. triggerSave is buggy and when it fails it fails silently so you think that your content got posted, but in reality it didn't. After it fails once it will no longer work for the rest of the session, as in until the page is manually reloaded and tinymce does another full init().
Just got bit by this one badly, again. Never again trust triggerSave.
You could easily do this yourself by using JavaScript's setTimeout() function.
See http://www.w3schools.com/js/js_timing.asp.