@@ -11,7 +11,7 @@ export class ObjectScriptDiagnosticProvider {
1111 this . _collection = vscode . languages . createDiagnosticCollection ( "ObjectScript" ) ;
1212 }
1313
14- public updateDiagnostics ( document : vscode . TextDocument ) {
14+ public updateDiagnostics ( document : vscode . TextDocument ) : void {
1515 if ( document . languageId . startsWith ( "objectscript" ) ) {
1616 this . _collection . set ( document . uri , [
1717 ...this . classMembers ( document ) ,
@@ -47,7 +47,7 @@ export class ObjectScriptDiagnosticProvider {
4747 }
4848
4949 const memberMatch = text . match (
50- / ^ ( C l a s s | P r o p e r t y | R e l a t i o n s h i p | I n d e x | (?: (?: C l i e n t ) ? (?: C l a s s ) ? M e t h o d ) | C l i e n t C l a s s M e t h o d | M e t h o d | X D a t a | Q u e r y | T r i g g e r | F o r e i g n K e y | P r o j e c t i o n | P a r a m e t e r ) \s ( \b [ ^ ( ] + \b ) / i
50+ / ^ ( C l a s s | P r o p e r t y | R e l a t i o n s h i p | I n d e x | (?: (?: C l i e n t ) ? (?: C l a s s ) ? M e t h o d ) | C l i e n t C l a s s M e t h o d | M e t h o d | X D a t a | Q u e r y | T r i g g e r | F o r e i g n K e y | P r o j e c t i o n | P a r a m e t e r ) \s ( (?: " [ ^ " ] + " ) | (?: [ ^ ( ; ] + ) ) / i
5151 ) ;
5252 if ( memberMatch ) {
5353 const [ fullMatch , type , name ] = memberMatch ;
@@ -72,6 +72,25 @@ export class ObjectScriptDiagnosticProvider {
7272 } ) ;
7373 }
7474 map . set ( key , fullMatch ) ;
75+
76+ let leftChars ;
77+ if ( ! name . startsWith ( '"' ) && ( leftChars = name . replace ( / [ % a - z 0 - 9 . ] / gi, "" ) ) && leftChars !== "" ) {
78+ const pos = line . text . indexOf ( name ) ;
79+ const range = new vscode . Range ( new vscode . Position ( i , pos ) , new vscode . Position ( i , pos + name . length ) ) ;
80+ result . push ( {
81+ code : "" ,
82+ message : "Non-latin characters" ,
83+ range,
84+ severity : vscode . DiagnosticSeverity . Warning ,
85+ source : "" ,
86+ relatedInformation : [
87+ new vscode . DiagnosticRelatedInformation (
88+ new vscode . Location ( document . uri , range ) ,
89+ `Element name contains non-latin characters: ${ leftChars } `
90+ ) ,
91+ ] ,
92+ } ) ;
93+ }
7594 }
7695 }
7796
0 commit comments