How to count LanguageServer completion requests that have occurred from within a VSCode extension? - visual-studio-code

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

Related

Is there a function in AnyLogic to display an alert message during model run?

I would like to display some text in an alert box similar to what the error() and errorInModel() methods create, but not as an error, just a simple message. I searched for a built-in method in the Help, but couldn't find anything.
It's not intended for an end user, just for myself as an alternative to printing to console during debugging.
No, but you can create an agent type with a visual warning msg.
Embed the agent in Main as myAgent.
When you have your issue, you jump into the agent using ((Main)getRootAgent()).myAgent._origin_VA.navigateTo();
this will visually jump into the agent.
It is up to you to change the msg in that agent using a text object, obviously.

Attachments are not updated asynchronously in Fiori MyInbox app?

I use SAP standard library: Inbox.
in library class S3.controller by tap on attachments icon is onTabSelect event executed, witch makes
this.fnDelegateAttachmentsCreation();
this.fnFetchDataOnTabSelect("Attachments");
this.fnHandleAttachmentsCountText("Attachments");
this.fnHandleNoTextCreation("Attachments");
break;
fnFetchDataOnTabSelect makes an asynchronous call. During this call is fnHandleAttachmentsCountText already executed, so the update of attachments count occurs before the request for attachments is ready. As far the request for attachments is ready, there is no update for title executed.
On screenshot is AttachmentCountText „Attachnents (1/1)“, that comes from previously selected item.
It should be „Attachements (2/2)".
Also if response comes too quick, then view changes to loading view after it received the answer from request.
If list of attachments was updated from request callback, then it should not be updated second time.
Here it seems, that there is something on loading, but request is already finished.
How could be Inbox extended, to update the attachment header and content after request is ready?
used SAPUI5-Version: 1.71.4
You are using the standard bsp-application ca_fiori_inbox?
You didn't create an extension project of the application ca_fiori_inbox with custom coding?
If that's the case, it's a bug in an standard application delivered by the SAP. SAP releases so called notes to fix bugs in their standard applications.
You can import notes in your system via the transaction SNOTE. May ask a SAP Basis Administrator from your company for help.
The following notes exactly describe your problem
2873960
2823664
2916255
2901520
If you already extended the SAP standard application(MyInbox) without using ExtensionPoints codechanges in the standard application will not affect your custom extension.
When overriding a controller method, any functionality that was previously provided by it is no longer available. Likewise, any future changes made to the original controller method implementation will not be reflected in the custom controller.
In this case you could still implement the note and check the changes in the standard controller vs. your custom controller on your system and change the respective lines in your custom coding.
Don't fix SAP coding. Report it and get a fix.
The Note 2873960 corrects coding in an abap class, not in the bsp-application(ca_fiori_inbox). So definitly import the note and check if it's fixing your problem.
I actually do not know, how the app works, but I want to give it a try.
Since it is an asynchronous function, you can always also wait for the function until it is done. So in your case, you could try to set an await keyword in front of the function.
await fnFetchDataOnTabSelect("Attachments");
This will now wait on this position until it has finished the function call before it will call the next functions. In addition to that you also need to set the upper function onTabSelect to async. So in the end it should look something like this.
onTabSelect: async function() {
// ...
this.fnDelegateAttachmentsCreation();
await this.fnFetchDataOnTabSelect("Attachments");
this.fnHandleAttachmentsCountText("Attachments");
this.fnHandleNoTextCreation("Attachments");
// ...
}
Although the Web IDE maybe shows you errors, it does work, since it is an official JavaScript API.

jQuery File Upload's change callback returns nothing

Everything about the uploader is working perfectly, but one callback seems to do nothing:
.bind('fileuploadchange', function (e, data) {
console.log("foo");
})
Binding to the change event never returns anything... so my question:
1) Is this a bug? I'm using the most recent version.
2) Is there another/better way to detect when files are manually removed from the upload queue (something more elegant than reading DOM elements)?
There might be a bit of misunderstanding in what the fileuploadchange event does.
The admittedly limited documentation for the change event states:
Callback for change events of the fileInput collection.
That means it's an event callback for the native change event of all the file input elements of the fileupload widget.
This event only fires if the user selects one or more files via the file picker dialog that is displayed after clicking on the file input button.
Technically, the basic fileupload library doesn't keep track of a queue.
It's up to the UI implementation to handle this, via the various callbacks provided by the basic library.
Until the user actually starts the file upload, there is technically nothing the basic library could keep track of.
And as soon as a file upload is started, the done and fail events are your basic building blocks.
By the way, the sample UI implementation handles the removal of items that have not been started yet by triggering a manual fail event.

Automatic handling of errors/warnings

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.

Has anyone used SlickGrid with the updated drag functions jquery.event.drag-2.2.js?

I read from the threedubmedia site "The previous version of this plugin allowed this method to be overloaded with arguments to additionally bind handlers for "dragstart" and "dragend" in a single call, but this is no longer supported." but since I haven't actually read every line of the code I was wondering if this has already been accounted for?
Yes I upgraded to v2.2 (Updated: 2012-05-21) and it works fine for me.
I actually had an issue with 'dragend' event getting missed sometimes with v2.0.
I was doing some operations at the end of 'dragend' event (like when user stops resizing column width), but sometimes the operation won't trigger because this event was missed. Actually one had to resize rather quickly and release mouse soon to get the problem in v2.0.
After upgrading to v2.2 those issues are gone.