private static boolean appendName(PbRef ref, StringBuilder builder) {
   String refName = ref.getReferenceName();
   if (refName == null) {
     return false;
   }
   PbRef qualifier = (PbRef) ref.getQualifier();
   if (qualifier != null) {
     appendName(qualifier, builder);
     builder.append(".");
   }
   builder.append(refName);
   return true;
 }
 public static PsiElement getTypeScope(final PsiElement element) {
   if (element instanceof PbFieldDef) {
     PbRef typeRef = ((PbFieldDef) element).getTypeRef();
     if (typeRef != null) {
       PsiElement resolvedElement = typeRef.resolve();
       if (resolvedElement != null) {
         return getScope(resolvedElement);
       }
     }
     return null;
   }
   if (element instanceof PbGroupDef) {
     return ((PbGroupDef) element).getBlock();
   }
   if (element instanceof PbExtendDef) {
     return ((PbExtendDef) element).getBlock();
   }
   assert false;
   return null;
 }