How to use the jsonc-parser.parseTree function in jsonc-parser

To help you get started, we’ve selected a few jsonc-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Devine-Davies / vs-make-hidden / src / make-hidden / exclude-items / exclude-items.provider.ts View on Github external
private parseTree(): void  {
        // Get our work space configuration object
        // let fileExcludeObject: any = this.getFilesExcludeObject();
        let fileExcludeObject: any = Util.getItemFromJsonFile(
            this.getSettingPath(), 'files.exclude'
        );

        // FIX
        fileExcludeObject = this.fixRemove__Error( fileExcludeObject );

        if( fileExcludeObject != null ){
            // Update the tree Parse tree accordingly
            this.excludeList = fileExcludeObject;

            this.tree = json.parseTree( JSON.stringify(
                fileExcludeObject
            ) );
        }
    }
github Devine-Davies / vs-make-hidden / src / make-hidden / make-hidden.provider.ts View on Github external
private parse_tree(): void 
    {
        // Get our work space configuration object
        let workspace_config = this.get_workspace_configuration();

        // Parse Tree accordingly
        this.tree =  json.parseTree(
            JSON.stringify( workspace_config )
        );
    }
github aws / aws-toolkit-vscode / src / lambda / config / templates.ts View on Github external
private ensureJsonPropertyExists(
        jsonPath: jsonParser.JSONPath,
        value: any,
        allowedTypes: jsonParser.NodeType[] = ['object', 'null']
    ) {
        const root = jsonParser.parseTree(this.json)
        const node = jsonParser.findNodeAtLocation(root, jsonPath)
        const allowedTypesSet = new Set(allowedTypes)

        if (node && !allowedTypesSet.has(node.type)) {
            throw new TemplatesConfigFieldTypeError({
                message: 'Invalid configuration',
                jsonPath: jsonPath,
                actualType: node.type,
                expectedTypes: allowedTypes
            })
        }

        if (!node || node.type === 'null') {
            const edits = jsonParser.modify(this.json, jsonPath, value, this.modificationOptions)

            if (edits.length > 0) {
github Devine-Davies / vs-make-hidden / src / MakeHidden / Classes / ExcludeItems / ExcludeItems.viewpane.ts View on Github external
public update(list: string[]): void {
      let treeString: string = JSON.stringify(list)
      this.tree = parseTree(treeString);
      this.viewUpdatedEventEmitter.fire();
  }
github microsoft / vscode / extensions / extension-editing / src / extensionLinter.ts View on Github external
this.packageJsonQ.forEach(document => {
			this.packageJsonQ.delete(document);
			if (document.isClosed) {
				return;
			}

			const diagnostics: Diagnostic[] = [];

			const tree = parseTree(document.getText());
			const info = this.readPackageJsonInfo(this.getUriFolder(document.uri), tree);
			if (info.isExtension) {

				const icon = findNodeAtLocation(tree, ['icon']);
				if (icon && icon.type === 'string') {
					this.addDiagnostics(diagnostics, document, icon.offset + 1, icon.offset + icon.length - 1, icon.value, Context.ICON, info);
				}

				const badges = findNodeAtLocation(tree, ['badges']);
				if (badges && badges.type === 'array') {
					badges.children.map(child => findNodeAtLocation(child, ['url']))
						.filter(url => url && url.type === 'string')
						.map(url => this.addDiagnostics(diagnostics, document, url.offset + 1, url.offset + url.length - 1, url.value, Context.BADGE, info));
				}

			}
github microsoft / vscode-extension-samples / tree-view-sample / src / jsonOutline.ts View on Github external
private parseTree(): void {
		this.text = '';
		this.tree = null;
		this.editor = vscode.window.activeTextEditor;
		if (this.editor && this.editor.document) {
			this.text = this.editor.document.getText();
			this.tree = json.parseTree(this.text);
		}
	}
github DaGhostman / vscode-tree-view / src / providers / json.ts View on Github external
private parseTree(document?: vscode.TextDocument): void {
        document = document !== undefined ? document : vscode.window.activeTextEditor.document;
        if (document) {
            this.text = document.getText();
            this.tree = json.parseTree(this.text);
        }
    }