In vscode api, we can use provideInlineCompletionItems to implemetn inline completions whenever the user stopped typing. but how can i implement user explicitly triggers?
export interface InlineCompletionItemProvider {
/**
* Provides inline completion items for the given position and document.
* **If inline completions are enabled, this method will be called whenever the user stopped typing.**
* **It will also be called when the user explicitly triggers inline completions **or explicitly asks for the next or previous inline completion.
* In that case, all available inline completions should be returned.
* `context.triggerKind` can be used to distinguish between these scenarios.
*
* #param document The document inline completions are requested for.
* #param position The position inline completions are requested for.
* #param context A context object with additional information.
* #param token A cancellation token.
* #return An array of completion items or a thenable that resolves to an array of completion items.
*/
provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionList | InlineCompletionItem[]>;
}
i dont know how to achieve this.
Related
What I would like is to write something like this:
/**
* Takes a foo and {#link grokelates} it.
*/
function doSomething(foo) {
}
And have "grokelates" be a link to more detail on what "grokelate" means, but because I'm going to have functions dealing with grokelation all over my code base, I'd like to write that definition once and link to it in multiple places.
Is this possible?
To be clear, grokelates is not a function. It's just a word I want to define, but not have to define in-line everywhere I use it. I basically want to write a glossary file and be able to link to definitions from that glossary in my JSDoc.
Ideally this would also be in a way the VS Code picks it up and lets someone navigate to that definition on hover.
Yes there is. When you run jsdoc to generate your documentation, you can pass it any filetype you wish. A standard practice is to create one or more *.jsdoc files which contain doclet comments (those that begin with /**) to describe features you expect to use elsewhere in your code. For instance:
// filename: grokelation.jsdoc
/**
* #module grokelates
*/
/**
* #name Grokelate
* #memberof module:grokelates
* #description
* Here is the description of the grokelation process.
*
* #example
* var g = new Grokelate(opts);
*/
Then, when you wish to reference this new object elsewhere in your documentation, simply use its long name module:grokelates~Grokelate where you can consider the ~ glyph to mean "member of".
In your example above, you'd say {#link module:grokelates~Grokelate}.
We have Azure DevOps extension in which one of build task we used to obtain data from release build log to display in release summary tab.
This build task works perfect for the single Agent Job pipelines, but we have come across a scenario that there are multiple Agent jobs available and we couldn’t retrieve data once our build task added to second or later agent job.
Below is how we get data from task logs. However, this method only iterates trough first job and does not access second.
We are using release management client from "ReleaseManagement/Core/RestClient" in the VSS SDK
//getting list of tasks
var t = await rmClient.getTasks(VSS.getWebContext().project.id, release.id, environment.id);
// iterate trough task list until required task found
for (var i = 0; i < t.length; i++) {
var currentTask = t[i];
var logData = await rmClient.getLog(VSS.getWebContext().project.id, release.id, environment.id, currentTask.id, environment.deploySteps.length);
// Identify task based on data in it
break;
}
As per the SDK implementation there are two methods available for retrieve logs getlog which returns log of task as a string (the one we use now) and getLogs which returns all Logs as ArrayBuffer
/**
* [Preview API] Gets logs
*
* #param {string} project - Project ID or project name
* #param {number} releaseId - Id of the release.
* #param {number} environmentId - Id of release environment.
* #param {number} taskId - ReleaseTask Id for the log.
* #param {number} attemptId - Id of the attempt.
* #return IPromise<string>
*/
getLog(project: string, releaseId: number, environmentId: number, taskId: number, attemptId?: number): IPromise<string>;
/**
* [Preview API] Get logs for a release Id.
*
* #param {string} project - Project ID or project name
* #param {number} releaseId - Id of the release.
* #return IPromise<ArrayBuffer>
*/
getLogs(project: string, releaseId: number): IPromise<ArrayBuffer>;
As you can observe there is no place to specify agent job in these methods.
If someone has experience with this,
Is it possible to obtain log data from second or later job in the release pipeline? sample / documentation would be much helpful.
I tried to get data from array buffer, but it ends up getting out of boundary error when I try to convert ArrayBuffer to string.
Any thoughts, advise highly appreciated 😊
To get a task log from an Agent Job, you also need releaseDeployPhaseId. Check the following api:
https://learn.microsoft.com/en-us/rest/api/azure/devops/release/releases/get%20task%20log?view=azure-devops-rest-6.0
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version=6.0-preview.2
You could call REST APIs from your extension as this documentation mentioned:
https://learn.microsoft.com/en-us/azure/devops/extend/develop/auth?view=azure-devops#calling-rest-apis-from-your-extension
I have a javascript library for communicating with server APIS, written in modern ECMAScript.
It is fully documented with JSDoc comments:
/**
* #class - TODOS API Client class
*/
class todosApi {
/**
* Gets Todos, given the parameters
* #param {number} personId
* #param {number} [year]
* #param {number} [month]
* #param {number} [todoTypeId]
* #returns {Object} - api response object, data will be array of todos
*/
fetchTodos = async (....
}
When using this API in the unit tests in this project, in Visual Studio code, I have excellent intellisense from these comments, and it's a beautiful thing.
However, this library is used by/referenced in a separate react application created with create-react-app. When I run this through babel to transpile into a format that is consumable by my create-react-app app, it ends up like this:
/**
* #class - TODOS API Client class
*/
class todosApi {
_defineProperty(this, "fetchTodos", async (personId, eventYear, eventMonth, todoTypeId) => {
}
And I lose my intellisense for fetchTodos, and actually the class itself because of how it is exported in and index.js file. babel does have the option to include comments by default, however the class gets a little mangled in transpiling and loses some comments.
Is there any way to transpile and still preserve this intellisense for VS Code?
Use tsd-jsdoc to create a types.d.ts file.
In your package.json add a script to run ...
jsdoc -r src -t node_modules/tsd-jsdoc/dist -d lib
And set types to lib/types.d.js.
Include that script as part of prepublishOnly so it runs before every npm publish.
I can't get the google sheets autocomplete to show my custom function even when I use Google's version (see below). I have the jsdoc info correctly formatted, but it still doesn't show up. I'm sure I'm just overlooking something stupid, but I can't find it. So what am I missing?
Google's demo code:
/**
* Multiplies the input value by 2.
*
* #param {number} input The value to multiply.
* #customfunction
*/
function double(input) {
return input * 2;
}
BTW, I'm using Chrome to develop my custom functions. Also, my function works, just no autocomplete. All the built-in functions autocomplete works.
Thanks in advance for the help!
Brad
I managed to get the custom function autocomplete working yesterday. It seems to only work with container-bound scripts, so any JSDoc info inside a script being used as a library will not come across. To verify it works, I did the following:
Create new Google Sheet
Open Script Editor
Enter the following in the script:
/**
* Returns amount multiplied by itself.
*
* #param {Number} amount The amount to be multiplied by itself.
* #return {Number} The amount multiplied by itself.
* #customfunction
*/
function test(amount) {
return amount*amount;
}
Then, when entering =test into a cell in the spreadsheet, the information above the function appears in the autocomplete hint, like any other built-in spreadsheet function.
I created an extension using Extension Builder, and included a backend module, under the web section. In the generated code, there are two constants for the storage pid: one for plugins and one for modules.
Now I like my module to use the storage pid from the selected page or folder in the pagetree, like page, list, or template modules do. How can I use storage pid from pagetree instead of using a constant, in a backend module?
To get the selected page from the page tree in your backend module, one way is to simply get the id param, ideally in your initializer.
Since extbase reads the storage pid from your module (or plugin for the frontend) settings, you can just override the storagePid part so you don't have to set the pid for each query / otherwise in your repositories.
The following should work. However, I use this in a CommandController and not in a controller used in the backend. I hadn't to change anything there because the repositories automatically scoped records to the selected page.
class Tx_MyExt_Controller_BackendController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* #var Tx_Extbase_Configuration_ConfigurationManagerInterface
* #inject
*/
protected $configurationManager;
/**
* #var int Current page
*/
protected $pageId;
/**
* Action initializer
*
* #return void
*/
protected function initializeAction()
{
$this->pageId = (int)t3lib_div::_GP('id');
$frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId));
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration));
}
}