@@ -26,11 +26,42 @@ export class ObjectScriptDiagnosticProvider {
26
26
27
27
private commands ( document : vscode . TextDocument ) : vscode . Diagnostic [ ] {
28
28
const result = new Array < vscode . Diagnostic > ( ) ;
29
+ const isClass = document . fileName . toLowerCase ( ) . endsWith ( ".cls" ) ;
29
30
31
+ let inComment = false ;
32
+ let endingComma = false ;
33
+ let isCode = ! isClass ;
30
34
for ( let i = 0 ; i < document . lineCount ; i ++ ) {
31
35
const line = document . lineAt ( i ) ;
32
36
const text = this . stripLineComments ( line . text ) ;
33
37
38
+ if ( text . match ( / \/ \* / ) ) {
39
+ inComment = true ;
40
+ }
41
+
42
+ if ( inComment ) {
43
+ if ( text . match ( / \* \/ / ) ) {
44
+ inComment = false ;
45
+ }
46
+ continue ;
47
+ }
48
+ if ( endingComma ) {
49
+ endingComma = text . match ( / , \s * $ / ) !== null ;
50
+ continue ;
51
+ }
52
+ endingComma = text . match ( / , \s * $ / ) !== null ;
53
+ if ( isClass ) {
54
+ if ( isCode ) {
55
+ isCode = text . match ( / ^ } $ / ) === null ;
56
+ } else {
57
+ isCode = text . match ( / ^ ( c l a s s ) ? m e t h o d | t r i g g e r / i) != null ;
58
+ continue ;
59
+ }
60
+ }
61
+ if ( ! isCode ) {
62
+ continue ;
63
+ }
64
+
34
65
const commandsMatch = text . match ( / ^ \s + (?: } \s ) ? \b ( [ a - z ] + ) \b / i) ;
35
66
if ( commandsMatch ) {
36
67
const [ , found ] = commandsMatch ;
@@ -60,10 +91,37 @@ export class ObjectScriptDiagnosticProvider {
60
91
private functions ( document : vscode . TextDocument ) : vscode . Diagnostic [ ] {
61
92
const result = new Array < vscode . Diagnostic > ( ) ;
62
93
94
+ const isClass = document . fileName . toLowerCase ( ) . endsWith ( ".cls" ) ;
95
+
96
+ let inComment = false ;
97
+ let isCode = ! isClass ;
63
98
for ( let i = 0 ; i < document . lineCount ; i ++ ) {
64
99
const line = document . lineAt ( i ) ;
65
100
const text = this . stripLineComments ( line . text ) ;
66
101
102
+ if ( text . match ( / \/ \* / ) ) {
103
+ inComment = true ;
104
+ }
105
+
106
+ if ( inComment ) {
107
+ if ( text . match ( / \* \/ / ) ) {
108
+ inComment = false ;
109
+ }
110
+ continue ;
111
+ }
112
+
113
+ if ( isClass ) {
114
+ if ( isCode ) {
115
+ isCode = text . match ( / ^ } $ / ) === null ;
116
+ } else {
117
+ isCode = text . match ( / ^ ( c l a s s ) ? m e t h o d | t r i g g e r / i) != null ;
118
+ continue ;
119
+ }
120
+ }
121
+ if ( ! isCode ) {
122
+ continue ;
123
+ }
124
+
67
125
const pattern = / (?< ! \$ ) ( \$ \b [ a - z ] + ) \b / gi;
68
126
let functionsMatch = null ;
69
127
while ( ( functionsMatch = pattern . exec ( text ) ) !== null ) {
0 commit comments