Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion generator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function main(): void {
)
shell.sed(
'-i',
/"description": ".*"/,
/^ "description": ".*"/,
`"description": "Provides basic code intelligence for ${stylized} using the Sourcegraph search API"`,
'package.json'
)
Expand All @@ -114,6 +114,26 @@ function main(): void {
`"url": "https://github.com/sourcegraph/sourcegraph-${languageID}"`,
'package.json'
)
shell.sed(
'-i',
/GENERATOR:IMPRECISE_RESULTS_URL/,
langSpec.hasLanguageServer
? `https://github.com/sourcegraph/sourcegraph-${
langSpec.handlerArgs.languageID
}`
: `https://github.com/sourcegraph/sourcegraph-${
langSpec.handlerArgs.languageID
}#limitations`,
'package.json'
)
shell.sed(
'-i',
/"These locations are computed using heuristics.*"/,
langSpec.hasLanguageServer
? `These locations are computed using heuristics. Use a language server for precise results."`
: `These locations are computed using heuristics.`,
'package.json'
)
shell.sed('-i', /\$LANGNAME\b/, languageID, 'README.md')
shell.sed('-i', /\$LANG\b/, stylized, 'README.md')
shell.sed(
Expand Down
4 changes: 4 additions & 0 deletions languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
export type LanguageSpec = {
handlerArgs: Omit<HandlerArgs, 'sourcegraph'>
stylized: string
hasLanguageServer?: boolean
}

const cStyleBlock = {
Expand Down Expand Up @@ -59,6 +60,7 @@ export const languages: LanguageSpec[] = [
commentStyle: cStyle,
},
stylized: 'TypeScript',
hasLanguageServer: true,
},
{
handlerArgs: {
Expand All @@ -75,6 +77,7 @@ export const languages: LanguageSpec[] = [
},
},
stylized: 'Python',
hasLanguageServer: true,
},
{
handlerArgs: {
Expand All @@ -98,6 +101,7 @@ export const languages: LanguageSpec[] = [
},
},
stylized: 'Go',
hasLanguageServer: true,
},
{
handlerArgs: {
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sourcegraph/basic-code-intel",
"version": "6.0.5",
"version": "6.0.6",
"description": "Common library for providing basic code intelligence in Sourcegraph extensions",
"repository": {
"type": "git",
Expand Down
8 changes: 6 additions & 2 deletions package/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { Handler, documentSelector, HandlerArgs } from './handler'
// No-op for Sourcegraph versions prior to 3.0-preview
const DUMMY_CTX = { subscriptions: { add: (_unsubscribable: any) => void 0 } }

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

export function activateBasicCodeIntel(
args: HandlerArgs
args: Omit<HandlerArgs, 'sourcegraph'>
): (ctx: sourcegraph.ExtensionContext) => void {
return function activate(
ctx: sourcegraph.ExtensionContext = DUMMY_CTX
): void {
const h = new Handler(args)
const h = new Handler({ ...args, sourcegraph })

sourcegraph.internal.updateContext({ isImprecise: true })

ctx.subscriptions.add(
sourcegraph.languages.registerHoverProvider(
Expand Down
22 changes: 22 additions & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@
"*"
],
"contributes": {
"actions": [
{
"id": "impreciseResults",
"title": "Imprecise results",
"command": "open",
"commandArguments": [
"GENERATOR:IMPRECISE_RESULTS_URL"
],
"actionItem": {
"label": "Imprecise results",
"description": "These locations are computed using heuristics. (If available:) use a language server for precise results."
}
}
],
"menus": {
"panel/toolbar": [
{
"action": "impreciseResults",
"when": "isImprecise"
}
]
},
"configuration": {
"title": "Basic code intelligence settings",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion template/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import * as spec from '../../languages'

export function activate(ctx: sourcegraph.ExtensionContext): void {
for (const language of spec.languages) {
activateBasicCodeIntel({ ...language.handlerArgs, sourcegraph })(ctx)
activateBasicCodeIntel(language.handlerArgs)(ctx)
}
}