Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
) );
}
}
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 )
);
}
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) {
public update(list: string[]): void {
let treeString: string = JSON.stringify(list)
this.tree = parseTree(treeString);
this.viewUpdatedEventEmitter.fire();
}
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));
}
}
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);
}
}
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);
}
}