Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add the concept of an active query

オープン
#2,187 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript, vscode

調査の方向性

リポジトリのファイルやテストは指定されていません。まず、codeQL.runQuery コマンドに対する拡張機能の登録と、proof of concept に示されている VS Code のワークスペース状態の処理を探してください。完了条件には、開いている .ql ファイルをアクティブなクエリとして選択し、別のファイルから実行できる方法を含める必要があります。ただし、アクティブなタブ内のクエリを引き続き優先できるようにします。

索引モデルが issue の本文から書いたものです。

説明

enhancement VSCode

Is your feature request related to a problem? Please describe.
When I'm working on a query I'm often in editing other files like .qll files, but still want to run the primary query after making a change. I'm in the habit of pressing the key binding for running a query, but this doesn't work from .qll files, so I need to switch tabs back to the original query and then run it. This gets annoying over time.

Describe the solution you'd like
If I know I only want to work on a single query, it would be useful to specify this query once, and then have a key binding for running the active query from any file.

Additional context
I've prototyped this feature in a separate extension and it's been working well for me:

Screenshot 2023-03-19 at 12 09 02 PM image
    function getQLFileFromTab(tab: vscode.Tab): string | null {
        if (tab.input === undefined) {
            return null;
        }
        const tabInput = tab.input as vscode.TabInputText
        if (tabInput.uri === undefined) {
            return null;
        }
        const path: string = tabInput.uri.fsPath
        if (path.endsWith(".ql")) {
            return path
        }

        return null;
    }

    context.subscriptions.push(vscode.commands.registerCommand('gsgx.runActiveCodeQLQuery', async () => {
        const activeTab = vscode.window.tabGroups.activeTabGroup.activeTab
        let activeTabPath = null;
        if (activeTab !== undefined) {
            activeTabPath = getQLFileFromTab(activeTab)
            if (activeTabPath !== null) {
                vscode.commands.executeCommand("codeQL.runQuery",
                    vscode.Uri.file(activeTabPath)
                );
                return;
            }
        }

        const activeQuery = <string>context.workspaceState.get("codeql.active-query");
        if (activeQuery) {
            vscode.commands.executeCommand("codeQL.runQuery",
                vscode.Uri.file(activeQuery)
            );
        } else {
            vscode.window.showInformationMessage('No active query');
        }
    }));


    class QLFileQuickPickItem implements vscode.QuickPickItem {
        label: string;
        path: string;
        detail: string;
        constructor(path: string) {
            this.path = path
            this.detail = path
            this.label = basename(path)
        }
    }
    context.subscriptions.push(vscode.commands.registerCommand('gsgx.setActiveCodeQLQuery', async () => {
        let openFiles = []

        const activeTab = vscode.window.tabGroups.activeTabGroup.activeTab
        let activeTabPath = null;
        let activeTabFiles = []
        if (activeTab !== undefined) {
            activeTabPath = getQLFileFromTab(activeTab)
            if (activeTabPath !== null) {
                activeTabFiles.push(new QLFileQuickPickItem(activeTabPath))
            }
        }
        console.log(activeTabPath)


        for (const tg of vscode.window.tabGroups.all) {
            for (const tab of tg.tabs) {
                const path = getQLFileFromTab(tab)
                if (path === null) {
                    continue
                }
                const item = new QLFileQuickPickItem(path)
                if (tab.isActive) {
                    if (activeTabPath != path) {
                        activeTabFiles.push(item)
                    }
                } else {
                    openFiles.push(item)
                }
            }
        }

        // activeTabFiles come first
        openFiles.unshift(...activeTabFiles)
        if (openFiles.length != 0) {
            const result = await vscode.window.showQuickPick(openFiles, {
                title: "Query path",
                canPickMany: false,
            });
            await context.workspaceState.update("codeql.active-query", result?.path)
        } else {
            vscode.window.showInformationMessage("No CodeQL files are open")
        }
    }));

This is just a proof of concept to start a discussion about how this feature should work, if you think it makes sense to add it.

In this implementation, you can set any QL file that is in an open tab to the active query (in addition to this, it would probably be good to have an option in the right click context menu in the file explorer to set an active query).

Also, if another .ql file is in the active tab, it will always run that QL file instead of the active one. The reason for this is I occasionally do need to run other queries, but don't want to change the active query. It's convenient and intuitive to always run the query in the active tab first, and if the active tab is not a .ql file, then run the active query.

Please let me know what you think.

主要言語
TypeScript
スター
539
フォーク
240
平均マージ
2日 6時間
マージ済み PR(30日)
29

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/vscode-codeql のほかの issue

github/vscode-codeql の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。