Skip to content

Commit 7ec0af9

Browse files
committed
first path implementation for recognizing js <script> tags
1 parent ad94a04 commit 7ec0af9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/providers/ObjectScriptDiagnosticProvider.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,24 @@ export class ObjectScriptDiagnosticProvider {
9595
let inComment = false;
9696
let endingComma = false;
9797
let isCode = !isClass;
98+
let jsScript = false;
9899
for (let i = 0; i < document.lineCount; i++) {
99100
const line = document.lineAt(i);
100101
const text = this.stripLineComments(line.text);
101102

103+
// it is important to check script tag context before ObjectScript comments
104+
// since /* ... */ comments can also be used in JavaScript
105+
if (text.match(/<script .*>/)) {
106+
jsScript = true;
107+
}
108+
109+
if (jsScript) {
110+
if (text.match(/<\/script>/)) {
111+
jsScript = false;
112+
}
113+
continue;
114+
}
115+
102116
if (text.match(/\/\*/)) {
103117
inComment = true;
104118
}

0 commit comments

Comments
 (0)