mantish/ help / docs
Join the waitlist

Rename rules

Decide per language and kind of declaration which renames to mute, hide or spotlight.

Last updated

Renaming one method can touch every line that calls it: a diff of a hundred lines with nothing else in it. Mantish recognises a rename from the structure of the code — not by guessing from the text — so you can tell it what to do with renames, precisely.

For each language, every kind of declaration — classes, methods, fields, parameters and so on — gets its own state:

StateEffect
ShowThe rename is a normal change
MuteThe rename is greyed out, like any muted change
HideThe rename is not drawn at all, only counted
SpotlightThe rename is highlighted, like any spotlighted change

Show, Mute and Hide are set under Auto-mute; Show and Spotlight under Spotlight. For example: hide renamed fields, parameters and variables in Go, mute renamed methods, and spotlight every renamed C# class and interface.

Safe by design

  • A rename is only a rename. A change that renames something and edits anything the rename does not explain is shown in full. No rule mutes or hides it.
  • Mixed renames are muted, not hidden. A change that renames a hidden kind and a muted one — a field and a method — is muted.
  • Spotlight wins. If a renamed kind is both muted and spotlighted, the rename is spotlighted.
  • Public API stays on screen. A rule never mutes or hides the rename of a public or protected declaration — a method or a property code outside may use — unless you turn on Public too for that kind. Where Mantish cannot tell a declaration's visibility, a change it tags breaking is not muted either.

Visibility

Every kind that has a visibility in its language — types and members, not locals or parameters — can be scoped. Under Auto-mute, Not public (the default) mutes or hides only private and internal renames, and Public too mutes or hides them all. Under Spotlight, Any visibility (the default) spotlights every rename of the kind, and Public only just the public and protected ones.

Visibility is read from each declaration's own words, or its language's default where it stands — the visibility of what contains it is not taken into account:

  • C#, Java, Kotlin, Scala, PHP, Swift, Rust, TypeScript, C++ — the access modifier. Without one, the language's default: private in a C# class, package access in Java, public in Kotlin, Scala and PHP, internal in Swift, private in Rust, private in a C++ class and public in a struct. An interface's members are public. A C# record's positional parameter is the public property it declares.
  • TypeScript, JavaScript — a module's declaration is public when it is exported, private otherwise; a #name is private.
  • Go — an exported name is public, any other internal to its package.
  • Python — __name is private, _name internal, any other name public.
  • Dart — a name starting with _ is private to its library.
  • Ruby — private and protected sections, private def, and private :name.
  • C — static is private. Lua — local function is private.
  • GDScript, HCL / Terraform — no visibility. In Terraform, the kinds already separate a module's inputs and outputs from what only its own files read.

A rename that also changes visibility counts as the wider of the two: a private method renamed and made public is a rename of public API. A rename of a public or protected declaration says so in its label — Public method renamed: Save → Store.

Languages and declarations

The settings list each language's kinds in three groups — types, members and locals:

LanguageTypesMembersLocals
C#Classes, Records, Structs, Interfaces, Enums, NamespacesMethods, Properties, Events, Fields, ConstantsLocal functions, Variables, Parameters
GoStructs, Interfaces, Defined types, Types declared elsewhereFunctions, Methods, Fields, Constants, Package variablesVariables, Parameters, Receivers
PythonClassesMethods, Functions, Fields, ConstantsVariables, Parameters
TypeScript, TSXClasses, Interfaces, Enums, Type aliases, NamespacesMethods, Functions, Properties, Constants, Module variablesVariables, Parameters
JavaScript, JSXClassesMethods, Functions, Properties, Constants, Module variablesVariables, Parameters
JavaClasses, Interfaces, Enums, RecordsMethods, Fields, ConstantsVariables, Parameters
KotlinClasses, Interfaces, Enums, Objects, Type aliases, Types declared elsewhereMethods, Functions, Properties, Constants, Top-level propertiesVariables, Parameters
RustStructs, Enums, Unions, Traits, Type aliases, Modules, Types declared elsewhereMethods, Functions, Fields, Constants, StaticsVariables, Parameters
CStructs, Unions, Enums, Type aliasesFunctions, Fields, Constants, Global variablesVariables, Parameters
C++Classes, Structs, Unions, Enums, Type aliases, Namespaces, Types declared elsewhereMethods, Functions, Fields, Constants, Global variablesVariables, Parameters
PHPClasses, Interfaces, Traits, Enums, NamespacesMethods, Functions, Properties, ConstantsVariables, Parameters
RubyClasses, ModulesMethods, Functions, ConstantsVariables, Parameters
SwiftClasses, Structs, Enums, Actors, Protocols, Type aliases, Types declared elsewhereMethods, Functions, Properties, Constants, Global variablesVariables, Parameters
ScalaClasses, Traits, Objects, Enums, Type aliases, Types declared elsewhereMethods, Functions, FieldsVariables, Parameters
DartClasses, Mixins, Enums, Type aliases, Types declared elsewhereMethods, Functions, Properties, Fields, Constants, Top-level variablesVariables, Parameters
LuaMethods, FunctionsVariables, Parameters
GDScriptClasses, EnumsMethods, Fields, ConstantsVariables, Parameters
HCL / TerraformInput variables, Local values, Outputs, Module calls

