Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove me #295

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"@typescript-eslint/tslint",
"jsdoc",
"prefer-arrow",
"eslint-plugin-import"
"eslint-plugin-import",
"@stylistic/ts"
],
"settings": {},
"globals": {
Expand Down Expand Up @@ -489,7 +490,7 @@
"accessibility": "explicit"
}
],
"@typescript-eslint/indent": [
"@stylistic/ts/indent": [
"error",
4,
{
Expand Down Expand Up @@ -558,15 +559,15 @@
"@typescript-eslint/no-loss-of-precision": "off", // TODO: enable
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/quotes": [
"@stylistic/ts/quotes": [
"error",
"double",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"@typescript-eslint/semi": [
"@stylistic/ts/semi": [
"error",
"always"
],
Expand Down
2,308 changes: 1,663 additions & 645 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@
"build-watch": "npm run build -- --watch"
},
"dependencies": {
"@stylistic/eslint-plugin-ts": "^2.6.4",
mlshort marked this conversation as resolved.
Show resolved Hide resolved
"@unicode/unicode-11.0.0": "1.5.2",
"@vscode/debugadapter": "1.65.0",
"@vscode/debugprotocol": "1.65.0",
Expand All @@ -603,7 +604,10 @@
"antlr4ng": "^3.0.4",
"await-notify": "1.0.1",
"d3": "7.9.0",
"fs-extra": "11.2.0"
"fs-extra": "11.2.0",
"node-notifier": "^10.0.1",
"swc": "^1.0.11",
"@swc/core": "^1.7.14"
mlshort marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@types/d3": "7.4.3",
Expand All @@ -613,9 +617,9 @@
"@types/vscode": "1.90.0",
"@typescript-eslint/eslint-plugin": "8.0.0",
"@typescript-eslint/eslint-plugin-tslint": "7.0.2",
"@typescript-eslint/parser": "7.14.1",
"@typescript-eslint/parser": "8.0.0",
"antlr4ng-cli": "^2.0.0",
"esbuild": "0.23.0",
"esbuild": "0.23.1",
"eslint": "8.57.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "48.2.7",
Expand Down
8 changes: 4 additions & 4 deletions src/backend/DetailsListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DetailsListener extends ANTLRv4ParserListener {
}

public override enterParserRuleSpec = (ctx: ParserRuleSpecContext): void => {
this.pushNewSymbol(RuleSymbol, ctx, ctx.RULE_REF()!.getText());
this.pushNewSymbol(RuleSymbol, ctx, ctx.RULE_REF().getText());
};

public override exitParserRuleSpec = (_ctx: ParserRuleSpecContext): void => {
Expand All @@ -86,9 +86,9 @@ export class DetailsListener extends ANTLRv4ParserListener {

public override enterLexerRuleSpec = (ctx: LexerRuleSpecContext): void => {
if (ctx.FRAGMENT()) {
this.pushNewSymbol(FragmentTokenSymbol, ctx, ctx.TOKEN_REF()!.getText());
this.pushNewSymbol(FragmentTokenSymbol, ctx, ctx.TOKEN_REF().getText());
} else {
this.pushNewSymbol(TokenSymbol, ctx, ctx.TOKEN_REF()!.getText());
this.pushNewSymbol(TokenSymbol, ctx, ctx.TOKEN_REF().getText());
}
};

Expand Down Expand Up @@ -209,7 +209,7 @@ export class DetailsListener extends ANTLRv4ParserListener {
* @param ctx The parser context for the action block.
*/
public override exitActionBlock = (ctx: ActionBlockContext): void => {
let run = ctx.parent as ParserRuleContext | null;
let run = ctx.parent;

while (run) {
switch (run.ruleIndex) {
Expand Down
12 changes: 6 additions & 6 deletions src/backend/SVGGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class SVGGenerator extends ANTLRv4ParserVisitor<string> {

public override visitParserRuleSpec = (ctx: ParserRuleSpecContext): string => {
this.#nestedCharLength = 0;
const ruleName = ctx.RULE_REF()!.getText();
const ruleName = ctx.RULE_REF().getText();
if (ruleName === this.#requestedRuleName) {
this.#done = true;

Expand Down Expand Up @@ -93,11 +93,11 @@ export class SVGGenerator extends ANTLRv4ParserVisitor<string> {
};

public override visitLexerRuleSpec = (ctx: LexerRuleSpecContext): string => {
const ruleName = ctx.TOKEN_REF()!.getText();
const ruleName = ctx.TOKEN_REF().getText();
if (ruleName === this.#requestedRuleName) {
this.#done = true;

return "new Diagram(" + this.visitLexerAltList(ctx.lexerRuleBlock()!.lexerAltList()) + ")";
return "new Diagram(" + this.visitLexerAltList(ctx.lexerRuleBlock().lexerAltList()) + ")";
}

return "";
Expand Down Expand Up @@ -266,9 +266,9 @@ export class SVGGenerator extends ANTLRv4ParserVisitor<string> {

if (ctx.blockSuffix()) {
return this.visitEbnfSuffix(ctx.blockSuffix()!.ebnfSuffix()) + "(" +
this.visitAltList(ctx.block()!.altList()) + ")";
this.visitAltList(ctx.block().altList()) + ")";
} else {
return this.visitAltList(ctx.block()!.altList());
return this.visitAltList(ctx.block().altList());
}
};

Expand Down Expand Up @@ -313,7 +313,7 @@ export class SVGGenerator extends ANTLRv4ParserVisitor<string> {
if (ctx.terminalDef()) {
return this.visitTerminalDef(ctx.terminalDef()!);
} else if (ctx.ruleref()) {
return this.visitTerminal(ctx.ruleref()!.RULE_REF()!);
return this.visitTerminal(ctx.ruleref()!.RULE_REF());
} else if (ctx.notSet()) {
return this.visitNotSet(ctx.notSet()!);
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/SemanticListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class SemanticListener extends ANTLRv4ParserListener {
* @param ctx The lexer rule context.
*/
public override exitLexerRuleSpec = (ctx: LexerRuleSpecContext): void => {
const tokenRef = ctx.TOKEN_REF()!;
const tokenRef = ctx.TOKEN_REF();
const name = tokenRef.getText();

// The symbol table already contains an entry for this symbol. So we can only partially use that
Expand All @@ -113,7 +113,7 @@ export class SemanticListener extends ANTLRv4ParserListener {
*/
public override exitParserRuleSpec = (ctx: ParserRuleSpecContext): void => {
// Same processing here as for lexer rules.
const ruleRef = ctx.RULE_REF()!;
const ruleRef = ctx.RULE_REF();
const name = ruleRef.getText();
const seenSymbol = this.seenSymbols.get(name);
if (seenSymbol) {
Expand Down
10 changes: 7 additions & 3 deletions src/backend/SourceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ export class SourceContext {
return Promise.resolve([]);
}
} else {
return Promise.reject(errors);
return Promise.reject(Error(errors));
}
}

Expand Down Expand Up @@ -1114,7 +1114,11 @@ export class SourceContext {
fileList.push(dependency.fileName);

const actualParameters = [...parameters, dependency.fileName];
const result = await this.doGeneration(actualParameters, spawnOptions, errorParser, options.javaHomeOverride, options.outputDir);
const result = await this.doGeneration(actualParameters,
spawnOptions,
errorParser,
options.javaHomeOverride,
options.outputDir);
if (result.length > 0) {
message += "\n" + result;
}
Expand Down Expand Up @@ -1743,7 +1747,7 @@ export class SourceContext {
if (flag) {
resolve(this.setupInterpreters(outputDir));
} else {
reject(buffer); // Treat this as non-grammar output (e.g. Java exception).
reject(Error(buffer)); // Treat this as non-grammar output (e.g. Java exception).
}
});
});
Expand Down
8 changes: 6 additions & 2 deletions src/frontend/ActionsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ export class ActionsProvider extends AntlrTreeDataProvider<TreeItem> {

resolve(list);
} catch (e) {
reject(e);
if (e instanceof Error) {
reject(e);
}
}
});
}
Expand Down Expand Up @@ -244,7 +246,9 @@ export class ActionsProvider extends AntlrTreeDataProvider<TreeItem> {

resolve(rootList);
} catch (e) {
reject(e);
if (e instanceof Error) {
reject(e);
}
}
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/CompletionItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class AntlrCompletionItemProvider {

resolve(new CompletionList(completionList, false));
}).catch((reason) => {
reject(reason);
if (reason instanceof Error) {
reject(reason);
}
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/FrontendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class FrontendUtils {
*/
public static updateVsCodeContext(backend: AntlrFacade, document: TextDocument | undefined): void {
if (document && FrontendUtils.isGrammarFile(document)) {
const info = backend.getContextDetails(document.fileName); 1;
const info = backend.getContextDetails(document.fileName);
void FrontendUtils.switchVsCodeContext("antlr4.isLexer", info.type === GrammarType.Lexer);
void FrontendUtils.switchVsCodeContext("antlr4.isParser", info.type === GrammarType.Parser);
void FrontendUtils.switchVsCodeContext("antlr4.isCombined", info.type === GrammarType.Combined);
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/ParserSymbolsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ParserSymbolsProvider extends AntlrTreeDataProvider<ParserSymbolIte
rules.forEach((rule, index) => {
const info = this.backend.infoForSymbol(this.currentFile!, rule);
const parameters: Command = { title: "", command: "" };
const caption = `${index}: ${rules![index]}`;
const caption = `${index}: ${rules[index]}`;
if (info && info.definition) {
parameters.title = "";
parameters.command = "antlr.selectGrammarRange";
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/webviews/WebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class WebviewProvider {
protected currentRuleIndex: number | undefined;

// Keep track of all created panels, to avoid duplicates.
private webViewMap = new Map<String, [WebviewPanel, IWebviewShowOptions]>();
private webViewMap = new Map<string, [WebviewPanel, IWebviewShowOptions]>();

public constructor(protected backend: AntlrFacade, protected context: ExtensionContext) { }

Expand Down