Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] IName vs IASTName in CDT 4.0

Hi Beth,
the purpose of IName is to bridge between names from the ast (IASTName)
and
the ones from the index (IIndexName). In CDT 3.1 the names would
implement
IASTName without fullfilling the API contract.

The method ITranslationUnit.getDeclarations(IBinding) may return names
from
the index depending on how you have generated the AST. In case you do a
full
parse (headers are not pulled in from the index) all of the names will
be
IASTNames, you could cast them.

There is a new method ITranslationUnit.getDeclarationsInAST(IBinding)
that
returns the IASTNames, only and thus saves you from casting.

IName will most likely become an API with CDT 4.0 M6. In case the IName 
interface does not support functionality you depend on, its best to
request
it. 

Markus.

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Beth Tibbitts
Sent: Donnerstag, 07. Dezember 2006 02:39
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] IName vs IASTName in CDT 4.0


We're converting our PTP analysis code to CDT 4.0

I have an expression  that formerly returned IASTName[] but now seems to
return IName[].

IASTName[] decls =
funcName.getTranslationUnit().getDeclarations(binding);
Gives: - Type mismatch: cannot convert from IName[] to IASTName[]

IName has this scary :-) description about not using it since it's
EXPERIMENTAL.
Aha. Now I see Markus' name in there.
Any advice, Markus?
Can you, or anyone, suggest what we should do, or suggest a workaround
for
now?.


How does IName relate to IASTName and can I translate between them?

I'm using this to determine if a function i find in the source file is
declared in a particular include path,
and thus is an "artifact" that I want to place a marker upon.

More complete context of how I'm using it follows:
      /**
       * Determines if the funcName is an instance of the type of
artifact
in
       * which we are interested. <br>
       * That is, is, it, declared in the include path?
       *
       * @param funcName
       */
      protected boolean isArtifact(IASTName funcName) {
            IBinding binding = funcName.resolveBinding();
      ==>   IASTName[] decls = funcName.getTranslationUnit
().getDeclarations(binding);

            for> (int> i = 0; i < decls.length;; ++i) {
                  IASTFileLocation loc = decls[i].getFileLocation();.
                  String filename = loc.getFileName();
                  System.out.println(."PldtAstVisitor found filename " +
filename);
                  IPath path = new Path(filename);
                  // is this path valid?
                  if (isInIncludePath(path))
                        return true;
            }
            return false;
      }

...Beth
High Productivity Tools / Parallel Tools  http://eclipse.org/ptp
T.J.Watson Research Center
Lexington, KY 40511

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top