Remove some unused BQRS methods/argument type unions
This commit is contained in:
@@ -90,19 +90,6 @@ export interface RawResultSet {
|
||||
readonly rows: readonly ResultRow[];
|
||||
}
|
||||
|
||||
// TODO: This function is not necessary. It generates a tuple that is slightly easier
|
||||
// to handle than the ResultSetSchema and DecodedBqrsChunk. But perhaps it is unnecessary
|
||||
// boilerplate.
|
||||
export function transformBqrsResultSet(
|
||||
schema: ResultSetSchema,
|
||||
page: DecodedBqrsChunk,
|
||||
): RawResultSet {
|
||||
return {
|
||||
schema,
|
||||
rows: Array.from(page.tuples),
|
||||
};
|
||||
}
|
||||
|
||||
export type BqrsKind =
|
||||
| "String"
|
||||
| "Float"
|
||||
|
||||
@@ -102,7 +102,7 @@ function mapEntityValue(cellValue: BqrsEntityValue): EntityValue {
|
||||
};
|
||||
}
|
||||
|
||||
function mapUrlValue(urlValue: BqrsUrlValue): UrlValue | undefined {
|
||||
export function mapUrlValue(urlValue: BqrsUrlValue): UrlValue | undefined {
|
||||
if (typeof urlValue === "string") {
|
||||
const location = tryGetLocationFromString(urlValue);
|
||||
if (location !== undefined) {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { createRemoteFileRef } from "../common/location-link-utils";
|
||||
import {
|
||||
isUrlValueResolvable,
|
||||
UrlValue,
|
||||
UrlValueResolvable,
|
||||
} from "./raw-result-types";
|
||||
import { isUrlValueResolvable, UrlValue } from "./raw-result-types";
|
||||
import {
|
||||
LineColumnLocation,
|
||||
UrlValue as BqrsUrlValue,
|
||||
@@ -18,82 +14,6 @@ export function isEmptyPath(uriStr: string) {
|
||||
return !uriStr || uriStr === "file:/";
|
||||
}
|
||||
|
||||
/**
|
||||
* The CodeQL filesystem libraries use this pattern in `getURL()` predicates
|
||||
* to describe the location of an entire filesystem resource.
|
||||
* Such locations appear as `StringLocation`s instead of `FivePartLocation`s.
|
||||
*
|
||||
* Folder resources also get similar URLs, but with the `folder` scheme.
|
||||
* They are deliberately ignored here, since there is no suitable location to show the user.
|
||||
*/
|
||||
const FILE_LOCATION_REGEX = /file:\/\/(.+):([0-9]+):([0-9]+):([0-9]+):([0-9]+)/;
|
||||
/**
|
||||
* Gets a resolvable source file location for the specified `LocationValue`, if possible.
|
||||
* @param loc The location to test.
|
||||
*/
|
||||
export function tryGetResolvableLocation(
|
||||
loc: BqrsUrlValue | undefined,
|
||||
): UrlValueResolvable | undefined {
|
||||
let resolvedLoc: UrlValueResolvable | undefined;
|
||||
if (loc === undefined) {
|
||||
resolvedLoc = undefined;
|
||||
} else if (isWholeFileLoc(loc)) {
|
||||
resolvedLoc = {
|
||||
type: "wholeFileLocation",
|
||||
uri: loc.uri,
|
||||
};
|
||||
} else if (isLineColumnLoc(loc)) {
|
||||
resolvedLoc = {
|
||||
type: "lineColumnLocation",
|
||||
uri: loc.uri,
|
||||
startLine: loc.startLine,
|
||||
startColumn: loc.startColumn,
|
||||
endLine: loc.endLine,
|
||||
endColumn: loc.endColumn,
|
||||
};
|
||||
} else if (isStringLoc(loc)) {
|
||||
resolvedLoc = tryGetLocationFromString(loc);
|
||||
} else {
|
||||
resolvedLoc = undefined;
|
||||
}
|
||||
|
||||
return resolvedLoc;
|
||||
}
|
||||
|
||||
export function tryGetLocationFromString(
|
||||
loc: string,
|
||||
): UrlValueResolvable | undefined {
|
||||
const matches = FILE_LOCATION_REGEX.exec(loc);
|
||||
if (matches && matches.length > 1 && matches[1]) {
|
||||
if (isWholeFileMatch(matches)) {
|
||||
return {
|
||||
type: "wholeFileLocation",
|
||||
uri: matches[1],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
type: "lineColumnLocation",
|
||||
uri: matches[1],
|
||||
startLine: Number(matches[2]),
|
||||
startColumn: Number(matches[3]),
|
||||
endLine: Number(matches[4]),
|
||||
endColumn: Number(matches[5]),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function isWholeFileMatch(matches: RegExpExecArray): boolean {
|
||||
return (
|
||||
matches[2] === "0" &&
|
||||
matches[3] === "0" &&
|
||||
matches[4] === "0" &&
|
||||
matches[5] === "0"
|
||||
);
|
||||
}
|
||||
|
||||
export function isLineColumnLoc(loc: BqrsUrlValue): loc is LineColumnLocation {
|
||||
return (
|
||||
typeof loc !== "string" &&
|
||||
@@ -115,20 +35,6 @@ export function isStringLoc(loc: BqrsUrlValue): loc is string {
|
||||
return typeof loc === "string";
|
||||
}
|
||||
|
||||
export function tryGetBqrsRemoteLocation(
|
||||
loc: BqrsUrlValue | undefined,
|
||||
fileLinkPrefix: string,
|
||||
sourceLocationPrefix: string | undefined,
|
||||
): string | undefined {
|
||||
const resolvedLoc = tryGetResolvableLocation(loc);
|
||||
|
||||
return tryGetRemoteLocation(
|
||||
resolvedLoc,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
);
|
||||
}
|
||||
|
||||
export function tryGetRemoteLocation(
|
||||
loc: UrlValue | undefined,
|
||||
fileLinkPrefix: string,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import * as sarif from "sarif";
|
||||
import {
|
||||
ResultSetSchema,
|
||||
ResolvableLocationValue,
|
||||
} from "../common/bqrs-cli-types";
|
||||
import { ResultSetSchema } from "../common/bqrs-cli-types";
|
||||
import {
|
||||
VariantAnalysis,
|
||||
VariantAnalysisScannedRepositoryResult,
|
||||
@@ -215,7 +212,7 @@ export type FromResultsViewMsg =
|
||||
*/
|
||||
interface ViewSourceFileMsg {
|
||||
t: "viewSourceFile";
|
||||
loc: ResolvableLocationValue | UrlValueResolvable;
|
||||
loc: UrlValueResolvable;
|
||||
databaseUri: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,15 +9,10 @@ import {
|
||||
window as Window,
|
||||
workspace,
|
||||
} from "vscode";
|
||||
import {
|
||||
ResolvableLocationValue,
|
||||
UrlValue as BqrsUrlValue,
|
||||
} from "../../common/bqrs-cli-types";
|
||||
import { assertNever, getErrorMessage } from "../../common/helpers-pure";
|
||||
import { Logger } from "../../common/logging";
|
||||
import { DatabaseItem } from "./database-item";
|
||||
import { DatabaseManager } from "./database-manager";
|
||||
import { tryGetResolvableLocation } from "../../common/bqrs-utils";
|
||||
import {
|
||||
UrlValueLineColumnLocation,
|
||||
UrlValueResolvable,
|
||||
@@ -74,20 +69,6 @@ function resolveWholeFileLocation(
|
||||
return new Location(databaseItem.resolveSourceFile(loc.uri), range);
|
||||
}
|
||||
|
||||
function isUrlValueResolvable(
|
||||
loc: BqrsUrlValue | UrlValueResolvable | undefined,
|
||||
): loc is UrlValueResolvable {
|
||||
if (!loc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof loc !== "object") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return "type" in loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to resolve the specified CodeQL location to a URI into the source archive. If no exact location
|
||||
* can be resolved, returns `undefined`.
|
||||
@@ -95,28 +76,25 @@ function isUrlValueResolvable(
|
||||
* @param databaseItem Database in which to resolve the file location.
|
||||
*/
|
||||
export function tryResolveLocation(
|
||||
loc: BqrsUrlValue | UrlValueResolvable | undefined,
|
||||
loc: UrlValueResolvable | undefined,
|
||||
databaseItem: DatabaseItem,
|
||||
): Location | undefined {
|
||||
const resolvableLoc = isUrlValueResolvable(loc)
|
||||
? loc
|
||||
: tryGetResolvableLocation(loc);
|
||||
if (!resolvableLoc) {
|
||||
if (!loc) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (resolvableLoc.type) {
|
||||
switch (loc.type) {
|
||||
case "wholeFileLocation":
|
||||
return resolveWholeFileLocation(resolvableLoc, databaseItem);
|
||||
return resolveWholeFileLocation(loc, databaseItem);
|
||||
case "lineColumnLocation":
|
||||
return resolveFivePartLocation(resolvableLoc, databaseItem);
|
||||
return resolveFivePartLocation(loc, databaseItem);
|
||||
default:
|
||||
assertNever(resolvableLoc);
|
||||
assertNever(loc);
|
||||
}
|
||||
}
|
||||
|
||||
export async function showResolvableLocation(
|
||||
loc: ResolvableLocationValue | UrlValueResolvable,
|
||||
loc: UrlValueResolvable,
|
||||
databaseItem: DatabaseItem,
|
||||
logger: Logger,
|
||||
): Promise<void> {
|
||||
@@ -174,7 +152,7 @@ export async function showLocation(location?: Location) {
|
||||
|
||||
export async function jumpToLocation(
|
||||
databaseUri: string,
|
||||
loc: ResolvableLocationValue | UrlValueResolvable,
|
||||
loc: UrlValueResolvable,
|
||||
databaseManager: DatabaseManager,
|
||||
logger: Logger,
|
||||
) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { DecodedBqrsChunk } from "../common/bqrs-cli-types";
|
||||
import { Call, CallClassification, Method } from "./method";
|
||||
import { DecodedBqrsChunk, EntityValue } from "../common/bqrs-cli-types";
|
||||
import { CallClassification, Method, Usage } from "./method";
|
||||
import { ModeledMethodType } from "./modeled-method";
|
||||
import { parseLibraryFilename } from "./library";
|
||||
import { Mode } from "./shared/mode";
|
||||
import { ApplicationModeTuple, FrameworkModeTuple } from "./queries/query";
|
||||
import { QueryLanguage } from "../common/query-language";
|
||||
import { getModelsAsDataLanguage } from "./languages";
|
||||
import { mapUrlValue } from "../common/bqrs-result";
|
||||
import { isUrlValueResolvable } from "../common/raw-result-types";
|
||||
|
||||
export function decodeBqrsToMethods(
|
||||
chunk: DecodedBqrsChunk,
|
||||
@@ -17,7 +19,7 @@ export function decodeBqrsToMethods(
|
||||
const definition = getModelsAsDataLanguage(language);
|
||||
|
||||
chunk?.tuples.forEach((tuple) => {
|
||||
let usage: Call;
|
||||
let usageEntityValue: EntityValue;
|
||||
let packageName: string;
|
||||
let typeName: string;
|
||||
let methodName: string;
|
||||
@@ -30,7 +32,7 @@ export function decodeBqrsToMethods(
|
||||
|
||||
if (mode === Mode.Application) {
|
||||
[
|
||||
usage,
|
||||
usageEntityValue,
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
@@ -43,7 +45,7 @@ export function decodeBqrsToMethods(
|
||||
] = tuple as ApplicationModeTuple;
|
||||
} else {
|
||||
[
|
||||
usage,
|
||||
usageEntityValue,
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
@@ -97,11 +99,25 @@ export function decodeBqrsToMethods(
|
||||
});
|
||||
}
|
||||
|
||||
if (usageEntityValue.url === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const usageUrl = mapUrlValue(usageEntityValue.url);
|
||||
if (!usageUrl || !isUrlValueResolvable(usageUrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!usageEntityValue.label) {
|
||||
return;
|
||||
}
|
||||
|
||||
const method = methodsByApiName.get(signature)!;
|
||||
const usages = [
|
||||
const usages: Usage[] = [
|
||||
...method.usages,
|
||||
{
|
||||
...usage,
|
||||
label: usageEntityValue.label,
|
||||
url: usageUrl,
|
||||
classification,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
|
||||
import { ModeledMethod, ModeledMethodType } from "./modeled-method";
|
||||
import { UrlValueResolvable } from "../common/raw-result-types";
|
||||
|
||||
export type Call = {
|
||||
readonly label: string;
|
||||
readonly url: Readonly<ResolvableLocationValue>;
|
||||
readonly url: Readonly<UrlValueResolvable>;
|
||||
};
|
||||
|
||||
export enum CallClassification {
|
||||
|
||||
@@ -19,6 +19,7 @@ import { assertNever } from "../../common/helpers-pure";
|
||||
import { ModeledMethod } from "../modeled-method";
|
||||
import { groupMethods, sortGroupNames, sortMethods } from "../shared/sorting";
|
||||
import { INITIAL_MODE, Mode } from "../shared/mode";
|
||||
import { UrlValueResolvable } from "../../common/raw-result-types";
|
||||
|
||||
export class MethodsUsageDataProvider
|
||||
extends DisposableObject
|
||||
@@ -99,11 +100,16 @@ export class MethodsUsageDataProvider
|
||||
} else {
|
||||
const { method, usage } = item;
|
||||
|
||||
const description =
|
||||
usage.url.type === "wholeFileLocation"
|
||||
? this.relativePathWithinDatabase(usage.url.uri)
|
||||
: `${this.relativePathWithinDatabase(usage.url.uri)} [${
|
||||
usage.url.startLine
|
||||
}, ${usage.url.endLine}]`;
|
||||
|
||||
return {
|
||||
label: usage.label,
|
||||
description: `${this.relativePathWithinDatabase(usage.url.uri)} [${
|
||||
usage.url.startLine
|
||||
}, ${usage.url.endLine}]`,
|
||||
description,
|
||||
collapsibleState: TreeItemCollapsibleState.None,
|
||||
command: {
|
||||
title: "Show usage",
|
||||
@@ -211,14 +217,35 @@ function usagesAreEqual(u1: Usage, u2: Usage): boolean {
|
||||
return (
|
||||
u1.label === u2.label &&
|
||||
u1.classification === u2.classification &&
|
||||
u1.url.uri === u2.url.uri &&
|
||||
u1.url.startLine === u2.url.startLine &&
|
||||
u1.url.startColumn === u2.url.startColumn &&
|
||||
u1.url.endLine === u2.url.endLine &&
|
||||
u1.url.endColumn === u2.url.endColumn
|
||||
urlValueResolvablesAreEqual(u1.url, u2.url)
|
||||
);
|
||||
}
|
||||
|
||||
function urlValueResolvablesAreEqual(
|
||||
u1: UrlValueResolvable,
|
||||
u2: UrlValueResolvable,
|
||||
): boolean {
|
||||
if (u1.type !== u2.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (u1.type === "wholeFileLocation" && u2.type === "wholeFileLocation") {
|
||||
return u1.uri === u2.uri;
|
||||
}
|
||||
|
||||
if (u1.type === "lineColumnLocation" && u2.type === "lineColumnLocation") {
|
||||
return (
|
||||
u1.uri === u2.uri &&
|
||||
u1.startLine === u2.startLine &&
|
||||
u1.startColumn === u2.startColumn &&
|
||||
u1.endLine === u2.endLine &&
|
||||
u1.endColumn === u2.endColumn
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function sortMethodsInGroups(methods: readonly Method[], mode: Mode): Method[] {
|
||||
const grouped = groupMethods(methods, mode);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Call, CallClassification } from "../method";
|
||||
import { CallClassification } from "../method";
|
||||
import { ModeledMethodType } from "../modeled-method";
|
||||
import { EntityValue } from "../../common/bqrs-cli-types";
|
||||
|
||||
export type Query = {
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ export type Query = {
|
||||
};
|
||||
|
||||
export type ApplicationModeTuple = [
|
||||
Call,
|
||||
EntityValue,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
@@ -52,7 +53,7 @@ export type ApplicationModeTuple = [
|
||||
];
|
||||
|
||||
export type FrameworkModeTuple = [
|
||||
Call,
|
||||
EntityValue,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
|
||||
@@ -63,6 +63,7 @@ const method: Method = {
|
||||
{
|
||||
label: "open(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 14,
|
||||
startColumn: 24,
|
||||
@@ -74,6 +75,7 @@ const method: Method = {
|
||||
{
|
||||
label: "open(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 25,
|
||||
startColumn: 24,
|
||||
|
||||
@@ -112,6 +112,7 @@ ModelEditor.args = {
|
||||
{
|
||||
label: "println(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 29,
|
||||
startColumn: 9,
|
||||
@@ -123,6 +124,7 @@ ModelEditor.args = {
|
||||
{
|
||||
label: "println(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/test/java/org/example/HelloControllerTest.java",
|
||||
startLine: 29,
|
||||
startColumn: 9,
|
||||
|
||||
@@ -2,8 +2,9 @@ import * as React from "react";
|
||||
import { select } from "d3";
|
||||
import { jumpToLocation } from "./result-table-utils";
|
||||
import { graphviz, GraphvizOptions } from "d3-graphviz";
|
||||
import { tryGetLocationFromString } from "../../common/bqrs-utils";
|
||||
import { useCallback, useEffect } from "react";
|
||||
import { mapUrlValue } from "../../common/bqrs-result";
|
||||
import { isUrlValueResolvable } from "../../common/raw-result-types";
|
||||
|
||||
type GraphProps = {
|
||||
graphData: string;
|
||||
@@ -42,8 +43,8 @@ export function Graph({ graphData, databaseUri }: GraphProps) {
|
||||
.attributer(function (d) {
|
||||
if (d.tag === "a") {
|
||||
const url = d.attributes["xlink:href"] || d.attributes["href"];
|
||||
const loc = tryGetLocationFromString(url);
|
||||
if (loc !== undefined) {
|
||||
const loc = mapUrlValue(url);
|
||||
if (loc !== undefined && isUrlValueResolvable(loc)) {
|
||||
d.attributes["xlink:href"] = "#";
|
||||
d.attributes["href"] = "#";
|
||||
loc.uri = `file://${loc.uri}`;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { ResolvableLocationValue } from "../../common/bqrs-cli-types";
|
||||
import {
|
||||
RawResultsSortState,
|
||||
QueryMetadata,
|
||||
SortDirection,
|
||||
RawResultsSortState,
|
||||
ResultSet,
|
||||
SortDirection,
|
||||
} from "../../common/interface-types";
|
||||
import { assertNever } from "../../common/helpers-pure";
|
||||
import { vscode } from "../vscode-api";
|
||||
@@ -41,7 +40,7 @@ const oddRowClassName = "vscode-codeql__result-table-row--odd";
|
||||
export const selectedRowClassName = "vscode-codeql__result-table-row--selected";
|
||||
|
||||
export function jumpToLocation(
|
||||
loc: ResolvableLocationValue | UrlValueResolvable,
|
||||
loc: UrlValueResolvable,
|
||||
databaseUri: string,
|
||||
): void {
|
||||
vscode.postMessage({
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {
|
||||
Usage,
|
||||
Method,
|
||||
CallClassification,
|
||||
Method,
|
||||
Usage,
|
||||
} from "../../../src/model-editor/method";
|
||||
import { ResolvableLocationValue } from "../../../src/common/bqrs-cli-types";
|
||||
import { UrlValueResolvable } from "../../../src/common/raw-result-types";
|
||||
|
||||
export function createMethod(data: Partial<Method> = {}): Method {
|
||||
return {
|
||||
@@ -24,11 +24,13 @@ export function createMethod(data: Partial<Method> = {}): Method {
|
||||
export function createUsage({
|
||||
classification = CallClassification.Unknown,
|
||||
label = "test",
|
||||
url = {} as ResolvableLocationValue,
|
||||
url = {
|
||||
type: "wholeFileLocation",
|
||||
} as UrlValueResolvable,
|
||||
}: {
|
||||
classification?: CallClassification;
|
||||
label?: string;
|
||||
url?: ResolvableLocationValue;
|
||||
url?: UrlValueResolvable;
|
||||
} = {}): Usage {
|
||||
return {
|
||||
classification,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { mapUrlValue } from "../../../src/common/bqrs-result";
|
||||
|
||||
describe("mapUrlValue", () => {
|
||||
it("should detect Windows whole-file locations", () => {
|
||||
const loc = "file://C:/path/to/file.ext:0:0:0:0";
|
||||
const wholeFileLoc = mapUrlValue(loc);
|
||||
expect(wholeFileLoc).toEqual({
|
||||
type: "wholeFileLocation",
|
||||
uri: "C:/path/to/file.ext",
|
||||
});
|
||||
});
|
||||
it("should detect Unix whole-file locations", () => {
|
||||
const loc = "file:///path/to/file.ext:0:0:0:0";
|
||||
const wholeFileLoc = mapUrlValue(loc);
|
||||
expect(wholeFileLoc).toEqual({
|
||||
type: "wholeFileLocation",
|
||||
uri: "/path/to/file.ext",
|
||||
});
|
||||
});
|
||||
|
||||
it("should detect Unix 5-part locations", () => {
|
||||
const loc = "file:///path/to/file.ext:1:2:3:4";
|
||||
const wholeFileLoc = mapUrlValue(loc);
|
||||
expect(wholeFileLoc).toEqual({
|
||||
type: "lineColumnLocation",
|
||||
uri: "/path/to/file.ext",
|
||||
startLine: 1,
|
||||
startColumn: 2,
|
||||
endLine: 3,
|
||||
endColumn: 4,
|
||||
});
|
||||
});
|
||||
it("should set other string locations as strings", () => {
|
||||
for (const loc of ["file:///path/to/file.ext", "I am not a location"]) {
|
||||
const urlValue = mapUrlValue(loc);
|
||||
expect(urlValue).toEqual({
|
||||
type: "string",
|
||||
value: loc,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,151 +1,9 @@
|
||||
import {
|
||||
tryGetBqrsRemoteLocation,
|
||||
tryGetRemoteLocation,
|
||||
tryGetResolvableLocation,
|
||||
} from "../../../src/common/bqrs-utils";
|
||||
import { tryGetRemoteLocation } from "../../../src/common/bqrs-utils";
|
||||
import {
|
||||
UrlValue,
|
||||
UrlValueResolvable,
|
||||
} from "../../../src/common/raw-result-types";
|
||||
|
||||
describe("tryGetResolvableLocation", () => {
|
||||
it("should detect Windows whole-file locations", () => {
|
||||
const loc = "file://C:/path/to/file.ext:0:0:0:0";
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).toEqual({
|
||||
type: "wholeFileLocation",
|
||||
uri: "C:/path/to/file.ext",
|
||||
});
|
||||
});
|
||||
it("should detect Unix whole-file locations", () => {
|
||||
const loc = "file:///path/to/file.ext:0:0:0:0";
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).toEqual({
|
||||
type: "wholeFileLocation",
|
||||
uri: "/path/to/file.ext",
|
||||
});
|
||||
});
|
||||
|
||||
it("should detect Unix 5-part locations", () => {
|
||||
const loc = "file:///path/to/file.ext:1:2:3:4";
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).toEqual({
|
||||
type: "lineColumnLocation",
|
||||
uri: "/path/to/file.ext",
|
||||
startLine: 1,
|
||||
startColumn: 2,
|
||||
endLine: 3,
|
||||
endColumn: 4,
|
||||
});
|
||||
});
|
||||
it("should ignore other string locations", () => {
|
||||
for (const loc of ["file:///path/to/file.ext", "I am not a location"]) {
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).toBeUndefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("tryGetBqrsRemoteLocation", () => {
|
||||
it("should return undefined if resolvableLocation is undefined", () => {
|
||||
const loc = "not a location";
|
||||
const fileLinkPrefix = "";
|
||||
const sourceLocationPrefix = "";
|
||||
|
||||
const link = tryGetBqrsRemoteLocation(
|
||||
loc,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
);
|
||||
|
||||
expect(link).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return undefined if resolvableLocation has the wrong format", () => {
|
||||
const loc = {
|
||||
uri: "file:/path/to/file.ext",
|
||||
startLine: 194,
|
||||
startColumn: 18,
|
||||
endLine: 237,
|
||||
endColumn: 1,
|
||||
};
|
||||
const fileLinkPrefix = "";
|
||||
const sourceLocationPrefix = "/home/foo/bar";
|
||||
|
||||
const link = tryGetBqrsRemoteLocation(
|
||||
loc,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
);
|
||||
|
||||
expect(link).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return a remote file ref if the sourceLocationPrefix and resolvableLocation match up", () => {
|
||||
const loc = {
|
||||
uri: "file:/home/foo/bar/path/to/file.ext",
|
||||
startLine: 194,
|
||||
startColumn: 18,
|
||||
endLine: 237,
|
||||
endColumn: 1,
|
||||
};
|
||||
const fileLinkPrefix = "https://github.com/owner/repo/blob/sha1234";
|
||||
const sourceLocationPrefix = "/home/foo/bar";
|
||||
|
||||
const link = tryGetBqrsRemoteLocation(
|
||||
loc,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
);
|
||||
|
||||
expect(link).toEqual(
|
||||
"https://github.com/owner/repo/blob/sha1234/path/to/file.ext#L194C18-L237C1",
|
||||
);
|
||||
});
|
||||
|
||||
it("should return undefined if the sourceLocationPrefix is missing and resolvableLocation doesn't match the default format", () => {
|
||||
const loc = {
|
||||
uri: "file:/home/foo/bar/path/to/file.ext",
|
||||
startLine: 194,
|
||||
startColumn: 18,
|
||||
endLine: 237,
|
||||
endColumn: 1,
|
||||
};
|
||||
const fileLinkPrefix = "https://github.com/owner/repo/blob/sha1234";
|
||||
const sourceLocationPrefix = "";
|
||||
|
||||
const link = tryGetBqrsRemoteLocation(
|
||||
loc,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
);
|
||||
|
||||
expect(link).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return a remote file ref if the sourceLocationPrefix is missing, but the resolvableLocation matches the default format", () => {
|
||||
const loc = {
|
||||
uri: "file:/home/runner/work/foo/bar/path/to/file.ext",
|
||||
startLine: 194,
|
||||
startColumn: 18,
|
||||
endLine: 237,
|
||||
endColumn: 1,
|
||||
};
|
||||
const fileLinkPrefix = "https://github.com/owner/repo/blob/sha1234";
|
||||
const sourceLocationPrefix = "";
|
||||
|
||||
const link = tryGetBqrsRemoteLocation(
|
||||
loc,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
);
|
||||
|
||||
expect(link).toEqual(
|
||||
"https://github.com/owner/repo/blob/sha1234/path/to/file.ext#L194C18-L237C1",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("tryGetRemoteLocation", () => {
|
||||
it("should return undefined if resolvableLocation is undefined", () => {
|
||||
const loc = undefined;
|
||||
|
||||
@@ -255,6 +255,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "println(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 29,
|
||||
startColumn: 9,
|
||||
@@ -280,6 +281,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "run(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/Sql2oExampleApplication.java",
|
||||
startLine: 9,
|
||||
startColumn: 9,
|
||||
@@ -304,6 +306,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -315,6 +318,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -339,6 +343,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -350,6 +355,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -374,6 +380,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "open(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 14,
|
||||
startColumn: 24,
|
||||
@@ -385,6 +392,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "open(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 25,
|
||||
startColumn: 24,
|
||||
@@ -409,6 +417,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 10,
|
||||
startColumn: 33,
|
||||
@@ -433,6 +442,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 23,
|
||||
startColumn: 23,
|
||||
@@ -519,6 +529,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "connect",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 22,
|
||||
startColumn: 19,
|
||||
@@ -543,6 +554,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "index",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 13,
|
||||
startColumn: 19,
|
||||
@@ -617,6 +629,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "call to method GetMethodInfo",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/bulk-builder/bulk-builder/src/Moq/ActionObserver.cs",
|
||||
startLine: 74,
|
||||
startColumn: 40,
|
||||
@@ -684,6 +697,7 @@ describe("decodeBqrsToMethods", () => {
|
||||
{
|
||||
label: "Validate",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/bulk-builder/bulk-builder/src/Moq/Times.cs",
|
||||
startLine: 369,
|
||||
startColumn: 21,
|
||||
|
||||
@@ -95,6 +95,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -106,6 +107,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -130,6 +132,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -141,6 +144,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -165,6 +169,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 10,
|
||||
startColumn: 33,
|
||||
@@ -190,6 +195,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "run(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/Sql2oExampleApplication.java",
|
||||
startLine: 9,
|
||||
startColumn: 9,
|
||||
@@ -213,6 +219,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "println(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 29,
|
||||
startColumn: 9,
|
||||
@@ -335,6 +342,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -346,6 +354,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -370,6 +379,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -381,6 +391,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -405,6 +416,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 10,
|
||||
startColumn: 33,
|
||||
@@ -430,6 +442,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "run(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/Sql2oExampleApplication.java",
|
||||
startLine: 9,
|
||||
startColumn: 9,
|
||||
@@ -453,6 +466,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
{
|
||||
label: "println(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 29,
|
||||
startColumn: 9,
|
||||
@@ -621,6 +635,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -632,6 +647,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -655,6 +671,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -666,6 +683,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -689,6 +707,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 10,
|
||||
startColumn: 33,
|
||||
@@ -775,6 +794,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -786,6 +806,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -809,6 +830,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 15,
|
||||
startColumn: 13,
|
||||
@@ -820,6 +842,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 26,
|
||||
startColumn: 13,
|
||||
@@ -843,6 +866,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 10,
|
||||
startColumn: 33,
|
||||
|
||||
@@ -14,21 +14,35 @@ describe("tryResolveLocation", () => {
|
||||
});
|
||||
|
||||
it("should resolve a whole file location", () => {
|
||||
expect(tryResolveLocation("file://hucairz:0:0:0:0", databaseItem)).toEqual(
|
||||
new Location(Uri.file("abc"), new Range(0, 0, 0, 0)),
|
||||
);
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{ type: "wholeFileLocation", uri: "file://hucairz:0:0:0:0" },
|
||||
databaseItem,
|
||||
),
|
||||
).toEqual(new Location(Uri.file("abc"), new Range(0, 0, 0, 0)));
|
||||
});
|
||||
|
||||
it("should resolve a five-part location edge case", () => {
|
||||
expect(tryResolveLocation("file://hucairz:1:1:1:1", databaseItem)).toEqual(
|
||||
new Location(Uri.file("abc"), new Range(0, 0, 0, 1)),
|
||||
);
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
type: "lineColumnLocation",
|
||||
uri: "file://hucairz",
|
||||
startLine: 1,
|
||||
startColumn: 1,
|
||||
endLine: 1,
|
||||
endColumn: 1,
|
||||
},
|
||||
databaseItem,
|
||||
),
|
||||
).toEqual(new Location(Uri.file("abc"), new Range(0, 0, 0, 1)));
|
||||
});
|
||||
|
||||
it("should resolve a five-part location", () => {
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
type: "lineColumnLocation",
|
||||
startColumn: 1,
|
||||
endColumn: 3,
|
||||
startLine: 4,
|
||||
@@ -46,44 +60,4 @@ describe("tryResolveLocation", () => {
|
||||
expect(databaseItem.resolveSourceFile).toHaveBeenCalledTimes(1);
|
||||
expect(databaseItem.resolveSourceFile).toHaveBeenCalledWith("hucairz");
|
||||
});
|
||||
|
||||
it("should resolve a five-part location with an empty path", () => {
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
startColumn: 1,
|
||||
endColumn: 3,
|
||||
startLine: 4,
|
||||
endLine: 5,
|
||||
uri: "",
|
||||
},
|
||||
databaseItem,
|
||||
),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should resolve a string location for whole file", () => {
|
||||
expect(tryResolveLocation("file://hucairz:0:0:0:0", databaseItem)).toEqual(
|
||||
new Location(Uri.file("abc"), new Range(0, 0, 0, 0)),
|
||||
);
|
||||
expect(databaseItem.resolveSourceFile).toHaveBeenCalledTimes(1);
|
||||
expect(databaseItem.resolveSourceFile).toHaveBeenCalledWith("hucairz");
|
||||
});
|
||||
|
||||
it("should resolve a string location for five-part location", () => {
|
||||
expect(tryResolveLocation("file://hucairz:5:4:3:2", databaseItem)).toEqual(
|
||||
new Location(
|
||||
Uri.file("abc"),
|
||||
new Range(new Position(4, 3), new Position(2, 2)),
|
||||
),
|
||||
);
|
||||
expect(databaseItem.resolveSourceFile).toHaveBeenCalledTimes(1);
|
||||
expect(databaseItem.resolveSourceFile).toHaveBeenCalledWith("hucairz");
|
||||
});
|
||||
|
||||
it("should resolve a string location for invalid string", () => {
|
||||
expect(
|
||||
tryResolveLocation("file://hucairz:x:y:z:a", databaseItem),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -349,6 +349,7 @@ describe("MethodsUsageDataProvider", () => {
|
||||
label: "test",
|
||||
classification: CallClassification.Source,
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "a/b/",
|
||||
startLine: 1,
|
||||
startColumn: 1,
|
||||
@@ -371,6 +372,7 @@ describe("MethodsUsageDataProvider", () => {
|
||||
label: "test",
|
||||
classification: CallClassification.Source,
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "a/b/",
|
||||
startLine: 1,
|
||||
startColumn: 1,
|
||||
@@ -382,6 +384,7 @@ describe("MethodsUsageDataProvider", () => {
|
||||
label: "test",
|
||||
classification: CallClassification.Source,
|
||||
url: {
|
||||
type: "lineColumnLocation",
|
||||
uri: "a/b/",
|
||||
startLine: 1,
|
||||
startColumn: 1,
|
||||
|
||||
Reference in New Issue
Block a user