Skip to content

Commit

Permalink
Merge branch 'main' into fix-remove-experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 authored Feb 1, 2023
2 parents 171440e + 6fe32b5 commit 70ca4db
Show file tree
Hide file tree
Showing 26 changed files with 869 additions and 858 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file.

## [0.6.0] - 2023-02-01

### 🚀 New Features and Enhancements

- Implement simple onDefinition feature in LSP [#3175](https://github.com/iterative/vscode-dvc/pull/3175) by [@mattseddon](https://github.com/mattseddon)

### 🐛 Bug Fixes

- Limit language server reach to dvc yaml files [#3194](https://github.com/iterative/vscode-dvc/pull/3194) by [@mattseddon](https://github.com/mattseddon)

### 🔨 Maintenance

- Rename files associated with LSP [#3185](https://github.com/iterative/vscode-dvc/pull/3185) by [@mattseddon](https://github.com/mattseddon)
- Remove unnecessary dependencies from LSP [#3184](https://github.com/iterative/vscode-dvc/pull/3184) by [@mattseddon](https://github.com/mattseddon)
- Remove unnecessary interface from LSP [#3181](https://github.com/iterative/vscode-dvc/pull/3181) by [@mattseddon](https://github.com/mattseddon)

## [0.5.40] - 2023-01-30

### 🚀 New Features and Enhancements
Expand Down
8 changes: 4 additions & 4 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"extensionDependencies": [
"vscode.git"
],
"version": "0.5.40",
"version": "0.6.0",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down Expand Up @@ -1606,7 +1606,7 @@
"@types/chai-as-promised": "7.1.5",
"@types/copy-webpack-plugin": "10.1.0",
"@types/fs-extra": "11.0.1",
"@types/jest": "29.2.6",
"@types/jest": "29.4.0",
"@types/js-yaml": "4.0.5",
"@types/lodash.clonedeep": "4.5.7",
"@types/lodash.get": "4.4.7",
Expand All @@ -1632,8 +1632,8 @@
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "11.0.0",
"fork-ts-checker-webpack-plugin": "7.3.0",
"jest": "29.3.1",
"jest-environment-node": "29.3.1",
"jest": "29.4.0",
"jest-environment-node": "29.4.0",
"lint-staged": "13.1.0",
"mocha": "10.2.0",
"mock-require": "3.0.3",
Expand Down
3 changes: 3 additions & 0 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { Setup } from './setup'
import { definedAndNonEmpty } from './util/array'
import { stopProcesses } from './processExecution'
import { Flag } from './cli/dvc/constants'
import { LanguageClient } from './languageClient'

export class Extension extends Disposable {
protected readonly internalCommands: InternalCommands
Expand Down Expand Up @@ -255,6 +256,8 @@ export class Extension extends Disposable {

void showWalkthroughOnFirstUse(env.isNewAppInstall)
this.dispose.track(recommendRedHatExtensionOnce())

this.dispose.track(new LanguageClient())
}

public async initialize() {
Expand Down
12 changes: 12 additions & 0 deletions extension/src/fileSystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,15 @@ export const getBinDisplayText = (
? '.' + sep + relative(workspaceRoot, path)
: path
}

export const readFileContents = (
uriString: string
): { contents: string } | null => {
try {
const uri = Uri.parse(uriString)
if (!isDirectory(uri.fsPath)) {
return { contents: readFileSync(uri.fsPath, 'utf8') }
}
} catch {}
return null
}
53 changes: 53 additions & 0 deletions extension/src/languageClient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { workspace } from 'vscode'
import {
LanguageClient as Client,
LanguageClientOptions,
ServerOptions,
TransportKind
} from 'vscode-languageclient/node'
import { documentSelector, serverModule } from 'dvc-vscode-lsp'
import { Disposable } from '../class/dispose'
import { readFileContents } from '../fileSystem'

export class LanguageClient extends Disposable {
private client: Client

constructor() {
super()

const clientOptions: LanguageClientOptions = {
documentSelector,
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/dvc.yaml')
}
}

this.client = this.dispose.track(
new Client(
'dvc-vscode-lsp',
'DVC Language Server',
this.getServerOptions(),
clientOptions
)
)

this.dispose.track(
this.client.onRequest('readFileContents', readFileContents)
)

void this.client.start()
}

private getServerOptions(): ServerOptions {
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }

return {
debug: {
module: serverModule,
options: debugOptions,
transport: TransportKind.ipc
},
run: { module: serverModule, transport: TransportKind.ipc }
}
}
}
83 changes: 0 additions & 83 deletions extension/src/lspClient/languageClient.ts

This file was deleted.

24 changes: 23 additions & 1 deletion extension/src/test/suite/fileSystem/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { join, resolve } from 'path'
import process from 'process'
import { Uri } from 'vscode'
import { afterEach, beforeEach, describe, it, suite } from 'mocha'
import { expect } from 'chai'
import { Disposable } from '@hediet/std/disposable'
import { restore } from 'sinon'
import { ensureFileSync, removeSync, writeFileSync } from 'fs-extra'
import { dvcDemoPath } from '../../util'
import { checkSignalFile, exists, getGitPath } from '../../../fileSystem'
import {
checkSignalFile,
exists,
getGitPath,
readFileContents
} from '../../../fileSystem'
import { gitPath } from '../../../cli/git/constants'
import { GitReader } from '../../../cli/git/reader'
import { standardizePath } from '../../../fileSystem/path'
Expand Down Expand Up @@ -93,4 +99,20 @@ suite('File System Test Suite', () => {
expect(exists(mockSignalFilePath)).to.be.false
})
})

describe('readFileContents', () => {
it('should read the contents of a file when it exists', () => {
const uriString = Uri.file(join(dvcDemoPath, 'train.py')).toString()

const file = readFileContents(uriString)
expect(file?.contents).to.contain('main()')
})

it('should return null when the file cannot be found', () => {
const uriString = 'file:///some/fun/file.txt'

const contents = readFileContents(uriString)
expect(contents).to.be.null
})
})
})
9 changes: 3 additions & 6 deletions languageServer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"typescript": "*"
},
"dependencies": {
"jsonc-parser": "3.2.0",
"jsonpath-plus": "7.2.0",
"lodash": "4.17.21",
"vscode-languageserver": "8.0.2",
"vscode-languageserver-textdocument": "1.0.8",
"vscode-uri": "3.0.7",
Expand All @@ -30,15 +27,15 @@
"devDependencies": {
"@swc/core": "1.3.28",
"@swc/jest": "0.2.24",
"@types/jest": "29.2.6",
"@types/jest": "29.4.0",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "11.0.0",
"fork-ts-checker-webpack-plugin": "7.3.0",
"ts-loader": "9.4.2",
"lint-staged": "13.1.0",
"jest": "29.3.1",
"jest": "29.4.0",
"webpack": "5.75.0",
"webpack-cli": "5.0.1",
"jest-environment-node": "29.3.1"
"jest-environment-node": "29.4.0"
}
}
7 changes: 0 additions & 7 deletions languageServer/src/ITextDocumentWrapper.ts

This file was deleted.

Loading

0 comments on commit 70ca4db

Please sign in to comment.