R.swift
R.swift copied to clipboard
Refactor warnings so that it's not an sideeffect anymore
Functions should just return warnings they have encountered. Later on we can print them at once.
This makes code clearer, easier to test and gives us the ability to suppress warnings. We could even add meta data so specific types of warnings could be shown/hidden etc.
Plan of attack for part of this, related to identifier warnings:
- [x] Create a separate
SwiftIdentifier
type instead of a string - [x] Refactor all data types (Struct, Let, etc) to use
SwiftIdentifier
- [x] Refactor code in SanitizedSwiftName.swift to use
SwiftIdentifier
- [ ] Move all code related to identifier checking (duplicates, empty names) into a single (parameterised function), instead of repeating it across all validators. This should fix https://github.com/mac-cain13/R.swift/issues/175
Continuing on:
- [ ] Identify a list of all other warning types
- [ ] Create an enum for those
- [ ] Figure out how to return those best from functions (return value,
inout
param, or mutable object passed around?)