@@ -11,7 +11,7 @@ export class ObjectScriptDiagnosticProvider {
11
11
this . _collection = vscode . languages . createDiagnosticCollection ( "ObjectScript" ) ;
12
12
}
13
13
14
- public updateDiagnostics ( document : vscode . TextDocument ) {
14
+ public updateDiagnostics ( document : vscode . TextDocument ) : void {
15
15
if ( document . languageId . startsWith ( "objectscript" ) ) {
16
16
this . _collection . set ( document . uri , [
17
17
...this . classMembers ( document ) ,
@@ -100,6 +100,8 @@ export class ObjectScriptDiagnosticProvider {
100
100
let isCode = ! isClass ;
101
101
let jsScript = false ;
102
102
let js = false ;
103
+ let html = false ;
104
+ let htmlParens = 0 ;
103
105
let jsParens = 0 ;
104
106
let sql = false ;
105
107
let sqlParens = 0 ;
@@ -111,21 +113,40 @@ export class ObjectScriptDiagnosticProvider {
111
113
112
114
// it is important to check script tag context before ObjectScript comments
113
115
// since /* ... */ comments can also be used in JavaScript
114
- if ( text . match ( / < s c r i p t .* > / i) ) {
116
+ if ( text . match ( / < s c r i p t .* > / i) ) {
115
117
jsScript = true ;
116
118
}
119
+ if ( jsScript ) {
120
+ if ( text . match ( / < \/ s c r i p t > / i) ) {
121
+ jsScript = false ;
122
+ }
123
+ continue ;
124
+ }
117
125
118
126
if ( text . match ( / & j s ( c r i p t ) ? / i) ) {
119
127
js = true ;
120
128
jsParens = 0 ;
121
129
}
122
130
if ( js ) {
123
- jsParens = jsParens + ( text . split ( "<" ) . length - 1 ) - ( text . split ( ">" ) . length - 1 ) ;
131
+ let noParensText = text ;
132
+ while ( noParensText != ( noParensText = noParensText . replace ( / \( [ ^ ( ) ] * \) / g, "" ) ) ) ;
133
+ jsParens = jsParens + ( noParensText . split ( "<" ) . length - 1 ) - ( noParensText . split ( ">" ) . length - 1 ) ;
124
134
if ( jsParens <= 0 ) {
125
135
js = false ;
126
136
}
127
137
continue ;
128
138
}
139
+ if ( text . match ( / & h t m l / i) ) {
140
+ html = true ;
141
+ htmlParens = 0 ;
142
+ }
143
+ if ( html ) {
144
+ htmlParens = htmlParens + ( text . split ( "<" ) . length - 1 ) - ( text . split ( ">" ) . length - 1 ) ;
145
+ if ( htmlParens <= 0 ) {
146
+ html = false ;
147
+ }
148
+ continue ;
149
+ }
129
150
130
151
if ( text . match ( / (?: & | # # ) s q l / i) ) {
131
152
sql = true ;
@@ -140,13 +161,6 @@ export class ObjectScriptDiagnosticProvider {
140
161
continue ;
141
162
}
142
163
143
- if ( jsScript ) {
144
- if ( text . match ( / < \/ s c r i p t > / i) ) {
145
- jsScript = false ;
146
- }
147
- continue ;
148
- }
149
-
150
164
if ( text . match ( / \/ \* / ) ) {
151
165
inComment = true ;
152
166
}
0 commit comments