How to use the lsif-protocol.VertexLabels.range function in lsif-protocol

To help you get started, we’ve selected a few lsif-protocol 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 microsoft / lsif-node / sqlite / src / blobStore.ts View on Github external
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) {
			const first = this.blob.documentSymbols[0];
			const compressor = lsp.DocumentSymbol.is(first) ? undefined : assertDefined(Compressor.getVertexCompressor(VertexLabels.range));
			if (compressor === undefined) {
				throw new Error(`Document symbol compression not supported`);
			}
			const inline = (result: any[], value: RangeBasedDocumentSymbol) => {
				const item: any[] = [];
				const rangeHash = assertDefined(rangeHashes.get(value.id));
				item.push(rangeHash);
				if (value.children && value.children.length > 0) {
					const children: any[] = [];
					for (let child of value.children) {
						inline(children, child);
					}
					item.push(children);
				}
				result.push(item);
			};
github microsoft / lsif-node / sqlite / src / blobStore.ts View on Github external
private computeHash(): string {
		const hash = crypto.createHash('md5');
		hash.update(this.blob.contents);
		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);
github microsoft / lsif-node / sqlite / src / graphStore.ts View on Github external
public insert(element: Edge | Vertex): void {
		if (element.type === ElementTypes.vertex) {
			switch (element.label) {
				case VertexLabels.metaData:
					this.insertMetaData(element);
					break;
				case VertexLabels.project:
					this.insertProject(element);
					break;
				case VertexLabels.document:
					this.insertDocument(element);
					break;
				case VertexLabels.packageInformation:
					this.insertPackageInformation(element);
					break;
				case VertexLabels.range:
					this.insertRange(element);
					break;
				default:
					this.insertVertex(element);
			}
		} else {
			switch(element.label) {
				case EdgeLabels.contains:
					this.insertContains(element);
					break;
				case EdgeLabels.item:
					this.insertItem(element);
					break;
				default:
					this.insertEdge(element);
			}
github microsoft / vscode-lsif-extension / server / src / json.ts View on Github external
private findRangeFromPosition(file: string, position: lsp.Position): Range | undefined {
		let document = this.indices.documents.get(file);
		if (document === void 0) {
			return undefined;
		}
		let contains = this.out.contains.get(document.id);
		if (contains === void 0 || contains.length === 0) {
			return undefined;
		}

		let candidate: Range | undefined;
		for (let item of contains) {
			if (item.label !== VertexLabels.range) {
				continue;
			}
			let range = item;
			if (JsonDatabase.containsPosition(range, position)) {
				if (!candidate) {
					candidate = item;
				} else {
					if (JsonDatabase.containsRange(candidate, range)) {
						candidate = item;
					}
				}
			}
		}
		return candidate;
	}