Switch AST viewer to use new result types
This commit is contained in:
@@ -9,6 +9,7 @@ import { ChildAstItem, AstItem } from "./ast-viewer";
|
|||||||
import { Uri } from "vscode";
|
import { Uri } from "vscode";
|
||||||
import { QueryOutputDir } from "../../run-queries-shared";
|
import { QueryOutputDir } from "../../run-queries-shared";
|
||||||
import { fileRangeFromURI } from "../contextual/file-range-from-uri";
|
import { fileRangeFromURI } from "../contextual/file-range-from-uri";
|
||||||
|
import { mapUrlValue } from "../../common/bqrs-result";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that wraps a tree of QL results from a query that
|
* A class that wraps a tree of QL results from a query that
|
||||||
@@ -106,7 +107,7 @@ export class AstBuilder {
|
|||||||
const item = {
|
const item = {
|
||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
location: entity.url,
|
location: entity.url ? mapUrlValue(entity.url) : undefined,
|
||||||
fileLocation: fileRangeFromURI(entity.url, this.db),
|
fileLocation: fileRangeFromURI(entity.url, this.db),
|
||||||
children: [] as ChildAstItem[],
|
children: [] as ChildAstItem[],
|
||||||
order: Number.MAX_SAFE_INTEGER,
|
order: Number.MAX_SAFE_INTEGER,
|
||||||
|
|||||||
@@ -16,20 +16,20 @@ import {
|
|||||||
import { basename } from "path";
|
import { basename } from "path";
|
||||||
|
|
||||||
import { DatabaseItem } from "../../databases/local-databases";
|
import { DatabaseItem } from "../../databases/local-databases";
|
||||||
import { UrlValue, BqrsId } from "../../common/bqrs-cli-types";
|
import { BqrsId } from "../../common/bqrs-cli-types";
|
||||||
import { showLocation } from "../../databases/local-databases/locations";
|
import { showLocation } from "../../databases/local-databases/locations";
|
||||||
import {
|
|
||||||
isStringLoc,
|
|
||||||
isWholeFileLoc,
|
|
||||||
isLineColumnLoc,
|
|
||||||
} from "../../common/bqrs-utils";
|
|
||||||
import { DisposableObject } from "../../common/disposable-object";
|
import { DisposableObject } from "../../common/disposable-object";
|
||||||
import { asError, getErrorMessage } from "../../common/helpers-pure";
|
import {
|
||||||
|
asError,
|
||||||
|
assertNever,
|
||||||
|
getErrorMessage,
|
||||||
|
} from "../../common/helpers-pure";
|
||||||
import { redactableError } from "../../common/errors";
|
import { redactableError } from "../../common/errors";
|
||||||
import { AstViewerCommands } from "../../common/commands";
|
import { AstViewerCommands } from "../../common/commands";
|
||||||
import { extLogger } from "../../common/logging/vscode";
|
import { extLogger } from "../../common/logging/vscode";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../../common/logging";
|
import { showAndLogExceptionWithTelemetry } from "../../common/logging";
|
||||||
import { telemetryListener } from "../../common/vscode/telemetry";
|
import { telemetryListener } from "../../common/vscode/telemetry";
|
||||||
|
import { UrlValue } from "../../common/raw-result-types";
|
||||||
|
|
||||||
export interface AstItem {
|
export interface AstItem {
|
||||||
id: BqrsId;
|
id: BqrsId;
|
||||||
@@ -90,15 +90,18 @@ class AstViewerDataProvider
|
|||||||
|
|
||||||
private extractLineInfo(loc?: UrlValue) {
|
private extractLineInfo(loc?: UrlValue) {
|
||||||
if (!loc) {
|
if (!loc) {
|
||||||
return "";
|
return;
|
||||||
} else if (isStringLoc(loc)) {
|
}
|
||||||
return loc;
|
|
||||||
} else if (isWholeFileLoc(loc)) {
|
switch (loc.type) {
|
||||||
|
case "string":
|
||||||
|
return loc.value;
|
||||||
|
case "wholeFileLocation":
|
||||||
return loc.uri;
|
return loc.uri;
|
||||||
} else if (isLineColumnLoc(loc)) {
|
case "lineColumnLocation":
|
||||||
return loc.startLine;
|
return loc.startLine;
|
||||||
} else {
|
default:
|
||||||
return "";
|
assertNever(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user