Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion vscode/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
],
"activationEvents": [
"onLanguage:sql",
"onLanguage:python"
"onLanguage:python",
"onLanguage:yaml"
],
"extensionKind": [
"workspace"
Expand Down
12 changes: 11 additions & 1 deletion vscode/extension/src/lsp/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@ export class LSPClient implements Disposable {
},
}
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', pattern: `**/*.sql` }],
documentSelector: [
{ scheme: 'file', pattern: `**/*.sql` },
{
scheme: 'file',
pattern: '**/external_models.yaml',
},
{
scheme: 'file',
pattern: '**/external_models.yml',
},
],
diagnosticCollectionName: 'sqlmesh',
outputChannel: outputChannel,
}
Expand Down
68 changes: 68 additions & 0 deletions vscode/extension/tests/external_models.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import os from 'os'
import { openServerPage, SUSHI_SOURCE_PATH } from './utils'
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
import { test, expect } from './fixtures'
import fs from 'fs-extra'
import path from 'path'

test.describe('External model files trigger lsp', () => {
test('external_models.yaml', async ({ page, sharedCodeServer }) => {
const file = 'external_models.yaml'

const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-sushi-'),
)
await fs.copy(SUSHI_SOURCE_PATH, tempDir)

// Assert external_models.yaml exists
const externalModelsYamlPath = path.join(tempDir, file)
expect(await fs.pathExists(externalModelsYamlPath)).toBe(true)

await createPythonInterpreterSettingsSpecifier(tempDir)
await openServerPage(page, tempDir, sharedCodeServer)

// Wait for the models folder to be visible
Comment thread
benfdking marked this conversation as resolved.
Outdated
await page.waitForSelector('text=models')

// Click on the models folder, excluding external_models
Comment thread
benfdking marked this conversation as resolved.
Outdated
await page
.getByRole('treeitem', { name: file, exact: true })
.locator('a')
.click()

await page.waitForSelector('text=raw.demographics')
await page.waitForSelector('text=Loaded SQLMesh Context')
})

test('external_models.yml', async ({ page, sharedCodeServer }) => {
const file = 'external_models.yml'

const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-sushi-'),
)
await fs.copy(SUSHI_SOURCE_PATH, tempDir)

// Move external_models.yaml to external_models.yml
const externalModelsYamlPath = path.join(tempDir, 'external_models.yaml')
const externalModelsYmlPath = path.join(tempDir, file)
await fs.rename(externalModelsYamlPath, externalModelsYmlPath)

// Assert external_models.yml exists
expect(await fs.pathExists(externalModelsYmlPath)).toBe(true)

await createPythonInterpreterSettingsSpecifier(tempDir)
await openServerPage(page, tempDir, sharedCodeServer)

// Wait for the models folder to be visible
Comment thread
benfdking marked this conversation as resolved.
Outdated
await page.waitForSelector('text=models')

// Click on the models folder, excluding external_models
Comment thread
benfdking marked this conversation as resolved.
Outdated
await page
.getByRole('treeitem', { name: file, exact: true })
.locator('a')
.click()

await page.waitForSelector('text=raw.demographics')
await page.waitForSelector('text=Loaded SQLMesh Context')
})
})
Loading