Skip to content
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
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Add support for the `telemetry.telemetryLevel` setting. For more information, see the [telemetry documentation](https://codeql.github.com/docs/codeql-for-visual-studio-code/about-telemetry-in-codeql-for-visual-studio-code). [#2824](https://github.com/github/vscode-codeql/pull/2824).
- Fix syntax highlighting directly after import statements with instantiation arguments. [#2792](https://github.com/github/vscode-codeql/pull/2792)
- The `debug.saveBeforeStart` setting is now respected when running variant analyses. [#2950](https://github.com/github/vscode-codeql/pull/2950)
- The 'open database' button of the model editor was renamed to 'open source'. Also, it's now only available if the source archive is available as a workspace folder. [#2945](https://github.com/github/vscode-codeql/pull/2945)

## 1.9.1 - 29 September 2023

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ export class DatabaseItemImpl implements DatabaseItem {
return encodeArchiveBasePath(sourceArchive.fsPath);
}

/**
* Returns true if the database's source archive is in the workspace.
*/
public hasSourceArchiveInExplorer(): boolean {
return (vscode.workspace.workspaceFolders || []).some((folder) =>
this.belongsToSourceArchiveExplorerUri(folder.uri),
);
}

public verifyZippedSources(): string | undefined {
const sourceArchive = this.sourceArchive;
if (sourceArchive === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export interface DatabaseItem {
*/
getSourceArchiveExplorerUri(): vscode.Uri;

/**
* Returns true if the database's source archive is in the workspace.
*/
hasSourceArchiveInExplorer(): boolean;

/**
* Holds if `uri` belongs to this database's source archive.
*/
Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/src/model-editor/model-editor-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ export class ModelEditorView extends AbstractWebview<
const showLlmButton =
this.databaseItem.language === "java" && this.modelConfig.llmGeneration;

const sourceArchiveAvailable =
this.databaseItem.hasSourceArchiveInExplorer();

await this.postMessage({
t: "setModelEditorViewState",
viewState: {
Expand All @@ -370,6 +373,7 @@ export class ModelEditorView extends AbstractWebview<
showLlmButton,
showMultipleModels: this.modelConfig.showMultipleModels,
mode: this.mode,
sourceArchiveAvailable,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface ModelEditorViewState {
showLlmButton: boolean;
showMultipleModels: boolean;
mode: Mode;
sourceArchiveAvailable: boolean;
}

export interface MethodModelingPanelViewState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ LibraryRow.args = {
showLlmButton: true,
showMultipleModels: true,
mode: Mode.Application,
sourceArchiveAvailable: true,
},
hideModeledMethods: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const viewState: ModelEditorViewState = {
showLlmButton: true,
showMultipleModels: true,
mode: Mode.Application,
sourceArchiveAvailable: true,
};

export const Unmodeled = Template.bind({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ModelEditor.args = {
showLlmButton: true,
showMultipleModels: true,
mode: Mode.Application,
sourceArchiveAvailable: true,
},
initialMethods: [
{
Expand Down
10 changes: 6 additions & 4 deletions extensions/ql-vscode/src/view/model-editor/ModelEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,12 @@ export function ModelEditor({
<>{viewState.extensionPack.name}</>
</HeaderRow>
<HeaderRow>
<LinkIconButton onClick={onOpenDatabaseClick}>
<span slot="start" className="codicon codicon-package"></span>
Open database
</LinkIconButton>
{viewState.sourceArchiveAvailable && (
<LinkIconButton onClick={onOpenDatabaseClick}>
<span slot="start" className="codicon codicon-package"></span>
Open source
</LinkIconButton>
)}
<LinkIconButton onClick={onOpenExtensionPackClick}>
<span slot="start" className="codicon codicon-package"></span>
Open extension pack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe(LibraryRow.name, () => {
showLlmButton: false,
showMultipleModels: false,
extensionPack: createMockExtensionPack(),
sourceArchiveAvailable: true,
};

const render = (props: Partial<LibraryRowProps> = {}) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe(MethodRow.name, () => {
showLlmButton: false,
showMultipleModels: false,
extensionPack: createMockExtensionPack(),
sourceArchiveAvailable: true,
};

const render = (props: Partial<MethodRowProps> = {}) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe(ModeledMethodDataGrid.name, () => {
showLlmButton: false,
showMultipleModels: false,
extensionPack: createMockExtensionPack(),
sourceArchiveAvailable: true,
};

const render = (props: Partial<ModeledMethodDataGridProps> = {}) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe(ModeledMethodsList.name, () => {
showLlmButton: false,
showMultipleModels: false,
extensionPack: createMockExtensionPack(),
sourceArchiveAvailable: true,
};

const render = (props: Partial<ModeledMethodsListProps> = {}) =>
Expand Down