Skip to content

Commit

Permalink
Fix formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaprieto committed Jun 2, 2023
1 parent 406fc4c commit b85b3da
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 35 deletions.
6 changes: 1 addition & 5 deletions src/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ export async function activate(context: vscode.ExtensionContext) {

if (ls.status !== 0) {
const errMsg: string = "Juvix's Error: " + ls.stderr.toString();
logger.error(
'typechecking-silent provider error' + errMsg,
'check.ts'
);
throw new Error(errMsg);
logger.error( errMsg, 'check.ts' );
}
return ls.stdout;
}
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import * as vampir from './vampir/tasks';
export async function activate(context: vscode.ExtensionContext) {
statusBar.activate(context);
codelens.activate(context);
// syntaxHighlighter.activate(context);
// goToDefinition.activate(context);
syntaxHighlighter.activate(context);
goToDefinition.activate(context);
hoverInfo.activate(context);
tasks.activate(context);
inputMethod.activate(context);
Expand Down
7 changes: 4 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function activate(_context: vscode.ExtensionContext) {
return [vscode.TextEdit.replace(range, stdout)];
} else {
const errMsg: string = ls.stderr.toString();
logger.error('formatter provider error' + errMsg, 'formatter.ts');
throw new Error(errMsg);
logger.error(errMsg, 'formatter.ts');
return [];
}
},
});
Expand Down Expand Up @@ -77,8 +77,9 @@ export function activate(_context: vscode.ExtensionContext) {
return [vscode.TextEdit.replace(range, stdout)];
} else {
const errMsg: string = ls.stderr.toString();
throw new Error(errMsg);
logger.error(errMsg, 'formatter.ts');
}
return [];
},
});
}
5 changes: 1 addition & 4 deletions src/highlighting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
DevHighlightOutput,
HoverProperty,
} from './interfaces';
import { JuvixConfig } from './config';
import { config } from './config';
import { spawnSync } from 'child_process';

/*
Expand All @@ -30,7 +30,6 @@ map that associates a file path to the corresponding information for that file.
*/

export async function activate(context: vscode.ExtensionContext) {
const config = new JuvixConfig();
if (!config.enableSemanticSyntax.get()) return;
try {
const semanticTokensProvider = new Highlighter();
Expand Down Expand Up @@ -99,8 +98,6 @@ export class Highlighter implements vscode.DocumentSemanticTokensProvider {
const content: string = document.getText();
const contentLines: string[] = content.split('\n');

const config = new JuvixConfig();

/*
Call the highlighter
*/
Expand Down
2 changes: 1 addition & 1 deletion src/judoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class JudocPanel {
message => {
switch (message.command) {
case 'alert':
vscode.window.showErrorMessage(message.text);
logger.error(message.text, 'judoc');
return;
}
},
Expand Down
3 changes: 1 addition & 2 deletions src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export async function activate(context: vscode.ExtensionContext) {
const msg =
'Juvix extension requires at least one workspace open.\n' +
'Open a folder containing a Juvix project and try again.';
vscode.window.showErrorMessage(msg);
logger.error(msg);
logger.error(msg, 'tasks.ts');
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ export function assert(condition: () => boolean): void {
if (!condition()) {
const msg = `Assert failed: "${condition.toString()}" must be true, but was not!`;
logger.error(msg);
throw new Error(msg);
}
}
4 changes: 2 additions & 2 deletions src/utils/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class Log {
vscode.window.showWarningMessage(msg);
}

public error(message: string, component?: string) {
public error(message: string, component?: string, modal:boolean = false) {
const msg = this.logString(message, component);
this.outputChannel.error(msg);
vscode.window.showErrorMessage(msg);
vscode.window.showErrorMessage(msg, {modal : modal });
throw new Error(msg);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/utils/fromResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export function fromResource<T>(
value = getValue();
} else {
const msg = 'Either an argument or getValue must be provided';
logger.error(msg);
throw new Error(msg);
logger.error(msg, 'fromResource.ts');
}
atom.reportChanged();
});
Expand Down
63 changes: 50 additions & 13 deletions syntaxes/Juvix.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"name": "Juvix",
"scopeName": "source.Juvix",
"fileTypes": [
"Juvix"
],
"fileTypes": ["Juvix"],
"patterns": [
{
"include": "#comment"
Expand All @@ -13,6 +11,15 @@
},
{
"include": "#number"
},
{
"include": "#keyword"
},
{
"include": "#constant"
},
{
"include": "#operator"
}
],
"repository": {
Expand Down Expand Up @@ -54,23 +61,53 @@
}
]
},
"string" :
{
"patterns" : [
"string": {
"patterns": [
{
"match" : "\".*\"",
"name" : "string"
"match": "\".*\"",
"name": "string"
}
]
},
"number" : {
"patterns" : [
"number": {
"patterns": [
{
"match": "[0-9]+",
"name": "number"
}
]
},
"keyword": {
"patterns": [
{
"match": "\\b(let|in|case|type|module|import|open|using|hiding|public|as|terminating|positive|Type|builtin|syntax)\\b",
"name": "keyword"
},
{
"name": "axiom",
"match": "(;)"
},
{
"name": "keyword",
"match": "(:=|:|\\/|->|→|↦|@|\\|)"
}
]
},
"constant": {
"patterns": [
{
"match": "\\b(true|false)\\b",
"name": "constant.language"
}
]
},
"operator": {
"patterns": [
{
"match" : "[0-9]+",
"name" : "number"
"match": "(\\+|-|\\*|\\^|\\$|&&|\\!|==|>>|<=|>=)",
"name": "function"
}
]
}
}

}

0 comments on commit b85b3da

Please sign in to comment.