resolveTypeHandle resolves a type handle within the project's registry.
(projectID ProjectID, handle TypeID)
| 246 | |
| 247 | // resolveTypeHandle resolves a type handle within the project's registry. |
| 248 | func (sd *snapshotData) resolveTypeHandle(projectID ProjectID, handle TypeID) (*checker.Type, error) { |
| 249 | if handle == 0 { |
| 250 | return nil, fmt.Errorf("%w: empty type handle", ErrClientError) |
| 251 | } |
| 252 | if projectID == "" { |
| 253 | return nil, fmt.Errorf("%w: empty project ID for type handle %d", ErrClientError, handle) |
| 254 | } |
| 255 | |
| 256 | sd.projectRegistriesMu.RLock() |
| 257 | reg := sd.projectRegistries[projectID] |
| 258 | sd.projectRegistriesMu.RUnlock() |
| 259 | |
| 260 | if reg == nil { |
| 261 | return nil, fmt.Errorf("%w: type handle %d not found (no registry for project %s)", ErrClientError, handle, projectID) |
| 262 | } |
| 263 | |
| 264 | reg.typeRegistryMu.RLock() |
| 265 | t, ok := reg.typeRegistry[handle] |
| 266 | reg.typeRegistryMu.RUnlock() |
| 267 | |
| 268 | if !ok { |
| 269 | return nil, fmt.Errorf("%w: type handle %d not found in project registry", ErrClientError, handle) |
| 270 | } |
| 271 | |
| 272 | return t, nil |
| 273 | } |
| 274 | |
| 275 | // resolveSignatureHandle resolves a signature handle within the project's registry. |
| 276 | func (sd *snapshotData) resolveSignatureHandle(projectID ProjectID, handle SignatureID) (*checker.Signature, error) { |
no test coverage detected