A constant is one in its language's own word: a const of a C# or C++ type or file, a Java static final field and every field of an interface, a Kotlin const val, a Dart const or static const, a Swift top-level let or static let, a Rust const (in an impl or a trait too), a TypeScript or JavaScript module's const, a PHP class or namespace const, a GDScript const, a Ruby constant, and a Python name in UPPER_CASE at a module's or a class's level. The members of an enum are not constants. A global variable — Package variables in Go, Statics in Rust, Module variables in TypeScript and JavaScript, Top-level properties in Kotlin, Top-level variables in Dart — is a variable declared at the top level of a file, outside every function and type. A TypeScript or JavaScript module's const holding a function, const save = () => …, is a function.

What counts as part of a rename depends on how much of the code the language lets Mantish resolve. In C#, every use the compiler resolves is part of it. In the other languages:

  • every use of a renamed local or parameter is;
  • so is every use of a renamed field or property inside the type that declares it — through this / self, and in Java, Kotlin, Swift, Scala, C++, Dart and GDScript also by its bare name wherever no local, parameter or import of the same name stands in the way;
  • and every use of a renamed type, method, function, field, property, constant or global variable in the same file that symbol navigation resolves to it beyond doubt — other.total through a value whose type it knows, a JSX tag naming a renamed component, a component's attribute or a {props.total} naming a renamed prop, a C or C++ designated initializer { .total = 1 }.

Code inside a JSX {…} counts like any other code: a local renamed with its uses in JSX expressions is a rename. A getter and a setter are each renamed on their own — a Dart accessor is a property, a Ruby def total= or attr_accessor :total a method — and a compound assignment such as total += 1 is part of the rename once both accessors carry the new name.

A comment that only follows a rename is part of it: one that says what it said, the old name before and the new one after — // Save writes the document. above a method renamed Persist, written again as // Persist writes the document. — is muted, hidden or spotlighted with the rename. A comment rewritten on the way stays visible.

A file can also rename a type it does not declare: a C++ .cpp that defines Store::close() outside the class, a Go file holding methods of a type declared elsewhere in the package, a Rust impl Store, a Swift, Kotlin, Dart or Scala extension. Renaming Store to Repo there is a Types declared elsewhere rename (Type renamed: Store → Repo) — but only when every use of the old name in the file, two at least, became the new one. Read from that one file, a type renamed and members moved onto another type look the same, so a file naming the type once stays visible.

In a pull request, and in a comparison of your repository, a file that only uses a type or a member another of its files renamed — IOrderService → IOrderHandler in thirty controllers — follows the same rule as the declaration: muted, hidden or spotlighted by its language and kind, with the same visibility scope, and labelled with the file that declares it (Public interface renamed in IOrderHandler.cs: IOrderService → IOrderHandler). A use counts only when the file replaced the old name everywhere in its code and never used the new one before, and only in code — never in a string or a comment. Locals, parameters and private declarations are never used from another file. Cascade still covers only the file that declares the rename. mantish diff and mantish pr diff judge what they export the same way, with the renames of every file of the comparison — also when you export only some of its files.

Any other use stays visible as a change of its own. Hover a kind in the settings to see exactly what it covers.

Some edits are never a rename, because the new name can change what the code does. A method or accessor of an object literal in TypeScript or JavaScript is a key that whatever holds the object reads by name — a Vue component's created(), a config object — so its rename always stays visible. In Rust, a function holding a macro that may turn a name into text — assert!, dbg!, stringify!, a crate's own macro — is not read for renamed locals; the standard macros that read their arguments as code (println!, format!, write!, vec!, matches!, assert_eq! and their kin) do not stop a rename.

The script of a Vue component follows the rules of the language it is written in — TypeScript or JavaScript — and a .h header written in C++ follows C++'s rules. In Terraform, a renamed variable, local value or module call covers its var., local. and module. references in the same file.

Set up a rule

AppWhere
Desktop appRenames in Settings › Auto-mute tags (show, mute or hide) and Settings › Spotlight tags
JetBrainsIn development
Terminal:settings › Auto-mute · Rename and Spotlight · Rename

In the desktop app, pick the language from Add a language…, then give each kind its state — or a group its state, to set every kind in it. Clicking a kind's name steps it through the states. A muted, hidden or spotlighted kind that has a visibility shows Public too under Auto-mute and Public only under Spotlight. A language whose kinds are all back on Show leaves the list once you pick another.

In the terminal, i chooses a language to add (type part of its name, ← / → pick among the matches, ↵ shows it), [ and ] move between languages, space steps the kind under the cursor through its states (on a group's heading, the whole group), ← / → (h / l) set a muted, hidden or spotlighted kind's visibility — not public or public too, any visibility or public only — and d removes the language shown.

Rename rules are saved as you change them, in every app.

Was this page helpful?