@@ -45,6 +45,7 @@ export class ObjectScriptDiagnosticProvider {
45
45
}
46
46
continue ;
47
47
}
48
+ let skipNonLatin = false ;
48
49
49
50
const memberMatch = text . match (
50
51
/ ^ ( 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 {
53
54
const [ fullMatch , type , name ] = memberMatch ;
54
55
const simpleType = type . toLowerCase ( ) . replace ( "classmethod" , "method" ) . replace ( "relationship" , "property" ) ;
55
56
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 invalid" ,
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 have a package name prefix`
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 invalid" ,
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 invalid characters '${ notValid } '`
99
+ ) ,
100
+ ] ,
101
+ } ) ;
102
+ skipNonLatin = true ;
103
+ }
56
104
if ( map . has ( key ) ) {
57
105
const original = map . get ( key ) ;
58
106
const pos = line . text . indexOf ( name ) ;
@@ -74,7 +122,12 @@ export class ObjectScriptDiagnosticProvider {
74
122
map . set ( key , fullMatch ) ;
75
123
76
124
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
+ ) {
78
131
const pos = line . text . indexOf ( name ) ;
79
132
const range = new vscode . Range ( new vscode . Position ( i , pos ) , new vscode . Position ( i , pos + name . length ) ) ;
80
133
result . push ( {
0 commit comments