Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

search additionalLanguages for language spec#42055

Merged
sqs merged 1 commit into
mainfrom
sqs/fix-js-refs
Sep 25, 2022
Merged

search additionalLanguages for language spec#42055
sqs merged 1 commit into
mainfrom
sqs/fix-js-refs

Conversation

@sqs

@sqs sqs commented Sep 25, 2022

Copy link
Copy Markdown
Member

javascript is an additionalLanguage in the typescript language spec. When looking for a language spec by languageID, we need to also search the additionalLanguages.

NOTE: I haven't thoroughly tested this, and I don't have much experience in this part of the codebase. This PR should be taken over by a code intel team member.

Fixes https://github.com/sourcegraph/sourcegraph/issues/41745.

Test plan

TBD, on https://sourcegraph.test:3443/github.com/sourcegraph/sourcegraph/-/blob/gulpfile.js?L37:3#tab=references :
image

App preview:

Check out the client app preview documentation to learn more.

`javascript` is an `additionalLanguage` in the `typescript` language spec. When looking for a language spec by languageID, we need to also search the `additionalLanguages`.

Fixes https://github.com/sourcegraph/sourcegraph/issues/41745.
@sqs sqs requested a review from a team September 25, 2022 17:08
@cla-bot cla-bot Bot added the cla-signed label Sep 25, 2022
@sqs sqs marked this pull request as draft September 25, 2022 17:09
@sqs sqs added release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases 4.0 items under consideration for 4.0 labels Sep 25, 2022

@olafurpg olafurpg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. I’m away from the computer until Tuesday so I can’t test this locally, but this looks like a very safe diff to merge and patch.

@olafurpg olafurpg marked this pull request as ready for review September 25, 2022 20:59
@sqs

sqs commented Sep 25, 2022

Copy link
Copy Markdown
Member Author

@olafurpg OK, thanks. I will merge this so that we can get it deployed on Sourcegraph.com and fix the issue there. I'll separately ensure another code intel team member follows up on Monday morning to see about patching this into 4.0 and what else (if anything) is needed to fix this issue comprehensively. cc @lguychard

@chrismwendt chrismwendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM2, this essentially restores the code from prior to https://github.com/sourcegraph/sourcegraph/pull/41128, specifically this part:

CleanShot 2022-09-25 at 15 10 44@2x

@sqs

sqs commented Sep 25, 2022

Copy link
Copy Markdown
Member Author

@chrismwendt (https://github.com/sourcegraph/sourcegraph/pull/42055#pullrequestreview-1119456090):

LGTM2, this essentially restores the code from prior to https://github.com/sourcegraph/sourcegraph/pull/41128, specifically this part: ...

Do you or @olafurpg know why the lookup in additionalLanguages was removed when the code was ported over? I just want to see if there was some reason for doing that, and this PR that reverts it would have unintended consequences.

@sqs sqs merged commit 13694ea into main Sep 25, 2022
@sqs sqs deleted the sqs/fix-js-refs branch September 25, 2022 21:45
@chrismwendt

Copy link
Copy Markdown
Contributor

I don't know, maybe it was some kind of copy-paste mistake.

camdencheek pushed a commit that referenced this pull request Sep 26, 2022
`javascript` is an `additionalLanguage` in the `typescript` language spec. When looking for a language spec by languageID, we need to also search the `additionalLanguages`.

Fixes https://github.com/sourcegraph/sourcegraph/issues/41745.
@olafurpg

Copy link
Copy Markdown
Contributor

I don't think this was caused by a copy-paste mistake. The spec.languageID === languageID || spec.additionalLanguages?.includes(languageID) condition doesn't exist in the original code-intel-extensions repo

https://sourcegraph.com/search?q=context:global+repo:code-intel-extensions+additionalLanguages&patternType=lucky

CleanShot 2022-09-27 at 10 51 58

From what I can tell, additional languages were only used by the extension template generator to register an onLanguage:LANGUAGE activation event. The copy-pasted code came from the activate function

export const activate = async (context: sourcegraph.ExtensionContext = DUMMY_CTX): Promise<void> => {
    const languageSpec = languageSpecs.find(spec => spec.languageID === languageID)
    if (languageSpec === undefined) {
        throw new Error(`Unknown language ${languageID}`)
    }

Source https://sourcegraph.com/github.com/sourcegraph/code-intel-extensions@b97feb343cbe5d1b03582181ee13fd459587db91/-/blob/template/src/extension.ts?L62-66

@olafurpg

Copy link
Copy Markdown
Contributor

@sqs Nice job finding the root cause of the issue! I spent a while trying to understand the root cause of the problem before opening the but didn't understand what was going on

sashaostrikov pushed a commit that referenced this pull request Sep 29, 2022
`javascript` is an `additionalLanguage` in the `typescript` language spec. When looking for a language spec by languageID, we need to also search the `additionalLanguages`.

Fixes https://github.com/sourcegraph/sourcegraph/issues/41745.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

4.0 items under consideration for 4.0 cla-signed release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: javascript is not defined

3 participants