Skip to main content

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

You may take a look at org.eclipse.cdt.internal.core.dom.rewrite.util.ASTNodes.

On Thu, Jan 19, 2017 at 3:50 PM, Jeff Johnston <jjohnstn@xxxxxxxxxx> wrote:

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.
cdt-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top