Skip to content

Commit

Permalink
Merge pull request #553 from usethesource/update-example-extension
Browse files Browse the repository at this point in the history
Update example folder to package language servers as VS Code extensions
  • Loading branch information
DavyLandman authored Dec 27, 2024
2 parents 3c5ff77 + a09da1b commit d1e6d94
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
3 changes: 2 additions & 1 deletion examples/pico-dsl-extension/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
package-lock.json
dist/
bin/
lib/
lib/
*.vsix
2 changes: 1 addition & 1 deletion examples/pico-dsl-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@usethesource/rascal-vscode-dsl-lsp-server": "0.5.8"
"@usethesource/rascal-vscode-dsl-lsp-server": "0.12.0"
}
}
18 changes: 9 additions & 9 deletions examples/pico-dsl-extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import * as vscode from 'vscode';
import { ParameterizedLanguageServer, VSCodeUriResolverServer, LanguageParameter } from '@usethesource/rascal-vscode-dsl-runtime';
import { ParameterizedLanguageServer, VSCodeUriResolverServer, LanguageParameter } from '@usethesource/rascal-vscode-dsl-lsp-server';
import { join } from 'path';

export function activate(context: vscode.ExtensionContext) {
// jar that contains the `pico-lsp` project
const picoLSPJar = `|jar+file://${context.extensionUri.path}/assets/jars/pico-lsp.jar!|`;
const language = <LanguageParameter>{
pathConfig: `pathConfig(srcs=[${picoLSPJar}])`,
name: "Pico",
extension: "pico",
mainModule: "lang::pico::LanguageServer",
name: "Pico",
extensions: ["pico"],
mainModule: "lang::pico::LanguageServer",
mainFunction: "picoContributions"
};
console.log(language);
// rascal vscode needs an instance of this class, if you register multiple languages, they can share this vfs instance
const vfs = new VSCodeUriResolverServer(false);
const vfs = new VSCodeUriResolverServer(false);
// this starts the LSP server and connects it to rascal
const lsp = new ParameterizedLanguageServer(context,
vfs,
calcJarPath(context),
true,
const lsp = new ParameterizedLanguageServer(context,
vfs,
calcJarPath(context),
true,
"pico", // vscode language ID
"Pico", // vscode language Title (visible in the right bottom corner)
language);
Expand Down
4 changes: 2 additions & 2 deletions examples/pico-dsl-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ const extensionConfig = {
// we copy the jars to an an easy to predict location
from: path.resolve(
__dirname,
"node_modules/@usethesource/rascal-vscode-dsl-runtime/assets/jars/"
"node_modules/@usethesource/rascal-vscode-dsl-lsp-server/assets/jars/"
),
to: path.resolve(__dirname, "dist/rascal-lsp/"),
},
],
}),
],
};
module.exports = [ extensionConfig ];
module.exports = [ extensionConfig ];
5 changes: 2 additions & 3 deletions examples/pico-dsl-lsp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal</artifactId>
<version>0.28.3</version>
<version>0.40.17</version>
</dependency>
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal-lsp</artifactId>
<version>2.12.1</version>
<version>2.21.0</version>
<exclusions>
<exclusion>
<groupId>org.rascalmpl</groupId>
Expand Down Expand Up @@ -96,4 +96,3 @@
</plugins>
</build>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import IO;
// a minimal implementation of a DSL in rascal
// users can add support for more advanced features
set[LanguageService] picoContributions() = {
parser(parser(#start[Program])), // register the parser function for the Pico language
outliner(picoOutliner),
summarizer(picoSummarizer, providesImplementations = false)
parsing(parser(#start[Program])), // register the parser function for the Pico language
documentSymbol(picoOutliner),
analysis(picoSummarizer, providesImplementations = false)
};


Expand Down Expand Up @@ -46,7 +46,7 @@ int main() {
language(
pathConfig(srcs=[|project://pico-dsl-lsp/src/main/rascal|]),
"Pico", // name of the language
"pico", // extension
{"pico"}, // extension
"lang::pico::LanguageServer", // module to import
"picoContributions"
)
Expand Down

0 comments on commit d1e6d94

Please sign in to comment.