File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
server/src/project/elements Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -85,15 +85,26 @@ export class ModuleElement extends BaseModuleElement implements ScopeElement {
8585}
8686
8787export class ClassElement extends BaseModuleElement {
88+ context : ClassModuleContext ;
8889 protected _name : string ;
8990
9091 constructor ( context : ClassModuleContext , document : TextDocument ) {
9192 super ( context , document , SymbolKind . Class ) ;
93+ this . context = context ;
9294 this . _name = this . _getName ( context ) ;
9395 }
9496
9597 evaluateDiagnostics ( ) : void {
96- return ;
98+ if ( ! this . _hasOptionExplicit ( ) ) {
99+ const header = this . context . classModuleHeader ( ) ;
100+ const startLine = header . stop ?. line ?? 0 + 1 ;
101+ this . diagnostics . push ( new MissingOptionExplicitDiagnostic (
102+ Range . create (
103+ startLine , 1 ,
104+ startLine , 1
105+ )
106+ ) ) ;
107+ }
97108 }
98109
99110 private _getName ( context : ClassModuleContext ) {
@@ -110,6 +121,21 @@ export class ClassElement extends BaseModuleElement {
110121 const nameAttribute = nameAttributes [ 0 ] ;
111122 return nameAttribute . STRINGLITERAL ( ) . getText ( ) . stripQuotes ( ) ;
112123 }
124+
125+ private _hasOptionExplicit ( ) : boolean {
126+ const moduleDeclarations = this . context . classModuleBody ( ) . classModuleDeclarationSection ( ) ?. classModuleDeclarationElement ( ) ;
127+ if ( ! moduleDeclarations ) {
128+ return false ;
129+ }
130+
131+ for ( const declaration of moduleDeclarations ) {
132+ if ( declaration . commonOptionDirective ( ) ?. optionExplicitDirective ( ) ) {
133+ return true ;
134+ }
135+ }
136+
137+ return false ;
138+ }
113139}
114140
115141
You can’t perform that action at this time.
0 commit comments