Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const options: CompressorOptions = { mode: 'hash' };
const compressor = assertDefined(Compressor.getVertexCompressor(VertexLabels.range));
const rangeHashes: Map = new Map();
for (let key of Object.keys(this.blob.ranges)) {
const range = this.blob.ranges[key];
const rangeHash = crypto.createHash('md5').update(JSON.stringify(compressor.compress(range, options), undefined, 0)).digest('base64');
rangeHashes.set(Number(key), rangeHash);
}
for (let item of Array.from(rangeHashes.values()).sort(Strings.compare)) {
hash.update(item);
}
// moniker
if (this.blob.monikers !== undefined) {
const monikers = LiteralMap.values(this.blob.monikers).sort(Monikers.compare);
const compressor = assertDefined(Compressor.getVertexCompressor(VertexLabels.moniker));
for (let moniker of monikers) {
const compressed = compressor.compress(moniker, options);
hash.update(JSON.stringify(compressed, undefined, 0));
}
}
// Assume that folding ranges are already sorted
if (this.blob.foldingRanges) {
const compressor = foldingRangeCompressor;
for (let range of this.blob.foldingRanges) {
const compressed = compressor.compress(range, options);
hash.update(JSON.stringify(compressed, undefined, 0));
}
}
// Unsure if we need to sort the children by range or not?
if (this.blob.documentSymbols && this.blob.documentSymbols.length > 0) {
rd.on('line', (line) => {
let element: Edge | Vertex = JSON.parse(line);
if (element.type === ElementTypes.vertex) {
switch(element.label) {
case VertexLabels.moniker:
if (element.kind === MonikerKind.local) {
emit(line);
} else {
if (exportLinker !== undefined) {
exportLinker.handleMoniker(element);
}
importLinker.handleMoniker(element);
}
break;
default:
emit(line);
}
} else {
emit(line);
}
});
public insert(element: Edge | Vertex): void {
if (element.type === ElementTypes.vertex) {
switch(element.label) {
case VertexLabels.metaData:
this.handleMetaData(element);
break;
case VertexLabels.document:
this.documents.set(element.id, element);
break;
case VertexLabels.range:
this.handleRange(element);
break;
case VertexLabels.resultSet:
this.handleResultSet(element);
break;
case VertexLabels.moniker:
this.handleMoniker(element);
break;
case VertexLabels.hoverResult:
this.handleHover(element);
break;
case VertexLabels.declarationResult:
this.handleDeclarationResult(element);
break;
case VertexLabels.definitionResult:
this.handleDefinitionResult(element);
break;
case VertexLabels.referenceResult:
this.handleReferenceResult(element);
break;
case VertexLabels.foldingRangeResult:
this.handleFoldingRange(element);
protected createMoniker(identifier: string, kind: MonikerKind, scheme: string): Moniker {
return {
id: this.idGenerator(),
type: ElementTypes.vertex,
label: VertexLabels.moniker,
kind: kind,
scheme: scheme,
identifier: identifier
} as Moniker;
}