Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] getting preprocessed tokens for an AST node

> In a situation like this is it possible to explore the area between the  
> images of 'a' and 'b' and extract '==' from there? 

I started trying to implement a solution along these lines, and in the process I made a realization: that the offset and length stored in ASTNode are measured not in characters, but in tokens. 

Since these are the quantities I'm trying to compute in CPPASTImplicitName.computeOperatorOffsets(), this gives rise to a fairly straightforward solution: figure out the offsets bounding the leading/trailing syntax, the way getLeadingSyntax()/getTrailingSyntax() would (this is not the part of the operations that can throw an ExpansionOverlapsBoundaryException); if the resulting range has size 1, that token must be the operator token, and so we know what offset we need to assign the operator node.

getImageLocation() (which is called later, by the semantic highlighting reconciler) then figures out the correct image location based on this offset, like it does for other nodes.

Thanks for the suggestion.

Regards,
Nate
 		 	   		  

Back to the top