Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Minor problem with ICPPNodeFactory


I've encountered a minor problem with the CDT ICPPNodeFactory

Consider the following method, which generates a qualified or
unqualified name depending on the flag 'qualify':

  public static final ICPPASTName makeName (ICPPNodeFactory nf, String s, boolean qualify) {
    ICPPASTName basicName = nf.newName(s.toCharArray());
    if (qualify) {
      ICPPASTQualifiedName qname = nf.newQualifiedName(nf.newName("std".toCharArray));
      return qname;
    } else {
      return basicName;

This works correctly, but it's a little annoying to have to write
nd.newName(s.toCharArray). However, if you replace it with
nf.newName(s) then it's impossible to get the method to compile
without adding casts or changing the return type to IASTName.  I think
the problem is that newName(String) is defined in the class
CPPNodeFactory, but not declared in the interface ICPPNodeFactory.
Instead, ICPPNodeFactory inherits newName(String) from
IASTNodeFactory, and the signature of this method says that it returns
an IASTName.  Presumably this problem could be solved by adding
newName(String) to ICPPNodeFactory.

Best wishes,


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Back to the top