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

feat: Demo of codelens for Jake #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion packages/extension/src/LegendCodelensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
} from './LegendLanguageClient';
import { TextDocumentIdentifier } from 'vscode-languageclient';
import { type LegendEntity } from './model/LegendEntity';
import { CLASSIFIER_PATH } from '@finos/legend-engine-ide-client-vscode-shared';
import { CLASSIFIER_PATH, TextLocation } from '@finos/legend-engine-ide-client-vscode-shared';

Check warning on line 30 in packages/extension/src/LegendCodelensProvider.ts

View workflow job for this annotation

GitHub Actions / Run Code Checks

Imports "TextLocation" are only used as type

export class LegendCodelensProvider implements CodeLensProvider {
private client: LegendLanguageClient;
Expand Down Expand Up @@ -55,6 +55,24 @@
);
}

private addDatabaseCodeLens(entityLocation: TextLocation): void {
this.codeLenses.push(
new CodeLens(
new Range(
entityLocation.textInterval.start.line,
entityLocation.textInterval.start.column,
entityLocation.textInterval.end.line,
entityLocation.textInterval.end.column,
),
{
title: 'Edit/Execute in QueryBuilder',
command: LEGEND_GENERATE_MODELS,
arguments: [entityLocation],
},
),
);
}

public async provideCodeLenses(
document: TextDocument,
_token: CancellationToken,
Expand All @@ -74,6 +92,9 @@
) {
this.addQueryBuilderCodeLens(entity);
}
if (entity.classifierPath === CLASSIFIER_PATH.RELATION) {
this.addDatabaseCodeLens(entity.location);
}
});
return this.codeLenses;
}
Expand Down
20 changes: 20 additions & 0 deletions packages/extension/src/LegendLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,24 @@ export class LegendLanguageClient extends LanguageClient {
executableArgs,
);
}

async generateModels(
entityDetails:
| TextLocation
| { documentUri: string; sectionIndex: number; entityId: string },
): Promise<LegendExecutionResult[]> {
return entityDetails instanceof TextLocation
? commands.executeCommand(
LEGEND_COMMAND,
entityDetails,
GET_QUERY_TYPEAHEAD_COMMAND_ID,
)
: commands.executeCommand(
LEGEND_COMMAND,
entityDetails.documentUri,
entityDetails.sectionIndex,
entityDetails.entityId,
GET_QUERY_TYPEAHEAD_COMMAND_ID,
);
}
}
10 changes: 10 additions & 0 deletions packages/extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
} from '@finos/legend-vscode-extension-dependencies';
import { LegendTreeDataProvider } from './utils/LegendTreeProvider';
import { LanguageClientProgressResult } from './model/LanguageClientProgressResult';
import {

Check warning on line 55 in packages/extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / Run Code Checks

Imports "TextLocation" are only used as type
ACTIVATE_FUNCTION_ID,
CLASSIFIER_PATH,
DIAGRAM_RENDERER,
Expand All @@ -77,6 +77,7 @@
SERVICE_QUERY_EDITOR,
SHOW_RESULTS_COMMAND_ID,
TDSLegendExecutionResult,
TextLocation,
} from '@finos/legend-engine-ide-client-vscode-shared';
import { LegendWebViewProvider } from './utils/LegendWebViewProvider';
import {
Expand Down Expand Up @@ -501,6 +502,15 @@
);
context.subscriptions.push(editInQueryBuilder);

const generateModels = commands.registerCommand(

Check warning on line 505 in packages/extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / Run Code Checks

'generateModels' is assigned a value but never used
LEGEND_GENERATE_MODELS, // TODO: add as const
async (...args: unknown[]) => {
const path = args[0] as TextLocation;

Check warning on line 508 in packages/extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / Run Code Checks

'path' is already declared in the upper scope on line 17 column 13
await client.generateModels(path);
}

)

Check warning on line 512 in packages/extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / Run Code Checks

Missing semicolon

const oneEntityPerFileRefactor = commands.registerCommand(
ONE_ENTITY_PER_FILE_COMMAND_ID,
() => {
Expand Down
Loading