@@ -3,9 +3,9 @@ import { handleComments, printComment } from './slang-comments/index.js';
33import massageAstNode from './clean.js' ;
44import loc from './loc.js' ;
55import options from './options.js' ;
6- import parse from './parser.js' ;
7- import print from './printer.js' ;
8- import solidityParse from './slangSolidityParser.js' ;
6+ import antlrParse from './parser.js' ;
7+ import antlrPrint from './printer.js' ;
8+ import slangParse from './slangSolidityParser.js' ;
99import slangPrint from './slangPrinter.js' ;
1010import { isComment , isBlockComment } from './slang-utils/is-comment.js' ;
1111import { locEnd , locStart } from './slang-utils/loc.js' ;
@@ -18,8 +18,10 @@ import type {
1818} from 'prettier' ;
1919import type { AstNode } from './slang-nodes' ;
2020
21- const parserSolidity = 'slang-solidity' ;
22- const astFormat = 'slang-ast' ;
21+ const slangParserId = 'slang-solidity' ;
22+ const antlrParserId = 'solidity-parse' ;
23+ const slangAstId = 'slang-ast' ;
24+ const antlrAstId = 'solidity-ast' ;
2325
2426// https://prettier.io/docs/en/plugins.html#languages
2527// https://github.com/github-linguist/linguist/blob/master/lib/linguist/languages.yml
@@ -30,23 +32,23 @@ const languages: SupportLanguage[] = [
3032 aceMode : 'text' ,
3133 tmScope : 'source.solidity' ,
3234 extensions : [ '.sol' ] ,
33- parsers : [ parserSolidity , 'solidity-parse' ] ,
35+ parsers : [ slangParserId , antlrParserId ] ,
3436 vscodeLanguageIds : [ 'solidity' ]
3537 }
3638] ;
3739
3840// https://prettier.io/docs/en/plugins.html#parsers
39- const parser = { astFormat : 'solidity-ast' , parse, ...loc } ;
40- const solidityParser : Parser < AstNode > = {
41- astFormat,
42- parse : solidityParse ,
41+ const antlrParser = { astFormat : antlrAstId , parse : antlrParse , ...loc } ;
42+ const slangParser : Parser < AstNode > = {
43+ astFormat : slangAstId ,
44+ parse : slangParse ,
4345 locStart,
4446 locEnd
4547} ;
4648
4749const parsers = {
48- [ parserSolidity ] : solidityParser ,
49- 'solidity-parse' : parser
50+ [ slangParserId ] : slangParser ,
51+ [ antlrParserId ] : antlrParser
5052} ;
5153
5254const solidityCanAttachComment = ( node : { type : string } ) : boolean =>
@@ -60,7 +62,7 @@ const canAttachComment = (node: AstNode): boolean =>
6062 ! isComment ( node ) ;
6163
6264// https://prettier.io/docs/en/plugins.html#printers
63- const printer = {
65+ const antlrPrinter = {
6466 canAttachComment : solidityCanAttachComment ,
6567 handleComments : {
6668 ownLine : comments . solidityHandleOwnLineComment ,
@@ -69,7 +71,7 @@ const printer = {
6971 } ,
7072 isBlockComment : comments . isBlockComment ,
7173 massageAstNode,
72- print,
74+ print : antlrPrint ,
7375 printComment : comments . printComment
7476} ;
7577const slangPrinter : Printer < AstNode > = {
@@ -82,8 +84,8 @@ const slangPrinter: Printer<AstNode> = {
8284} ;
8385
8486const printers = {
85- [ astFormat ] : slangPrinter ,
86- 'solidity-ast' : printer
87+ [ slangAstId ] : slangPrinter ,
88+ [ antlrAstId ] : antlrPrinter
8789} ;
8890
8991// https://prettier.io/docs/en/plugins.html#defaultoptions
0 commit comments