Skip to content

Commit

Permalink
Revert "Create Rascal project VSCode" (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju authored Apr 19, 2023
1 parent 1144887 commit 4084b9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 149 deletions.
14 changes: 7 additions & 7 deletions rascal-vscode-extension/package-lock.json

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

7 changes: 1 addition & 6 deletions rascal-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
],
"activationEvents": [
"onCommand:rascalmpl.createTerminal",
"onCommand:rascalmpl.createProject",
"onLanguage:rascalmpl"
],
"main": "./dist/extension.js",
Expand All @@ -47,10 +46,6 @@
{
"command": "rascalmpl.importMain",
"title": "Start Rascal Terminal and Import this module"
},
{
"command": "rascalmpl.createProject",
"title": "Create new Rascal project"
}
],
"languages": [
Expand Down Expand Up @@ -117,7 +112,7 @@
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.1.1",
"@types/node": "^16.18.23",
"@types/node": "^16.x",
"@types/node-fetch": "^2.5.12",
"@types/tar": "^6.1.1",
"@types/temp": "^0.9.1",
Expand Down
136 changes: 0 additions & 136 deletions rascal-vscode-extension/src/RascalExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ import * as os from 'os';
import * as path from 'path';
import * as vscode from 'vscode';

import { writeFileSync } from 'fs';

import { integer } from 'vscode-languageclient/node';
import { getJavaExecutable } from './auto-jvm/JavaLookup';
import { RascalLanguageServer } from './lsp/RascalLanguageServer';
import { LanguageParameter, ParameterizedLanguageServer } from './lsp/ParameterizedLanguageServer';
import { RascalTerminalLinkProvider } from './RascalTerminalLinkProvider';
import { VSCodeUriResolverServer } from './fs/VSCodeURIResolver';

const vsfs = vscode.workspace.fs;
const URI = vscode.Uri;

export class RascalExtension implements vscode.Disposable {
private readonly vfsServer: VSCodeUriResolverServer;
private readonly dsls:ParameterizedLanguageServer;
Expand All @@ -55,7 +50,6 @@ export class RascalExtension implements vscode.Disposable {
this.registerTerminalCommand();
this.registerMainRun();
this.registerImportModule();
this.createProject();

vscode.window.registerTerminalLinkProvider(new RascalTerminalLinkProvider(this.rascal.rascalClient));
}
Expand Down Expand Up @@ -93,34 +87,6 @@ export class RascalExtension implements vscode.Disposable {
);
}

private createProject() {
this.context.subscriptions.push(
vscode.commands.registerCommand("rascalmpl.createProject",
async () => {
try {
const filePath = await vscode.window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
title: "New Rascal project",
});

if (filePath) {
const dest = filePath[0].path;
const destUri = URI.file(dest);
const projectName = dest.split("/").at(-1) as string;

newRascalProject(dest, projectName);

// Open a workspace window
await vscode.commands.executeCommand("vscode.openFolder", destUri, true);
}
} catch (e) {
console.error(e);
}
})
);
}

private registerImportModule() {
this.context.subscriptions.push(
Expand Down Expand Up @@ -217,105 +183,3 @@ function calculateRascalREPLMemory() {
}
return "-Xmx800M";
}

async function newRascalProject(dest: string, name: string) {

const baseDest = URI.file(dest);
vsfs.createDirectory(baseDest);

const metaPath = URI.joinPath(baseDest, "META-INF");
await vsfs.createDirectory(metaPath);

const srcPath = URI.joinPath(baseDest, "src/main/rascal/");
await vsfs.createDirectory(srcPath);

const rascalMFPath = URI.joinPath(metaPath, "RASCAL.MF");
writeFileSync(rascalMFPath.fsPath, rascalMF(name));

const pomPath = URI.joinPath(baseDest, "pom.xml");
writeFileSync(pomPath.fsPath, pomXML(name));

const mainPath = URI.joinPath(srcPath, "Main.rsc");
writeFileSync(mainPath.fsPath, emptyModule);

}

function rascalMF(name: string): string {
return "Manifest-Version: 0.0.1\n" +
`Project-Name: ${name}\n` +
"Source: src/main/rascal\n" +
"Require-Libraries: \n"
;
}

function pomXML(name: string, group="org.rascalmpl", version="0.1.0-SNAPSHOT"): string {
return `<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${group}</groupId>
<artifactId>${name}</artifactId>
<version>${version}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>usethesource</id>
<url>https://releases.usethesource.io/maven/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>usethesource</id>
<url>https://releases.usethesource.io/maven/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal</artifactId>
<version><getRascalVersion()></version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgument>-parameters</compilerArgument>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal-maven-plugin</artifactId>
<version>0.8.2</version>
<configuration>
<errorsAsWarnings>true</errorsAsWarnings>
<bin>\${project.build.outputDirectory}</bin>
<srcs>
<src>$\{project.basedir}/src/main/rascal</src>
</srcs>
</configuration>
</plugin>
</plugins>
</build>
</project>
`;
}

const emptyModule = "module Main\n" +
"import IO;\n\n"+
"int main(int testArgument=0) {\n" +
` println("argument: <testArgument>");\n` +
" return testArgument;\n"+
"}";

0 comments on commit 4084b9e

Please sign in to comment.