@@ -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 ) ,
@@ -100,6 +100,8 @@ export class ObjectScriptDiagnosticProvider {
100100 let isCode = ! isClass ;
101101 let jsScript = false ;
102102 let js = false ;
103+ let html = false ;
104+ let htmlParens = 0 ;
103105 let jsParens = 0 ;
104106 let sql = false ;
105107 let sqlParens = 0 ;
@@ -111,21 +113,40 @@ export class ObjectScriptDiagnosticProvider {
111113
112114 // it is important to check script tag context before ObjectScript comments
113115 // 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) ) {
115117 jsScript = true ;
116118 }
119+ if ( jsScript ) {
120+ if ( text . match ( / < \/ s c r i p t > / i) ) {
121+ jsScript = false ;
122+ }
123+ continue ;
124+ }
117125
118126 if ( text . match ( / & j s ( c r i p t ) ? / i) ) {
119127 js = true ;
120128 jsParens = 0 ;
121129 }
122130 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 ) ;
124134 if ( jsParens <= 0 ) {
125135 js = false ;
126136 }
127137 continue ;
128138 }
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+ }
129150
130151 if ( text . match ( / (?: & | # # ) s q l / i) ) {
131152 sql = true ;
@@ -140,13 +161,6 @@ export class ObjectScriptDiagnosticProvider {
140161 continue ;
141162 }
142163
143- if ( jsScript ) {
144- if ( text . match ( / < \/ s c r i p t > / i) ) {
145- jsScript = false ;
146- }
147- continue ;
148- }
149-
150164 if ( text . match ( / \/ \* / ) ) {
151165 inComment = true ;
152166 }
0 commit comments