@@ -25,7 +25,7 @@ export default class CodeContextBuilder {
2525 //
2626 // returns a {CodeContext} object
2727 buildCodeContext ( editor , argType = 'Selection Based' ) {
28- if ( ! editor ) return null ;
28+ if ( ! editor ) { return null ; }
2929
3030 const codeContext = this . initCodeContext ( editor ) ;
3131
@@ -35,7 +35,7 @@ export default class CodeContextBuilder {
3535 editor . save ( ) ;
3636 } else if ( codeContext . selection . isEmpty ( ) && codeContext . filepath ) {
3737 codeContext . argType = 'File Based' ;
38- if ( editor && editor . isModified ( ) ) editor . save ( ) ;
38+ if ( editor && editor . isModified ( ) ) { editor . save ( ) ; }
3939 }
4040
4141 // Selection and Line Number Based runs both benefit from knowing the current line
@@ -66,9 +66,9 @@ export default class CodeContextBuilder {
6666
6767 const codeContext = new CodeContext ( filename , filepath , textSource ) ;
6868 codeContext . selection = selection ;
69- codeContext . shebang = this . getShebang ( editor ) ;
69+ codeContext . shebang = getShebang ( editor ) ;
7070
71- const lang = this . getLang ( editor ) ;
71+ const lang = getLang ( editor ) ;
7272
7373 if ( this . validateLang ( lang ) ) {
7474 codeContext . lang = lang ;
@@ -77,18 +77,14 @@ export default class CodeContextBuilder {
7777 return codeContext ;
7878 }
7979
80- getShebang ( editor ) {
81- if ( process . platform === 'win32' ) return null ;
82- const text = editor . getText ( ) ;
83- const lines = text . split ( '\n' ) ;
84- const firstLine = lines [ 0 ] ;
85- if ( ! firstLine . match ( / ^ # ! / ) ) return null ;
86-
87- return firstLine . replace ( / ^ # ! \s * / , '' ) ;
80+ /** @deprecated use {getShebang} function */ // eslint-disable-next-line class-methods-use-this
81+ getShebang ( arg ) {
82+ return getShebang ( arg ) ;
8883 }
8984
90- getLang ( editor ) {
91- return editor . getGrammar ( ) . name ;
85+ /** @deprecated use {getLang} function */ // eslint-disable-next-line class-methods-use-this
86+ getLang ( arg ) {
87+ return getLang ( arg ) ;
9288 }
9389
9490 validateLang ( lang ) {
@@ -117,3 +113,17 @@ export default class CodeContextBuilder {
117113 return this . emitter . on ( 'did-not-support-language' , callback ) ;
118114 }
119115}
116+
117+ export function getShebang ( editor ) {
118+ if ( process . platform === 'win32' ) { return null ; }
119+ const text = editor . getText ( ) ;
120+ const lines = text . split ( '\n' ) ;
121+ const firstLine = lines [ 0 ] ;
122+ if ( ! firstLine . match ( / ^ # ! / ) ) { return null ; }
123+
124+ return firstLine . replace ( / ^ # ! \s * / , '' ) ;
125+ }
126+
127+ export function getLang ( editor ) {
128+ return editor . getGrammar ( ) . name ;
129+ }
0 commit comments