Skip to content

Commit

Permalink
chore(format): run prettier 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mjossdev committed Jul 25, 2023
1 parent 48a920e commit f2435c4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
13 changes: 7 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@ let languageServerController: LanguageServerController | null = null;
async function enableTrustedFunctionality(context: vscode.ExtensionContext) {
languageServerController = new LanguageServerController(context);
context.subscriptions.push(
vscode.commands.registerCommand("samt.restartSamtServer", () =>
languageServerController?.restart()
vscode.commands.registerCommand(
"samt.restartSamtServer",
() => languageServerController?.restart(),
),
vscode.workspace.onDidChangeConfiguration(async (event) => {
if (event.affectsConfiguration("samt")) {
await languageServerController?.restart();
}
}),
vscode.tasks.registerTaskProvider("samt", new SamtTaskProvider())
vscode.tasks.registerTaskProvider("samt", new SamtTaskProvider()),
);
await languageServerController.start();
}

export async function activate(
context: vscode.ExtensionContext
context: vscode.ExtensionContext,
): Promise<void> {
if (vscode.workspace.isTrusted) {
await enableTrustedFunctionality(context);
} else {
context.subscriptions.push(
vscode.workspace.onDidGrantWorkspaceTrust(() =>
enableTrustedFunctionality(context)
)
enableTrustedFunctionality(context),
),
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/getJava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type JavaRuntime = IJavaRuntime & {

function convertJre(
jre: IJavaRuntime,
javaInPath: string | null = null
javaInPath: string | null = null,
): JavaRuntime {
const { homedir, version, isJavaHomeEnv, isJdkHomeEnv, isInPathEnv } = jre;
if (version == null) {
Expand Down Expand Up @@ -157,12 +157,12 @@ export default async function getJava(): Promise<string | null> {
async function showMissingJavaError(): Promise<void> {
const item = await vscode.window.showErrorMessage(
`The SAMT language server requires Java ${minimumVersion} or later to be installed. If the automatic detection failed, please configure the path to the Java home directory in the SAMT extension settings.`,
OPEN_SETTINGS
OPEN_SETTINGS,
);
if (item === OPEN_SETTINGS) {
await vscode.commands.executeCommand(
"workbench.action.openSettings",
"samt.java.home"
"samt.java.home",
);
}
}
4 changes: 2 additions & 2 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ interface GithubRelease {

export async function getLatestReleaseAsset(
repository: string,
assetName: string
assetName: string,
): Promise<Release> {
const response = await axios.get<GithubRelease>(
`https://api.github.com/repos/${repository}/releases/latest`
`https://api.github.com/repos/${repository}/releases/latest`,
);
const release = response.data;
const downloadUrl =
Expand Down
10 changes: 5 additions & 5 deletions src/languageServerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class LanguageServerController {
"samtLanguageServer",
"SAMT Language Server",
serverOptions,
clientOptions
clientOptions,
);

await this.client.start();
Expand Down Expand Up @@ -123,7 +123,7 @@ export default class LanguageServerController {
try {
const releaseAsset = await getLatestReleaseAsset(
githubRepository,
jarName
jarName,
);

if (currentFile != null && currentReleaseId === releaseAsset.releaseId) {
Expand All @@ -142,15 +142,15 @@ export default class LanguageServerController {
const file = await fileDownloader.downloadFile(
vscode.Uri.parse(releaseAsset.downloadUrl),
jarName,
this.context
this.context,
);
await this.context.globalState.update(
releaseIdKey,
releaseAsset.releaseId
releaseAsset.releaseId,
);
this.wasDownloaded = true;
return file.fsPath;
}
},
);
} catch (e) {
console.error(e);
Expand Down
16 changes: 8 additions & 8 deletions src/samtTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class SamtTaskProvider implements vscode.TaskProvider {
this.fileWatcher = vscode.workspace.createFileSystemWatcher(
`**/${scriptName}}`,
false,
true // ignore change events
true, // ignore change events
);
const fileListener = () => {
this.tasksPromise = null;
Expand All @@ -37,7 +37,7 @@ export default class SamtTaskProvider implements vscode.TaskProvider {
task.scope ?? vscode.TaskScope.Workspace,
task.name,
task.source,
getShellExecution(definition)
getShellExecution(definition),
);
}

Expand All @@ -57,7 +57,7 @@ interface SamtTaskDefinition extends vscode.TaskDefinition {
}

async function getSamtTasks(
token: vscode.CancellationToken
token: vscode.CancellationToken,
): Promise<vscode.Task[]> {
const wrappers = await findSamtWrappersWithConfig(token);
return wrappers.map((wrapper) => {
Expand All @@ -80,21 +80,21 @@ async function getSamtTasks(
folder ?? vscode.TaskScope.Workspace,
"compile",
"samt",
getShellExecution(definition)
getShellExecution(definition),
);
task.group = vscode.TaskGroup.Build;
return task;
});
}

async function findSamtWrappersWithConfig(
token: vscode.CancellationToken
token: vscode.CancellationToken,
): Promise<vscode.Uri[]> {
const wrappers = await vscode.workspace.findFiles(
`**/${scriptName}`,
undefined,
undefined,
token
token,
);
const wrappersWithConfig: vscode.Uri[] = [];
for (const wrapper of wrappers) {
Expand All @@ -111,13 +111,13 @@ async function hasConfig(wrapperPath: string) {
}

function getShellExecution(
definition: SamtTaskDefinition
definition: SamtTaskDefinition,
): vscode.ShellExecution {
return new vscode.ShellExecution(
`./${scriptName}`,
[definition.command, ...definition.args],
{
cwd: definition.cwd,
}
},
);
}
8 changes: 4 additions & 4 deletions src/test/suite/grammar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import path from "path";
async function readGrammar(): Promise<TextmateGrammar> {
const grammarPath = path.resolve(
__dirname,
"../../../syntaxes/samt.tmLanguage.json"
"../../../syntaxes/samt.tmLanguage.json",
);
const grammarJson = await readFile(grammarPath, "utf8");
return Convert.toTextmateGrammar(grammarJson);
Expand Down Expand Up @@ -46,7 +46,7 @@ suite("TextMate Grammar Test Suite", () => {
}
assert(
pattern.patterns?.some((p) => p.include === "#code"),
`code was not included in pattern ${JSON.stringify(pattern)}`
`code was not included in pattern ${JSON.stringify(pattern)}`,
);
pattern.patterns?.forEach(checkPatternRecursive);
}
Expand All @@ -72,7 +72,7 @@ suite("TextMate Grammar Test Suite", () => {
}: Pattern) {
assert(
name == null || name.endsWith(".samt"),
`scope name "${name ?? ""}" does not end with .samt`
`scope name "${name ?? ""}" does not end with .samt`,
);
patterns?.forEach(checkPatternRecursive);
for (const c of [captures, beginCaptures, endCaptures, whileCaptures]) {
Expand Down Expand Up @@ -140,7 +140,7 @@ suite("TextMate Grammar Test Suite", () => {

function checkRegex(regexString: string): void {
const includedKeywords = keywords.filter((keyword) =>
new RegExp(`\\b${keyword}\\b`).test(regexString)
new RegExp(`\\b${keyword}\\b`).test(regexString),
);
if (includedKeywords.length === 0) {
return;
Expand Down

0 comments on commit f2435c4

Please sign in to comment.