@@ -45,6 +45,7 @@ export class ObjectScriptDiagnosticProvider {
4545 }
4646 continue ;
4747 }
48+ let skipNonLatin = false ;
4849
4950 const memberMatch = text . match (
5051 / ^ ( 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
@@ -53,6 +54,53 @@ export class ObjectScriptDiagnosticProvider {
5354 const [ fullMatch , type , name ] = memberMatch ;
5455 const simpleType = type . toLowerCase ( ) . replace ( "classmethod" , "method" ) . replace ( "relationship" , "property" ) ;
5556 const key = simpleType === "class" ? simpleType : [ simpleType , name ] . join ( ":" ) ;
57+ if ( simpleType === "class" ) {
58+ if ( ! name . includes ( "." ) ) {
59+ const pos = line . text . indexOf ( name ) ;
60+ const range = new vscode . Range ( new vscode . Position ( i , pos ) , new vscode . Position ( i , pos + name . length ) ) ;
61+ result . push ( {
62+ code : "" ,
63+ message : "Class name is incorrect" ,
64+ range,
65+ severity : vscode . DiagnosticSeverity . Error ,
66+ source : "" ,
67+ relatedInformation : [
68+ new vscode . DiagnosticRelatedInformation (
69+ new vscode . Location ( document . uri , range ) ,
70+ `Class name '${ name } ' should contain package name`
71+ ) ,
72+ ] ,
73+ } ) ;
74+ }
75+ }
76+ const notValid =
77+ simpleType !== "class" && name . startsWith ( '"' ) && name . endsWith ( '"' )
78+ ? simpleType !== "class" && name . includes ( "." )
79+ ? "."
80+ : ""
81+ : name [ 0 ] . replace ( / [ ^ \x21 - \x2F \x3A - \x40 \x5B - \x60 \x7B - \x7E 0 - 9 ] | % / g, "" ) +
82+ name
83+ . slice ( 1 )
84+ . replace ( simpleType === "class" ? "." : "" , "" )
85+ . replace ( / [ ^ \x21 - \x2F \x3A - \x40 \x5B - \x60 \x7B - \x7E ] / g, "" ) ;
86+ if ( notValid !== "" ) {
87+ const pos = line . text . indexOf ( name ) ;
88+ const range = new vscode . Range ( new vscode . Position ( i , pos ) , new vscode . Position ( i , pos + name . length ) ) ;
89+ result . push ( {
90+ code : "" ,
91+ message : "Name is incorrect" ,
92+ range,
93+ severity : vscode . DiagnosticSeverity . Error ,
94+ source : "" ,
95+ relatedInformation : [
96+ new vscode . DiagnosticRelatedInformation (
97+ new vscode . Location ( document . uri , range ) ,
98+ `'${ fullMatch } ' contains not valid characters '${ notValid } '`
99+ ) ,
100+ ] ,
101+ } ) ;
102+ skipNonLatin = true ;
103+ }
56104 if ( map . has ( key ) ) {
57105 const original = map . get ( key ) ;
58106 const pos = line . text . indexOf ( name ) ;
@@ -74,7 +122,12 @@ export class ObjectScriptDiagnosticProvider {
74122 map . set ( key , fullMatch ) ;
75123
76124 let leftChars ;
77- if ( ! name . startsWith ( '"' ) && ( leftChars = name . replace ( / [ % a - z 0 - 9 . ] / gi, "" ) ) && leftChars !== "" ) {
125+ if (
126+ ! skipNonLatin &&
127+ ! name . startsWith ( '"' ) &&
128+ ( leftChars = name . replace ( / [ % a - z 0 - 9 . ] / gi, "" ) ) &&
129+ leftChars !== ""
130+ ) {
78131 const pos = line . text . indexOf ( name ) ;
79132 const range = new vscode . Range ( new vscode . Position ( i , pos ) , new vscode . Position ( i , pos + name . length ) ) ;
80133 result . push ( {
0 commit comments