Skip to content

Commit

Permalink
Update Volar
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Dec 7, 2023
1 parent 07017a3 commit 3c30ac3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
},
"dependencies": {
"@mdx-js/language-service": "0.2.0",
"@volar/language-server": "2.0.0-alpha.0",
"@volar/language-server": "2.0.0-alpha.2",
"load-plugin": "^5.0.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"volar-service-markdown": "0.0.18",
"volar-service-typescript": "0.0.18",
"volar-service-markdown": "0.0.19",
"volar-service-typescript": "0.0.19",
"vscode-uri": "^3.0.0"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions packages/language-service/lib/language-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ function findLastOffset(node) {
}

/**
* @param {string} fileId
* @param {string} fileName
* @param {IScriptSnapshot} snapshot
* @param {typeof import('typescript')} ts
* @param {Processor} processor
* @returns {VirtualFile[]}
*/
function getVirtualFiles(fileId, snapshot, ts, processor) {
function getVirtualFiles(fileName, snapshot, ts, processor) {
const mdx = snapshot.getText(0, snapshot.getLength())
/** @type {VirtualFile['mappings']} */
const jsxMappings = []
Expand All @@ -104,7 +104,7 @@ function getVirtualFiles(fileId, snapshot, ts, processor) {
return [
{
embeddedFiles: [],
id: fileId + '.jsx',
fileName: fileName + '.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: ts.ScriptKind.JSX
Expand All @@ -114,7 +114,7 @@ function getVirtualFiles(fileId, snapshot, ts, processor) {
},
{
embeddedFiles: [],
id: fileId + '.md',
fileName: fileName + '.md',
languageId: 'markdown',
mappings: mdMappings,
snapshot: ts.ScriptSnapshot.fromString(mdx)
Expand Down Expand Up @@ -143,7 +143,7 @@ function getVirtualFiles(fileId, snapshot, ts, processor) {
const frontmatterStart = frontmatterWithFences.indexOf(node.value)
virtualFiles.push({
embeddedFiles: [],
id: fileId + '.yaml',
fileName: fileName + '.yaml',
languageId: 'yaml',
mappings: [
{
Expand Down Expand Up @@ -308,7 +308,7 @@ function getVirtualFiles(fileId, snapshot, ts, processor) {
virtualFiles.unshift(
{
embeddedFiles: [],
id: fileId + '.jsx',
fileName: fileName + '.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: ts.ScriptKind.JSX
Expand All @@ -318,7 +318,7 @@ function getVirtualFiles(fileId, snapshot, ts, processor) {
},
{
embeddedFiles: [],
id: fileId + '.md',
fileName: fileName + '.md',
languageId: 'markdown',
mappings: mdMappings,
snapshot: ts.ScriptSnapshot.fromString(mdShadow)
Expand Down
2 changes: 1 addition & 1 deletion packages/language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@types/mdast": "^4.0.0",
"@types/unist": "^3.0.0",
"@volar/language-core": "2.0.0-alpha.0",
"@volar/language-core": "2.0.0-alpha.2",
"remark-mdx": "^3.0.0",
"remark-parse": "^11.0.0",
"unified": "^11.0.0",
Expand Down
56 changes: 28 additions & 28 deletions packages/language-service/test/language-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('create virtual file w/ mdxjsEsm', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -37,7 +37,7 @@ test('create virtual file w/ mdxjsEsm', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: 2
Expand Down Expand Up @@ -80,7 +80,7 @@ test('create virtual file w/ mdxjsEsm', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [],
snapshot: snapshotFromLines(' ', '')
Expand All @@ -97,7 +97,7 @@ test('create virtual file w/ mdxFlowExpression', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -118,7 +118,7 @@ test('create virtual file w/ mdxFlowExpression', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: 2
Expand Down Expand Up @@ -161,7 +161,7 @@ test('create virtual file w/ mdxFlowExpression', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [],
snapshot: snapshotFromLines(' ', '')
Expand All @@ -185,7 +185,7 @@ test('create virtual file w/ mdxJsxFlowElement w/ children', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -206,7 +206,7 @@ test('create virtual file w/ mdxJsxFlowElement w/ children', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: 2
Expand Down Expand Up @@ -270,7 +270,7 @@ test('create virtual file w/ mdxJsxFlowElement w/ children', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [
{
Expand Down Expand Up @@ -308,7 +308,7 @@ test('create virtual file w/ mdxJsxFlowElement w/o children', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -329,7 +329,7 @@ test('create virtual file w/ mdxJsxFlowElement w/o children', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
mappings: [
{
Expand Down Expand Up @@ -372,7 +372,7 @@ test('create virtual file w/ mdxJsxFlowElement w/o children', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [],
snapshot: snapshotFromLines(' ', '')
Expand All @@ -389,7 +389,7 @@ test('create virtual file w/ mdxJsxTextElement', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -410,7 +410,7 @@ test('create virtual file w/ mdxJsxTextElement', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: 2
Expand Down Expand Up @@ -453,7 +453,7 @@ test('create virtual file w/ mdxJsxTextElement', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [
{
Expand Down Expand Up @@ -484,7 +484,7 @@ test('create virtual file w/ mdxTextExpression', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -505,7 +505,7 @@ test('create virtual file w/ mdxTextExpression', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
typescript: {
scriptKind: 2
Expand Down Expand Up @@ -548,7 +548,7 @@ test('create virtual file w/ mdxTextExpression', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [
{
Expand Down Expand Up @@ -592,7 +592,7 @@ test('create virtual file w/ syntax error', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -613,7 +613,7 @@ test('create virtual file w/ syntax error', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
mappings: [],
snapshot: snapshotFromLines(
Expand All @@ -640,7 +640,7 @@ test('create virtual file w/ syntax error', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [],
snapshot: snapshotFromLines('<', '')
Expand All @@ -657,7 +657,7 @@ test('create virtual file w/ yaml frontmatter', () => {
const file = module.createVirtualFile('file:///test.mdx', 'mdx', snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -678,7 +678,7 @@ test('create virtual file w/ yaml frontmatter', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
mappings: [],
snapshot: snapshotFromLines(
Expand Down Expand Up @@ -711,7 +711,7 @@ test('create virtual file w/ yaml frontmatter', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [
{
Expand All @@ -732,7 +732,7 @@ test('create virtual file w/ yaml frontmatter', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.yaml',
fileName: '/test.mdx.yaml',
languageId: 'yaml',
mappings: [
{
Expand Down Expand Up @@ -768,7 +768,7 @@ test('update virtual file', () => {
module.updateVirtualFile(/** @type {VirtualFile} */ (file), snapshot)

assert.deepEqual(file, {
id: 'file:///test.mdx',
fileName: '/test.mdx',
languageId: 'mdx',
mappings: [
{
Expand All @@ -789,7 +789,7 @@ test('update virtual file', () => {
embeddedFiles: [
{
embeddedFiles: [],
id: 'file:///test.mdx.jsx',
fileName: '/test.mdx.jsx',
languageId: 'javascriptreact',
mappings: [],
snapshot: snapshotFromLines(
Expand Down Expand Up @@ -818,7 +818,7 @@ test('update virtual file', () => {
},
{
embeddedFiles: [],
id: 'file:///test.mdx.md',
fileName: '/test.mdx.md',
languageId: 'markdown',
mappings: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"@types/mdast": "^4.0.0",
"@types/node": "^20.0.0",
"@types/vscode": "^1.82.0",
"@volar/language-server": "2.0.0-alpha.0",
"@volar/vscode": "2.0.0-alpha.0",
"@volar/language-server": "2.0.0-alpha.2",
"@volar/vscode": "2.0.0-alpha.2",
"@vscode/vsce": "^2.0.0",
"esbuild": "^0.19.0",
"mdast-util-to-markdown": "^2.0.0",
Expand Down

0 comments on commit 3c30ac3

Please sign in to comment.