MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / formatDocument

Function formatDocument

packages/language/src/document.ts:251–263  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

249 * Formats the given ZModel content.
250 */
251export async function formatDocument(content: string) {
252 const services = createZModelServices().ZModelLanguage;
253 const langiumDocuments = services.shared.workspace.LangiumDocuments;
254 const document = langiumDocuments.createDocument(URI.parse('memory:///schema.zmodel'), content);
255 const formatter = services.lsp.Formatter as ZModelFormatter;
256 const identifier = { uri: document.uri.toString() };
257 const options = formatter.getFormatOptions() ?? {
258 insertSpaces: true,
259 tabSize: 4,
260 };
261 const edits = await formatter.formatDocument(document, { options, textDocument: identifier });
262 return TextDocument.applyEdits(document.textDocument, edits);
263}
264

Callers 6

generate.test.tsFile · 0.90
createProjectFunction · 0.90
pull.test.tsFile · 0.90
runPullFunction · 0.90
runFunction · 0.90
updateSchemaFunction · 0.90

Calls 4

createZModelServicesFunction · 0.90
getFormatOptionsMethod · 0.80
formatDocumentMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected