Skip to main content

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

Agree. I posted a patch to add newName(String) to ICPPNodeFactory: https://git.eclipse.org/r/78363


Regards,

Nate


From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Kenneth MacKenzie <kwxm@xxxxxxxxxxxx>
Sent: August 2, 2016 2:44:25 PM
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Minor problem with ICPPNodeFactory
 
Hi,

I've encountered a minor problem with the CDT ICPPNodeFactory
interface.

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));
      qname.addName(basicName);
      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,

Kenneth


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

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev

Back to the top