mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-04 06:32:54 +00:00
Implement set generator default
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import * as core from '@spyglassmc/core'
|
||||
import { FormatterContext } from '@spyglassmc/core'
|
||||
import { BrowserExternals } from '@spyglassmc/core/lib/browser.js'
|
||||
import type { McmetaSummary } from '@spyglassmc/java-edition/lib/dependency/index.js'
|
||||
import { Fluids, ReleaseVersion, symbolRegistrar } from '@spyglassmc/java-edition/lib/dependency/index.js'
|
||||
import * as jeJson from '@spyglassmc/java-edition/lib/json/index.js'
|
||||
import * as jeMcf from '@spyglassmc/java-edition/lib/mcfunction/index.js'
|
||||
import type { JsonFileNode, JsonStringNode } from '@spyglassmc/json'
|
||||
import type { JsonFileNode, JsonNode, JsonStringNode } from '@spyglassmc/json'
|
||||
import * as json from '@spyglassmc/json'
|
||||
import { localize } from '@spyglassmc/locales'
|
||||
import * as mcdoc from '@spyglassmc/mcdoc'
|
||||
@@ -76,9 +77,14 @@ export class SpyglassService {
|
||||
})
|
||||
}
|
||||
|
||||
public getCheckerContext(doc: TextDocument, errors: core.LanguageError[]) {
|
||||
public getCheckerContext(doc?: TextDocument, errors?: core.LanguageError[]) {
|
||||
if (!doc) {
|
||||
doc = TextDocument.create('file:///temp.json', 'json', 1, '')
|
||||
}
|
||||
const err = new core.ErrorReporter()
|
||||
err.errors = errors
|
||||
if (errors) {
|
||||
err.errors = errors
|
||||
}
|
||||
return core.CheckerContext.create(this.service.project, { doc, err })
|
||||
}
|
||||
|
||||
@@ -144,6 +150,13 @@ export class SpyglassService {
|
||||
}
|
||||
}
|
||||
|
||||
public formatNode(node: JsonNode, uri: string) {
|
||||
const formatter = this.service.project.meta.getFormatter(node.type)
|
||||
const doc = TextDocument.create(uri, 'json', 1, '')
|
||||
const ctx = FormatterContext.create(this.service.project, { doc, tabSize: 2, insertSpaces: true })
|
||||
return formatter(node, ctx)
|
||||
}
|
||||
|
||||
public async undoEdit(uri: string) {
|
||||
const document = this.client.documents.get(uri)
|
||||
if (document === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user