How to apply deprecation warning fixit across entire project?

i have hundreds of warnings like these:

warning: 'Symbol' is deprecated: renamed to 'UnifiedSymbol'

this was the goal, because there are many things in the project that have the substring "Symbol" in it (doccomments, generics, nested types, etc.), but the warnings list only the identifiers that should be replaced with UnifiedSymbol.

my question then, is how can i use the warnings to apply the renames across the project, without individually navigating to each source location?

i have heard this is possible in XCode. but i am using VSCode, and i do not know how to do this in VSCode.

1 Like

I would start by doing a regular expression search and replace and define a regular expression with capture groups at each end that are reused in the replacement. This works in vi I don't know if there is an equivalent in VS Code


That assumes your identifiers only use ASCII. There might be a more suitable character class you can use.

The search pattern is ([^0-9a-zA-Z_])Symbol([^0-9a-zA-Z_]). The replacement pattern is /\1UnifiedSymbol\2/.


Since writing the above, I found that VS Code does have a RE search and replace, but it also has a "whole word" search and replace. That will probably do the trick. You need to use the "replace in files" menu option which is on the edit menu.

Screenshot 2023-04-26 at 10.24.28

The three icons on the right of the search box containing "tokens" select respectively, normal, whole word and regular expression. I don't know if the replacement supports capture groups.

this won’t work, because it will also overwrite things like generics:

struct SomeStruct<Symbol> // shadows Symbol

this is why the deprecation warnings are helpful, they only target the actual names that should be replaced.

That doesn't matter because all the shadowed uses of Symbol will also be changed. It will still compile. :slight_smile: Actually, that's probably why you are making this change in the first place.

The perfect is the enemy of the good. Do you want a perfect answer or just one that makes the manual changes manageable?

If you have a Mac available, you can install Xcode and use its rename function. If not, you could probably extract the files and line numbers of all the warnings and use them to create a sed script to make the changes.

1 Like

the reason i’m making this change is because Symbol is too general a name to live in a frequently @_exported top-level namespace. it’s one of those “enum polymorphism” types:

enum UnifiedSymbol
    case a(ASymbol)
    case b(BSymbol)
    case c(CSymbol)

but when it’s a generic, the name Symbol is expected to be bound to one of the ASymbol, BSymbol, etc. payload types. so UnifiedSymbol is actively misleading there.

i do not.

In that case, I'd be looking at a partial manual approach. All files that do not have a generic Symbol in them: I would just do a global search and replace. Files that do have generic Symbol in them would be manually fixed or I would cut the generic types out temporarily and do a global search and replace.