public V getLocalVariable() {
   if (myLocalVariable != null && myLocalVariable.isValid()) {
     return myLocalVariable;
   }
   if (myLocalMarker != null) {
     V variable = getVariable();
     PsiFile containingFile;
     if (variable != null) {
       containingFile = variable.getContainingFile();
     } else {
       containingFile =
           PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
     }
     PsiNameIdentifierOwner identifierOwner =
         PsiTreeUtil.getParentOfType(
             containingFile.findElementAt(myLocalMarker.getStartOffset()),
             PsiNameIdentifierOwner.class,
             false);
     return identifierOwner != null && identifierOwner.getClass() == myLocalVariable.getClass()
         ? (V) identifierOwner
         : null;
   }
   return myLocalVariable;
 }
 protected void deleteTemplateField(V psiField) {
   if (psiField.isValid()) {
     psiField.delete();
   }
 }