Skip to content

Commit

Permalink
Merge pull request #7 from dylon/dylon/cleanup-and-testing
Browse files Browse the repository at this point in the history
Clean-up and testing (addressing tasks from issue #6)
  • Loading branch information
Pranavchiku authored Nov 15, 2024
2 parents bbb53a2 + 8b88b35 commit 02b83a3
Show file tree
Hide file tree
Showing 16 changed files with 2,621 additions and 426 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
!/client/package.json
!/client/src/*.ts
!/client/testFixture/*.txt
!/client/test/spec/**/*.ts
!/client/tsconfig.json
!/.gitignore
!/.mocharc.json
!/package.json
!/README.md
!/scripts/*.sh
!/server/package.json
!/server/src/*.ts
!/server/test/bin/lfortran
!/server/test/spec/**/*.ts
!/server/tsconfig.json
!/tsconfig.json
4 changes: 4 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://json.schemastore.org/mocharc.json",
"require": "tsx"
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ This will generate a .vsix file in your `lfortran-lsp` folder, which can then be
imported as an extension. You can go to extensions in VSCode, click on `...` on
the top right, click onInstall from VSIXand select the VSIX, and done (may
require a reload). The extension has now been installed.

## Testing

To test the extension, please run `npm run test`.
108 changes: 64 additions & 44 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,82 @@
* ------------------------------------------------------------------------------------------ */

import * as path from 'path';
import { workspace, ExtensionContext } from 'vscode';

import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind
ExtensionContext,
workspace
} from 'vscode';

import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind
} from 'vscode-languageclient/node';

let client: LanguageClient;

export function activate(context: ExtensionContext) {
// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join('out', 'server', 'src', 'server.js')
);
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions
}
};
// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join('out', 'server', 'src', 'server.js')
);

// The debug options for the server
// -----------------------------------------------------------------------
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can
// attach to the server for debugging
const debugOptions = {
execArgv: [
'--nolazy',
'--inspect=6009'
]
};

// If the extension is launched in debug mode then the debug server options
// are used. Otherwise, the run options are used.
const serverOptions: ServerOptions = {
run: {
module: serverModule,
transport: TransportKind.ipc
},
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions
}
};

// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: 'file', language: 'LFortran' }],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
};
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{
scheme: 'file',
language: 'fortran'
}],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in
// the workspace
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
};

// Create the language client and start the client.
client = new LanguageClient(
'LFortranLanguageServer',
'LFortran Language Server',
serverOptions,
clientOptions
);
// Create the language client and start the client.
client = new LanguageClient(
'LFortranLanguageServer',
'LFortran Language Server',
serverOptions,
clientOptions
);

// Start the client. This will also launch the server
client.start();
// Start the client. This will also launch the server
client.start();
}

export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined;
}
return client.stop();
if (!client) {
return undefined;
}
return client.stop();
}
Loading

0 comments on commit 02b83a3

Please sign in to comment.