public IASTDeclaration getPrimaryDeclaration() {
    // first check if we already know it
    if (declarations != null) {
      for (IASTDeclarator dtor : declarations) {
        if (dtor == null) {
          break;
        }
        dtor = ASTQueries.findOutermostDeclarator(dtor);
        IASTDeclaration decl = (IASTDeclaration) dtor.getParent();
        if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier) return decl;
      }
    }
    if (definition != null) {
      IASTDeclarator dtor = ASTQueries.findOutermostDeclarator(definition);
      IASTDeclaration decl = (IASTDeclaration) dtor.getParent();
      if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier) return decl;
    }

    final char[] myName = getASTName().getLookupKey();
    ICPPClassScope scope = (ICPPClassScope) getScope();
    ICPPASTCompositeTypeSpecifier compSpec =
        (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
    if (compSpec != null) {
      IASTDeclaration[] members = compSpec.getMembers();
      for (IASTDeclaration member : members) {
        if (member instanceof IASTSimpleDeclaration) {
          IASTDeclarator[] dtors = ((IASTSimpleDeclaration) member).getDeclarators();
          for (IASTDeclarator dtor : dtors) {
            IASTName name = ASTQueries.findInnermostDeclarator(dtor).getName();
            if (CharArrayUtils.equals(name.getLookupKey(), myName)
                && name.resolveBinding() == this) {
              return member;
            }
          }
        } else if (member instanceof IASTFunctionDefinition) {
          final IASTFunctionDeclarator declarator =
              ((IASTFunctionDefinition) member).getDeclarator();
          IASTName name = ASTQueries.findInnermostDeclarator(declarator).getName();
          if (CharArrayUtils.equals(name.getLookupKey(), myName) && name.resolveBinding() == this) {
            return member;
          }
        }
      }
    }
    return null;
  }
 @Override
 protected IASTName getASTName() {
   IASTDeclarator dtor =
       (declarations != null && declarations.length > 0) ? declarations[0] : definition;
   dtor = ASTQueries.findInnermostDeclarator(dtor);
   IASTName name = dtor.getName();
   if (name instanceof ICPPASTQualifiedName) {
     IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
     name = ns[ns.length - 1];
   }
   return name;
 }