Try this Structural Search template:
$This$.getClass()
Edit variables -> This -> Text/regexp: this, minimum count: 0, maximum count: 1
Replacement Template
$Clazz$.class
Edit variables -> Clazz -> Script text:
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.PsiClass;
PsiTreeUtil.getParentOfType(__context__, PsiClass.class).getQualifiedName();
UPD:
JetBrains support:
This is currently not supported in the new Structural Search & Replace (SSR) dialog. It is possible to do this by going back to the old UI, here's how:
- Invoke Help | Find Action... (Ctrl/Cmd+Shift+A)
- Type Registry and invoke the Registry... action
- Remove the check mark for the ssr.use.new.search.dialog key and close the dialog
Now when you invoke SSR, you're back to the old dialog and can use replacement variables again. Restoring replacement variables for the new SSR dialog is planned for version 2019.2, but no guarantee.