Skip to content

Commit

Permalink
Merge branch 'main' into kshitij79/BugBash/All-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dselman authored Nov 1, 2024
2 parents 5bb4398 + 1bdbc9d commit c6be109
Show file tree
Hide file tree
Showing 34 changed files with 2,359 additions and 2,874 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"preLaunchTask": {
"type": "npm",
"script": "watch"
"script": "watch-web"
}
},
{
Expand Down
39 changes: 8 additions & 31 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "compile",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$ts-webpack",
"$tslint-webpack"
]
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$ts-webpack-watch",
"$tslint-webpack-watch"
]
}
{
"type": "npm",
"script": "watch-web",
"group": "build",
"isBackground": true,
"problemMatcher": ["$ts-webpack-watch"]
}
]
}
}
12 changes: 10 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ Please update CHANGELOG.md when you make changes.

### Code Structure

This is a VSCode WEB Extension, meaning that it is composed on two parts: the client and the server. The client and server communicate using JSON over HTTP, and use the Language Server Protocol. When running on the web the language server runs in a web worker, while the language client runs on the web page.

Note that this means that you must be careful what assumptions you make and the 3rd-party packages you use - as they must be webpacked to build the web extension package for distribution. In particular the language server cannot access the underlying file system, but must request files from the language client, over RPC.

```
.
├── client // Language Client
│ ├── src
│ │ ├── test // End to End tests for Language Client / Server
│ │ └── extension.ts // Language Client entry point
│ │ └── browserClientMain.ts // Language Client entry point
├── package.json // The extension manifest.
└── server // Language Server
└── src
└── server.ts // Language Server entry point
└── browserServerMain.ts // Language Server entry point
```

### Running
Expand All @@ -33,6 +37,10 @@ Please update CHANGELOG.md when you make changes.
- Run the launch config.
- If you want to debug the server as well use the launch configuration `Attach to Server`

#### Run in Browser

- Run `npm run run-in-browser` to open the extension in Chrome.

### Manual Build and Install

Generate the installable VSIX file:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ This is a [Web Extension](https://code.visualstudio.com/api/extension-guides/web
## Features

- Create data models using the [Concerto](https://concerto.accordproject.org) modeling language
- Create vocabulary files
- Compilation of Concerto files to other languages
- Syntax highlighting for all files
- Compilation and problem markers
- AI-powered context-aware inline code suggestions
- Chat Panel for AI-driven Q&A sessions and debugging support
- Grammar/Model generation from markdown files
- Find all references for Concerto concepts and primitives
- Code actions:
- Update major, minor or patch version of a namespace, updating references in model files and vocabularies

### Commands

Expand Down
10 changes: 5 additions & 5 deletions client/package-lock.json

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

4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"url": "https://github.com/accordproject/vscode-web-extension.git"
},
"engines": {
"vscode": "^1.52.0"
"vscode": "^1.94.0"
},
"dependencies": {
"path-browserify": "^1.0.1",
"vscode-languageclient": "^7.0.0"
},
"devDependencies": {
"@types/vscode": "^1.52.0"
"@types/vscode": "^1.94.0"
}
}
39 changes: 21 additions & 18 deletions client/src/browserClientMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
} from './commands/compileToTarget';

import {
loadModels,
} from './commands/loadModels';
loadProjectFiles,
} from './commands/loadProjectFiles';

