diff --git a/contributors/.all-contributorsrc b/contributors/.all-contributorsrc
index 49e601b7f..29a94abca 100644
--- a/contributors/.all-contributorsrc
+++ b/contributors/.all-contributorsrc
@@ -55,8 +55,10 @@
{ "type": "ideas", "link": "issues/402", "text": "#402" },
{ "type": "bug", "link": "issues/458", "text": "#458" },
{ "type": "bug", "link": "issues/487", "text": "#487" },
+ { "type": "bug", "link": "issues/515", "text": "#515" },
{ "type": "bug", "link": "issues/516", "text": "#516" },
{ "type": "bug", "link": "issues/517", "text": "#517" },
+ { "type": "bug", "link": "issues/519", "text": "#519" },
{ "type": "bug", "link": "issues/520", "text": "#520" }
]
},
diff --git a/contributors/2.1.0.md b/contributors/2.1.0.md
index df0a7e2f0..139db572a 100644
--- a/contributors/2.1.0.md
+++ b/contributors/2.1.0.md
@@ -15,7 +15,7 @@ A big _thank you_ goes to these wonderful people! (sorted by the Unicode of name
ChapterII | π #467 |
- ChenCMD | β¨ #402 π #458 π #487 π #516 π #517 π #520 |
+ ChenCMD | β¨ #402 π #458 π #487 π #515 π #516 π #517 π #519 π #520 |
ColorRain_Tree | π (οΌΒ°ΠΒ°) |
diff --git a/src/locales/en.json b/src/locales/en.json
index 9c61a316a..78d7e6eea 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -132,6 +132,7 @@
"quote": "a quote (β'β or β\"β)",
"score-holder": "a score holder",
"server.checking-file": "Checking β%0%β",
+ "server.fixing-workspace": "Fixing all auto-fixable problems in the workspace",
"server.initializing": "Initialize DHP features",
"server.new-version": "The Datapack Language Server has been updated to a newer version: %0%",
"server.regenerating-cache": "Regenerating cache",
diff --git a/src/parsers/EntityArgumentParser.ts b/src/parsers/EntityArgumentParser.ts
index caba118a5..9af30b9cb 100644
--- a/src/parsers/EntityArgumentParser.ts
+++ b/src/parsers/EntityArgumentParser.ts
@@ -416,8 +416,6 @@ export class EntityArgumentParser extends ArgumentParser {
}
export function getNbtdocRegistryId(entity: EntityNode): null | string {
- console.log(require('util').inspect(entity, true, null))
-
if (entity.variable === 'a' || entity.variable === 'p' || entity.variable === 'r') {
return 'minecraft:player'
}
diff --git a/src/server.ts b/src/server.ts
index 94f9a8bc3..c29958b49 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -576,14 +576,16 @@ connection.onInitialized(() => {
})
break
}
- case 'datapack.fixWorkspace':
+ case 'datapack.fixWorkspace': {
+ const progress = await connection.window.createWorkDoneProgress()
+ progress.begin(locale('server.fixing-workspace'))
for (const root of roots) {
const dataPath = path.join(root.fsPath, 'data')
const namespaces = fs.pathExistsSync(dataPath) ? await fs.readdir(dataPath) : []
for (const namespace of namespaces) {
const namespacePath = path.join(dataPath, namespace)
const functionsPath = path.join(namespacePath, 'functions')
- walk(root.fsPath, functionsPath, async abs => {
+ await walk(root.fsPath, functionsPath, async abs => {
try {
const uri = getUri(Uri.file(abs).toString(), uris)
await fixFileCommandHandler({
@@ -599,8 +601,10 @@ connection.onInitialized(() => {
})
}
}
+ progress.done()
break
- case 'datapack.regenerateCache':
+ }
+ case 'datapack.regenerateCache': {
const progress = await connection.window.createWorkDoneProgress()
progress.begin(locale('server.regenerating-cache'))
@@ -609,6 +613,7 @@ connection.onInitialized(() => {
progress.done()
break
+ }
default:
throw new Error(`Unknown βworkspace/executeCommandβ request for β${command}β.`)
}
diff --git a/src/test/utils/handlers/onDidCloseTextDocument.spec.ts b/src/test/utils/handlers/onDidCloseTextDocument.spec.ts
index c53bb4c61..54366512b 100644
--- a/src/test/utils/handlers/onDidCloseTextDocument.spec.ts
+++ b/src/test/utils/handlers/onDidCloseTextDocument.spec.ts
@@ -13,6 +13,6 @@ describe('onDidCloseTextDocument() Tests', () => {
onDidCloseTextDocument({ uri, infos })
- assert(infos.size === 1)
+ assert(infos.size === 0)
})
})
diff --git a/src/utils/handlers/commands/fixFileCommandHandler.ts b/src/utils/handlers/commands/fixFileCommandHandler.ts
index 105857cea..73a74d8c2 100644
--- a/src/utils/handlers/commands/fixFileCommandHandler.ts
+++ b/src/utils/handlers/commands/fixFileCommandHandler.ts
@@ -10,12 +10,7 @@ export async function fixFileCommandHandler({ uri, roots, infos, cacheFile, read
const info = await getOrCreateInfo(uri, roots, infos, cacheFile, config, readFile, commandTree, vanillaData)
/* istanbul ignore else */
if (info) {
- const startTime = new Date().getTime()
const edit = getMergedPreferredEdit(info, uri)
- const endTime = new Date().getTime()
- console.log(`--------------- Edit for β${uri.toString()}β (${endTime - startTime} ms) ---------------`)
- console.log(JSON.stringify(edit, undefined, 4))
-
if (edit) {
applyEdit(edit)
}
diff --git a/src/utils/handlers/index.ts b/src/utils/handlers/index.ts
index 4751fcdfb..140679dc5 100644
--- a/src/utils/handlers/index.ts
+++ b/src/utils/handlers/index.ts
@@ -153,20 +153,28 @@ export function getInfo(uri: Uri, infos: InfosOfUris): FunctionInfo | undefined
return infos.get(uri)
}
+/* istanbul ignore next */
+export async function createInfo(uri: Uri, roots: Uri[], infos: InfosOfUris, cacheFile: CacheFile, config: Config, readFile: ReadFileFunction, commandTree?: CommandTree, vanillaData?: VanillaData): Promise {
+ try {
+ const rel = getRel(uri, roots)!
+ if (isRelIncluded(rel, config)) {
+ const text = await readFile(uri.fsPath, 'utf8')
+ await onDidOpenTextDocument({ text, uri, rel, infos, config, cacheFile, version: null, roots, commandTree, vanillaData })
+ const info = infos.get(uri)
+ infos.delete(uri)
+ return info
+ }
+ } catch (e) {
+ console.error('createInfo', e)
+ }
+ return undefined
+}
+
export async function getOrCreateInfo(uri: Uri, roots: Uri[], infos: InfosOfUris, cacheFile: CacheFile, config: Config, readFile: ReadFileFunction, commandTree?: CommandTree, vanillaData?: VanillaData): Promise {
let info = infos.get(uri)
if (!info) {
- try {
- const rel = getRel(uri, roots)!
- if (isRelIncluded(rel, config)) {
- const text = await readFile(uri.fsPath, 'utf8')
- await onDidOpenTextDocument({ text, uri, rel, infos, config, cacheFile, version: null, roots, commandTree, vanillaData })
- info = infos.get(uri)
- }
- } catch (ignored) {
- // Ignored.
- }
+ info = await createInfo(uri, roots, infos, cacheFile, config, readFile, commandTree, vanillaData)
}
return info
diff --git a/src/utils/handlers/onDidCloseTextDocument.ts b/src/utils/handlers/onDidCloseTextDocument.ts
index 875b04bef..d48fd90d7 100644
--- a/src/utils/handlers/onDidCloseTextDocument.ts
+++ b/src/utils/handlers/onDidCloseTextDocument.ts
@@ -1,5 +1,5 @@
import { InfosOfUris, Uri } from '../../types/handlers'
-export function onDidCloseTextDocument({ }: { uri: Uri, infos: InfosOfUris }) {
- // infos.delete(uri)
+export function onDidCloseTextDocument({ infos, uri }: { uri: Uri, infos: InfosOfUris }) {
+ infos.delete(uri)
}