Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes and comments #290

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
ignorePatterns: ["**/*.d.ts", "**/*.js"],
parser: "@typescript-eslint/parser",
extends: ["plugin:@typescript-eslint/recommended"],
plugins: ["header", "license-header"],
plugins: ["header", "license-header", "unused-imports"],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
Expand All @@ -12,7 +12,20 @@ module.exports = {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"license-header/header": ["error", "./resources/license-header.js"],
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],

// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
},
Expand Down
46 changes: 46 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "kdb",
"description": "IDE support for kdb product suite",
"publisher": "KX",
"version": "1.4.0",
"version": "1.5.0",
"engines": {
"vscode": "^1.75.0"
},
Expand Down Expand Up @@ -773,7 +773,8 @@
"coverage": "tsc -p ./test && node ./out/test/runTest.js --coverage",
"package": "npx vsce package",
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
"publish": "npx vsce publish"
"publish": "npx vsce publish",
"lint": "eslint 'src/**' --fix"
},
"prettier": {
"printWidth": 80,
Expand Down Expand Up @@ -804,6 +805,7 @@
"eslint": "^8.56.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-license-header": "^0.6.0",
"eslint-plugin-unused-imports": "^3.2.0",
"glob": "^8.1.0",
"istanbul-lib-coverage": "^3.2.2",
"istanbul-lib-instrument": "^3.3.0",
Expand Down
17 changes: 6 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
import { env } from "node:process";
import path from "path";
import {
commands,
ConfigurationTarget,
EventEmitter,
ExtensionContext,
extensions,
languages,
Range,
TextDocumentContentProvider,
Uri,
WorkspaceEdit,
commands,
extensions,
languages,
window,
workspace,
WorkspaceEdit,
} from "vscode";
import {
LanguageClient,
Expand Down Expand Up @@ -56,7 +56,6 @@ import { ExecutionTypes } from "./models/execution";
import { InsightDetails, Insights } from "./models/insights";
import { QueryResult } from "./models/queryResult";
import { Server, ServerDetails } from "./models/server";
import { KdbDataSourceProvider } from "./services/dataSourceTreeProvider";
import {
InsightsNode,
KdbNode,
Expand All @@ -79,13 +78,13 @@ import AuthSettings from "./utils/secretStorage";
import { Telemetry } from "./utils/telemetryClient";
import { DataSourceEditorProvider } from "./services/dataSourceEditorProvider";
import {
addWorkspaceFile,
FileTreeItem,
WorkspaceTreeProvider,
addWorkspaceFile,
} from "./services/workspaceTreeProvider";
import {
checkOldDatasourceFiles,
ConnectionLensProvider,
checkOldDatasourceFiles,
connectWorkspaceCommands,
importOldDSFiles,
pickConnection,
Expand All @@ -108,7 +107,6 @@ export async function activate(context: ExtensionContext) {
const insights: Insights | undefined = getInsights();

ext.serverProvider = new KdbTreeProvider(servers!, insights!);
ext.dataSourceProvider = new KdbDataSourceProvider();
ext.queryHistoryProvider = new QueryHistoryProvider();
ext.resultsViewProvider = new KdbResultsViewProvider(
ext.context.extensionUri,
Expand Down Expand Up @@ -480,9 +478,6 @@ export async function activate(context: ExtensionContext) {

export async function deactivate(): Promise<void> {
await Telemetry.dispose();
if (ext.dataSourceProvider) {
ext.dataSourceProvider.dispose();
}

// cleanup of local q instance processes
Object.keys(ext.localProcessObjects).forEach((index) => {
Expand Down
2 changes: 0 additions & 2 deletions src/extensionVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { LocalProcess } from "./models/localProcess";
import { MetaObjectPayload } from "./models/meta";
import { QueryHistory } from "./models/queryHistory";
import { ServerObject } from "./models/serverObject";
import { KdbDataSourceProvider } from "./services/dataSourceTreeProvider";
import {
InsightsNode,
KdbNode,
Expand All @@ -46,7 +45,6 @@ export namespace ext {
export let outputChannel: OutputChannel;
export let consolePanel: OutputChannel;
export let serverProvider: KdbTreeProvider;
export let dataSourceProvider: KdbDataSourceProvider;
export let queryHistoryProvider: QueryHistoryProvider;
export let resultsViewProvider: KdbResultsViewProvider;
export let scratchpadTreeProvider: WorkspaceTreeProvider;
Expand Down
12 changes: 6 additions & 6 deletions src/ipc/I64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ export default abstract class I64 extends Vector {
length: number,
offset: number,
qtype: number,
dataView: DataView
dataView: DataView,
) {
super(length, offset, qtype, dataView, 8);
}

calcRange(): bigint[] {
let xMax = this.getScalar(0);
let xMin = xMax;
// @ts-ignore TS2304
// TS2304
for (let i = 1; i < this.length; i++) {
const x = this.getScalar(i);
// @ts-ignore TS2304
// TS2304
if (xMax === I64.nullValue || (x > xMax && x !== I64.nullValue)) {
xMax = x;
}
// @ts-ignore TS2304
// TS2304
if (xMin === I64.nullValue || (x < xMin && x !== I64.nullValue)) {
xMin = x;
}
Expand All @@ -50,7 +50,7 @@ export default abstract class I64 extends Vector {
*/
public deserializeScalar<DType>(
scalar: bigint,
deserialize: (scalar: bigint) => DType
deserialize: (scalar: bigint) => DType,
): DType | number | null {
if (scalar === I64.nullValue) {
return null;
Expand All @@ -68,7 +68,7 @@ export default abstract class I64 extends Vector {
*/
public deserializeScalarAt<DType>(
index: number,
deserialize: (scalar: bigint) => DType
deserialize: (scalar: bigint) => DType,
): DType | number | null {
const s = this.getScalar(index);
return this.deserializeScalar(s, deserialize);
Expand Down
40 changes: 22 additions & 18 deletions src/ipc/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default abstract class Vector extends TypeBase {
offset: number,
qtype: number,
dataView: DataView,
size: number
size: number,
) {
super(length, offset, qtype);
this.dataView = dataView;
Expand All @@ -54,9 +54,9 @@ export default abstract class Vector extends TypeBase {
new Uint8Array(
this.dataView.buffer,
this.offset,
arg.length * this.size
arg.length * this.size,
).set(
new Uint8Array(arg.dataView.buffer, arg.offset, arg.length * this.size)
new Uint8Array(arg.dataView.buffer, arg.offset, arg.length * this.size),
);
}

Expand All @@ -79,20 +79,20 @@ export default abstract class Vector extends TypeBase {
if (this.size !== 8 || [9, 15].indexOf(this.qtype) !== -1) {
const compareFn = (x: number, y: number): number =>
x - (this.hash(y) as number);
// @ts-ignore
// @ts-expect-error
return Tools.binarySearch2(Number(value), this.index, compareFn);
} else {
const compareFn = (x: bigint, y: number): number =>
Number(x - (this.hash(y) as bigint));
// @ts-ignore
// @ts-expect-error
return Tools.binarySearch2(BigInt(value), this.index, compareFn);
}
}

public mergeKeyedPrimary(
arg: Vector,
maxRows: number,
insertIndices: Array<number>
insertIndices: Array<number>,
): number {
this.resetRangeCache();
this.index = this.index ? this.index : this.generateIndex();
Expand Down Expand Up @@ -121,13 +121,13 @@ export default abstract class Vector extends TypeBase {
new Uint8Array(
this.dataView.buffer,
this.offset + targetIndex * this.size,
this.size
this.size,
).set(
new Uint8Array(
arg.dataView.buffer,
arg.offset + i * this.size,
this.size
)
this.size,
),
);
insertIndices.push(targetIndex);
} else {
Expand All @@ -142,7 +142,7 @@ export default abstract class Vector extends TypeBase {
arg: Vector,
indices: Array<number>,
indexOffset: number,
maxRows: number
maxRows: number,
): void {
this.resetRangeCache();
for (let i = 0; i < indices.length; i++) {
Expand All @@ -159,13 +159,13 @@ export default abstract class Vector extends TypeBase {
new Uint8Array(
this.dataView.buffer,
this.offset + targetIndex * this.size,
this.size
this.size,
).set(
new Uint8Array(
arg.dataView.buffer,
arg.offset + i * this.size,
this.size
)
this.size,
),
);
}

Expand All @@ -176,7 +176,11 @@ export default abstract class Vector extends TypeBase {
this.bufferLength = extLength || this.bufferLength;
const buffer = new ArrayBuffer(this.bufferLength * this.size);
new Uint8Array(buffer, 0, this.length * this.size).set(
new Uint8Array(this.dataView.buffer, this.offset, this.length * this.size)
new Uint8Array(
this.dataView.buffer,
this.offset,
this.length * this.size,
),
);

this.dataView = new DataView(buffer);
Expand Down Expand Up @@ -216,14 +220,14 @@ export default abstract class Vector extends TypeBase {
new TA(
this.dataView.buffer,
this.indexOffset * this.size,
this.length - this.indexOffset
)
this.length - this.indexOffset,
),
);

typedArray.set(
// @ts-ignore
new TA(this.dataView.buffer, 0, this.indexOffset),
this.length - this.indexOffset
this.length - this.indexOffset,
);

return typedArray;
Expand Down Expand Up @@ -252,7 +256,7 @@ export default abstract class Vector extends TypeBase {
index.sort((a, b) => (this.hash(a) as number) - (this.hash(b) as number));
} else {
index.sort((a, b) =>
Number((this.hash(a) as bigint) - (this.hash(b) as bigint))
Number((this.hash(a) as bigint) - (this.hash(b) as bigint)),
);
}

Expand Down
Loading
Loading