mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 07:37:10 +00:00
Validate regex patterns, fix object bodies
This commit is contained in:
@@ -15,7 +15,7 @@ import type { Position, Range } from 'vscode-languageserver-textdocument'
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument'
|
||||
import type { ConfigGenerator } from '../Config.js'
|
||||
import siteConfig from '../Config.js'
|
||||
import { computeIfAbsent, genPath } from '../Utils.js'
|
||||
import { computeIfAbsent, genPath, message } from '../Utils.js'
|
||||
import type { VersionMeta } from './DataFetcher.js'
|
||||
import { fetchBlockStates, fetchRegistries, fetchVanillaMcdoc, fetchVersions, getVersionChecksum } from './DataFetcher.js'
|
||||
import type { VersionId } from './Versions.js'
|
||||
@@ -332,6 +332,23 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, ve
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// Until spyglass implements this attribute itself
|
||||
mcdoc.runtime.registerAttribute(meta, 'regex_pattern', () => undefined, {
|
||||
checker: (_, typeDef) => {
|
||||
if (typeDef.kind !== 'literal' || typeDef.value.kind !== 'string') {
|
||||
return undefined
|
||||
}
|
||||
const pattern = typeDef.value.value
|
||||
return (node, ctx) => {
|
||||
try {
|
||||
RegExp(pattern)
|
||||
} catch (e) {
|
||||
ctx.err.report(message(e), node, 2)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function getLsPosition(offset: number, doc: TextDocument): Position {
|
||||
|
||||
Reference in New Issue
Block a user