import { inlineSuggestionProvider } from './copilot/inlineSuggestionProvider';
import { promptProvider } from './copilot/promptProvider';
Expand All @@ -50,17 +50,20 @@ export async function activate(context: vscode.ExtensionContext) {
log('Accord Project Extension activated');

const documentSelector = [
{ language: 'concerto' },
{ language: 'concerto' },
{ language: 'concerto-vocabulary' },
{ language: 'templatemark' }
];

// Options to control the language client
const clientOptions: LanguageClientOptions = {
documentSelector,
// synchronize: {
// fileEvents: vscode.workspace.createFileSystemWatcher('**/logic/*.ts')
// },
initializationOptions: {}
synchronize: {
fileEvents: [vscode.workspace.createFileSystemWatcher('**/*.cto'),
vscode.workspace.createFileSystemWatcher('**/*.voc')
]
},
initializationOptions: {},
};

const client = createWorkerLanguageClient(context, clientOptions);
Expand All @@ -80,11 +83,11 @@ export async function activate(context: vscode.ExtensionContext) {
// register commands
// menus etc for commands are defined in package.json
context.subscriptions.push(vscode.commands
.registerCommand('cicero-vscode-extension.compileToTarget', (file) => compileToTarget(client,file)));
.registerCommand('cicero-vscode-extension.compileToTarget', (file) => compileToTarget(client, file)));

context.subscriptions.push(vscode.commands
.registerCommand('cicero-vscode-extension.loadModels', (file) => loadModels(client,file)));
.registerCommand('cicero-vscode-extension.loadProjectFiles', (file) => loadProjectFiles(client, file)));

// Register the prompt provider command, startPromptProviderUI
context.subscriptions.push(vscode.commands
.registerCommand('cicero-vscode-extension.startPromptProviderUI', () => promptProvider.showPromptInputBox(client)));
Expand All @@ -93,20 +96,20 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands
.registerCommand('cicero-vscode-extension.configureSettings', () => createSettingsWebview(context, client)));

// Register the quick pick command
registerQuickPickCommand(context, client);
// Register the quick pick command
registerQuickPickCommand(context, client);

// Create and show the status bar item, statusBarItem
createStatusBarItem(context);

// Create and show the status bar item, statusBarItem
createStatusBarItem(context);

// Register the toggle settings commands
registerToggleSettingsCommands(context, client);

context.subscriptions.push(vscode.commands
.registerCommand('cicero-vscode-extension.chatPanelWithErrorMessage', (errorMessage) => createOrShowChatPanel(client, context, errorMessage)));

context.subscriptions.push(vscode.commands
.registerCommand('cicero-vscode-extension.openFileGenerator', () => createFileGeneratorPanel(context, client)));
.registerCommand('cicero-vscode-extension.openFileGenerator', () => createFileGeneratorPanel(context, client)));
}

function createWorkerLanguageClient(context: vscode.ExtensionContext, clientOptions: LanguageClientOptions) {
Expand All @@ -116,4 +119,4 @@ function createWorkerLanguageClient(context: vscode.ExtensionContext, clientOpti

// create the language server client to communicate with the server running in the worker
return new LanguageClient('cicero-vscode-extension', 'Accord Project - Server', clientOptions, worker);
}
}
10 changes: 0 additions & 10 deletions client/src/commands/loadModels.ts

This file was deleted.

10 changes: 10 additions & 0 deletions client/src/commands/loadProjectFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient/browser';

export async function loadProjectFiles(client:LanguageClient, file: vscode.Uri) {
try {
await client.sendRequest('loadProjectFiles', {uri:file.toString()});
} catch (e) {
vscode.window.showErrorMessage(`Failed to load project files: ${e}`);
}
}
15 changes: 15 additions & 0 deletions client/src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as assert from 'assert';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';

suite('Web Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');

test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});
30 changes: 30 additions & 0 deletions client/src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Imports mocha for the browser, defining the `mocha` global.
require('mocha/mocha');

export function run(): Promise<void> {

return new Promise((c, e) => {
mocha.setup({
ui: 'tdd',
reporter: undefined
});

// Bundles all files in the current directory matching `*.test`
const importAll = (r: __WebpackModuleApi.RequireContext) => r.keys().forEach(r);
importAll(require.context('.', true, /\.test$/));

try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
}
Binary file removed concerto-vscode-extension-1.10.0.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.6.0.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.7.0.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.7.1.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.7.2.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.7.3.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.7.4.vsix
Binary file not shown.
Binary file removed concerto-vscode-extension-1.7.5.vsix
Binary file not shown.
Loading

0 comments on commit c6be109

Please sign in to comment.