Skip to content

Conversation

slavik-lvovsky
Copy link
Member

No description provided.

const contributorId = _.get(uiOptions, "contributorId");
const snippetName = _.get(uiOptions, "snippetName");
if (contributorId && snippetName) {
const api = await Contributors.apiMap.get(contributorId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel to me like there is no await for the activate() method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep a getApi method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension.activate() returns Thenable, so it is OK to use await

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a new test with activate method

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        const apiPromise = Contributors.apiMap.get(contributorId);
        const api = await 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Contributors.getSnippet(_.get(uiOptions, "snippet", uiOptions)).then(snippet => {
if (_.isNil(snippet)) {
this.webViewPanel.dispose();
return vscode.window.showErrorMessage("Can not find snippet.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider remove the vscode notification. and only only log it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked to leave it, didn't we ?

this.initWebviewPanel();
Contributors.getSnippet(_.get(uiOptions, "snippet", uiOptions)).then(snippet => {
if (_.isNil(snippet)) {
this.webViewPanel.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯

const contributorId = _.get(uiOptions, "contributorId");
const snippetName = _.get(uiOptions, "snippetName");
if (contributorId && snippetName) {
const api = await Contributors.apiMap.get(contributorId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        const apiPromise = Contributors.apiMap.get(contributorId);
        const api = await 

}
}
private static getApiPromise(extension: vscode.Extension<any>) {
return (extension.isActive ? extension.exports : extension.activate());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension.exports is not a promise, but we can keep the name.

@tomer-epstein
Copy link
Contributor

as we just discuss. lets activate (if not already active) only when trying to get the snippet, and then update the apiMap.

Comment on lines 31 to 33
const extensionName: string = _.get(extension, "packageJSON.name");
const extensionPublisher: string = _.get(extension, "packageJSON.publisher");
const extensionId = `${extensionPublisher}.${extensionName}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static getExtensionId(extension: vscode.Extension)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

private static getApiPromise(extension: vscode.Extension<any>) {
return (extension.isActive ? extension.exports : extension.activate());
return (extension.isActive ? Promise.resolve(extension.exports) : extension.activate());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to wrap extension.exports with Promise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const contributorId = _.get(contributerInfo, "contributorId");
const snippetName = _.get(contributerInfo, "snippetName");
const extension = Contributors.getContributorExtension(contributorId);
if (extension) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if extension not found?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case tab is closed and we show error message

if (!extension.isActive) {
public static async getSnippet(contributerInfo: any) {
const contributorId = _.get(contributerInfo, "contributorId");
const snippetName = _.get(contributerInfo, "snippetName");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move into the try block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

tomer-epstein
tomer-epstein previously approved these changes Nov 24, 2020
@slavik-lvovsky slavik-lvovsky merged commit 90b7e42 into master Nov 24, 2020
@slavik-lvovsky slavik-lvovsky deleted the refactoring branch November 24, 2020 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants