This commit is contained in:
Dirk Baeumer 2021-04-13 22:28:40 +02:00
Родитель 3f84bf7163
Коммит 3d4b3ce7c4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: DD95715335E91385
3 изменённых файлов: 37 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,4 @@
build
samples
node_modules
node_modules
lib

Просмотреть файл

@ -21,6 +21,7 @@ export class ValidateCommand extends Command {
private readonly edgeInformation: Map<EdgeLabels, Map<VertexDescriptor<V>, Set<VertexDescriptor<V>>>>;
private readonly openElements: Set<Id>;
private readonly closedElements: Set<Id>;
private readonly associatedRanges: Set<Id>;
constructor(input: NodeJS.ReadStream | fs.ReadStream | IterableIterator<Edge | Vertex>, options: ValidateOptions, reporter: DiagnosticReporter) {
super(input, reporter);
@ -31,6 +32,7 @@ export class ValidateCommand extends Command {
this.edgeInformation = new Map();
this.openElements = new Set();
this.closedElements = new Set();
this.associatedRanges = new Set();
this.options;
}
@ -75,6 +77,8 @@ export class ValidateCommand extends Command {
let cardinalityCorrect: boolean = true;
let isOpen: boolean = true;
let isClosed: boolean = false;
let freeRanges: Id[] = [];
if (valid) {
const referencedVertices: [VertexLabels | undefined, VertexLabels | undefined][] = [];
if (Edge.is11(edge)) {
@ -121,12 +125,26 @@ export class ValidateCommand extends Command {
if (descriptor.cardinality === Cardinality.one2one && cardinality !== 1) {
cardinalityCorrect = false;
}
if (edge.label === EdgeLabels.contains) {
const vertexLabel = this.vertices.get(edge.outV);
if (vertexLabel === VertexLabels.document) {
for (const range of edge.inVs) {
this.associatedRanges.add(range);
}
}
}
if (edge.label === EdgeLabels.item) {
isOpen = this.openElements.has(edge.shard)!!;
isClosed = this.closedElements.has(edge.shard)!!;
for (const inV of edge.inVs) {
const vertexLabel = this.vertices.get(inV);
if (vertexLabel === VertexLabels.range && !this.associatedRanges.has(inV)) {
freeRanges.push(inV);
}
}
}
}
if (!valid || !sameInVs || !verticesEmitted || !inOutCorrect || !isOpen || !cardinalityCorrect) {
if (!valid || !sameInVs || !verticesEmitted || !inOutCorrect || !isOpen || !cardinalityCorrect || freeRanges.length > 0) {
this.reporter.error(edge);
if (!valid) {
this.reporter.error(edge, 'edge has invalid property values.');
@ -153,6 +171,9 @@ export class ValidateCommand extends Command {
this.reporter.error(edge, `the vertex referenced via the shard property is not open yet.`);
}
}
if (freeRanges.length > 0) {
this.reporter.error(edge, `the ranges [${freeRanges.join(',')}] referenced via the edge are not associated with a document.`);
}
}
}

Просмотреть файл

@ -439,7 +439,7 @@ class SymbolDataPartition extends LSIFData<EmitterContext> {
public end(): void {
if (this.definitionRanges !== SymbolDataPartition.EMPTY_ARRAY) {
let definitionResult = this.symbolData.getOrCreateDefinitionResult();
const definitionResult = this.symbolData.getOrCreateDefinitionResult();
this.emit(this.edge.item(definitionResult, this.definitionRanges, this.shard));
}
if (this.typeDefinitionRanges !== SymbolDataPartition.EMPTY_ARRAY) {
@ -820,7 +820,7 @@ class StandardSymbolData extends SymbolData {
if (forceSingle && this.partitions.size > 1) {
throw new Error(`Symbol data has more than one partition.`);
}
for (let entry of this.partitions.entries()) {
for (const entry of this.partitions.entries()) {
entry[1].end();
}
this.clearedPartitions = undefined;
@ -2216,6 +2216,12 @@ abstract class ProjectDataManager {
public getDocuments(): Set<Document> {
const result = new Set<Document>();
for (const data of this.documentDataItems) {
// The documents are used to end partitions in lower level
// projects. So flush the ranges so that we can use them
// in item edges.
if (!data.isClosed) {
data.flushRanges();
}
result.add(data.document);
}
return result;
@ -2257,6 +2263,11 @@ abstract class ProjectDataManager {
public abstract end(): void;
protected doEnd(documents: Set<Document> | undefined): void {
for (const data of this.documentDataItems) {
if (!data.isClosed) {
data.flushRanges();
}
}
for (const symbolData of this.managedSymbolDataItems) {
if (documents === undefined) {
symbolData.end();