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

Test+Lint+Refactor #1117

Merged
merged 17 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,17 @@
// Pass a directory to run tests in
"${workspaceFolder}/extensions/vscode/manual-testing-sandbox",
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode",
"--extensionTestsPath=${workspaceFolder}/extensions/vscode/out/test-runner/mochaRunner"
"--extensionTestsPath=${workspaceFolder}/extensions/vscode/out/test/runner/mochaRunner"
],
"outFiles": [
// Allows setting breakpoints in test suites across the /src folder
"${workspaceFolder}/extensions/vscode/out/test-suites/**/*.js",
"${workspaceFolder}/extensions/vscode/out/test/test-suites/**/*.js",
// Allows setting breakpoints in mocha test runner file
"${workspaceFolder}/extensions/vscode/out/test-runner/**/*.js"
"${workspaceFolder}/extensions/vscode/out/test/runner/**/*.js"
],
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "vscode-extension:tests:build",
"env": {
"CONTINUE_SERVER_URL": "http://localhost:65432",
// Avoid timing out when stopping on breakpoints during debugging in VSCode
"MOCHA_TIMEOUT": "0"
}
Expand Down
157 changes: 157 additions & 0 deletions binary/package-lock.json

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

1 change: 1 addition & 0 deletions binary/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@biomejs/biome": "1.6.4",
"@types/follow-redirects": "^1.14.4",
"@types/uuid": "^9.0.8",
"@vercel/ncc": "^0.38.1",
Expand Down
2 changes: 1 addition & 1 deletion binary/src/IpcIde.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MessageIde } from "core/util/messageIde";
import { IpcMessenger } from "./messenger";
import type { IpcMessenger } from "./messenger";

export class IpcIde extends MessageIde {
constructor(messenger: IpcMessenger) {
Expand Down
8 changes: 4 additions & 4 deletions binary/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContextItemId, IDE } from "core";
import type { ContextItemId, IDE } from "core";
import { CompletionProvider } from "core/autocomplete/completionProvider";
import { ConfigHandler } from "core/config/handler";
import { addModel, addOpenAIKey, deleteModel } from "core/config/util";
Expand All @@ -7,12 +7,12 @@ import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/Transform
import { CodebaseIndexer, PauseToken } from "core/indexing/indexCodebase";
import { logDevData } from "core/util/devdata";
import historyManager from "core/util/history";
import { Message } from "core/util/messenger";
import type { Message } from "core/util/messenger";
import { Telemetry } from "core/util/posthog";
import { streamDiffLines } from "core/util/verticalEdit";
import { v4 as uuidv4 } from "uuid";
import { IpcMessenger } from "./messenger";
import { Protocol } from "./protocol";
import type { IpcMessenger } from "./messenger";
import type { Protocol } from "./protocol";

export class Core {
private messenger: IpcMessenger;
Expand Down
2 changes: 1 addition & 1 deletion binary/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process.env.IS_BINARY = "true";
import fs from "node:fs";
import { Command } from "commander";
import { getCoreLogsPath } from "core/util/paths";
import fs from "fs";
import { IpcIde } from "./IpcIde";
import { Core } from "./core";
import { IpcMessenger } from "./messenger";
Expand Down
10 changes: 5 additions & 5 deletions binary/src/messenger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { v4 as uuidv4 } from "uuid";

import * as fs from "node:fs";
import { getCoreLogsPath } from "core/util/paths";
import * as fs from "fs";
import { Message } from "../../core/util/messenger";
import { Protocol, ReverseProtocol } from "./protocol";
import type { Message } from "../../core/util/messenger";
import type { Protocol, ReverseProtocol } from "./protocol";

export class IpcMessenger {
typeListeners = new Map<keyof Protocol, ((message: Message) => any)[]>();
Expand Down Expand Up @@ -50,7 +50,7 @@ export class IpcMessenger {
try {
const msg: Message = JSON.parse(line);
if (msg.messageType === undefined || msg.messageId === undefined) {
throw new Error("Invalid message sent: " + JSON.stringify(msg));
throw new Error(`Invalid message sent: ${JSON.stringify(msg)}`);
}

// Call handler and respond with return value
Expand Down Expand Up @@ -99,7 +99,7 @@ export class IpcMessenger {
messageId,
};
// process.send?.(data);
process.stdout?.write(JSON.stringify(data) + "\r\n");
process.stdout?.write(`${JSON.stringify(data)}\r\n`);
return messageId;
}

Expand Down
22 changes: 22 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"style": {
"noUselessElse": "off",
"noNonNullAssertion": "off"
}
}
},
"formatter": {
"indentStyle": "space"
}
}
8 changes: 4 additions & 4 deletions core/autocomplete/ast.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Parser from "web-tree-sitter";
import { RangeInFileWithContents } from "../commands/util";
import type Parser from "web-tree-sitter";
import type { RangeInFileWithContents } from "../commands/util";
import { getParserForFile } from "../util/treeSitter";

export async function getAst(
Expand Down Expand Up @@ -27,7 +27,7 @@ export async function getTreePathAtCursor(
const path = [ast.rootNode];
while (path[path.length - 1].childCount > 0) {
let foundChild = false;
for (let child of path[path.length - 1].children) {
for (const child of path[path.length - 1].children) {
if (child.startIndex <= cursorIndex && child.endIndex >= cursorIndex) {
path.push(child);
foundChild = true;
Expand Down Expand Up @@ -63,7 +63,7 @@ export async function getScopeAroundRange(
let node = ast.rootNode;
while (node.childCount > 0) {
let foundChild = false;
for (let child of node.children) {
for (const child of node.children) {
if (child.startIndex < startIndex && child.endIndex > endIndex) {
node = child;
foundChild = true;
Expand Down
4 changes: 2 additions & 2 deletions core/autocomplete/cache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { open } from "sqlite";
import sqlite3 from "sqlite3";
import { DatabaseConnection } from "../indexing/refreshIndex";
import type { DatabaseConnection } from "../indexing/refreshIndex";
import { getTabAutocompleteCacheSqlitePath } from "../util/paths";

export class AutocompleteLruCache {
private static capacity: number = 1000;
private static capacity = 1000;

db: DatabaseConnection;

Expand Down
2 changes: 1 addition & 1 deletion core/autocomplete/charStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function* onlyWhitespaceAfterEndOfLine(

export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
let first = true;
for await (let char of stream) {
for await (const char of stream) {
if (first) {
first = false;
if (char === "\n") return;
Expand Down