matchClassWithDefaultLayer checks if a class declaration has a Default layer property with Scope in RIn.
(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile, node *ast.Node)
| 137 | Callee: call.Expression, |
| 138 | MethodIdentifier: methodIdentifier, |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | // matchClassWithDefaultLayer checks if a class declaration has a Default layer property with Scope in RIn. |
| 143 | func matchClassWithDefaultLayer(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile, node *ast.Node) *ScopeInLayerEffectMatch { |
| 144 | if node.Kind != ast.KindClassDeclaration { |
| 145 | return nil |
| 146 | } |
| 147 | classDecl := node.AsClassDeclaration() |
| 148 | |
| 149 | // Must have a name and heritage clauses |
| 150 | if node.Name() == nil || classDecl.HeritageClauses == nil { |
| 151 | return nil |
| 152 | } |
| 153 | |
| 154 | // Get the class symbol |
| 155 | classSym := tp.GetSymbolAtLocation(node.Name()) |
| 156 | if classSym == nil { |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | // Get the class type |
| 161 | classType := c.GetTypeOfSymbolAtLocation(classSym, node) |
| 162 | if classType == nil { |
| 163 | return nil |
| 164 | } |
| 165 | |
| 166 | // Check for a "Default" property |
| 167 | defaultProp := c.GetPropertyOfType(classType, "Default") |
| 168 | if defaultProp == nil { |
| 169 | return nil |
| 170 | } |
| 171 | |
| 172 | // Get the Default property's type |
| 173 | defaultType := c.GetTypeOfSymbolAtLocation(defaultProp, node) |
| 174 | if defaultType == nil { |
| 175 | return nil |
| 176 | } |
| 177 | |
| 178 | // Parse as Layer type |
| 179 | layer := tp.LayerType(defaultType) |
| 180 | if layer == nil { |
| 181 | return nil |
| 182 | } |
| 183 | |
| 184 | // Check if RIn contains a Scope type |
| 185 | if !hasScope(tp, layer.RIn) { |
| 186 | return nil |
| 187 | } |
| 188 | |
| 189 | return &ScopeInLayerEffectMatch{ |
| 190 | SourceFile: sf, |
| 191 | Location: scanner.GetErrorRangeForNode(sf, node), |
| 192 | MethodIdentifier: nil, |
| 193 | } |
no test coverage detected