Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] How to find end of previous line using AST

Hi,

I am trying to implement a quick-fix resolution for missing semi-colon.  Unfortunately,
gcc reports the problem as a semi-colon is needed to be inserted for the next line.

For example,

int a(int x) {
  int y = 2*x /* double input */
  return y;
}

gcc reports a semi-colon is expected before 'return'.

I would like to use the AST to find the location of the ')' in the document (i.e. the
last character in the previous line that is not part of a comment).  My attempts thus far haven't worked to
go backwards from the reported position as I can't find any ASTNode for the 'return' to work back from
(I keep getting back null from the interfaces I tried: getASTNameFromProblemMarker() being one of them).

Any suggestions on how to do this?

-- Jeff J. 


Back to the top