This is an archive of the discontinued LLVM Phabricator instance.

[tooling] FixItHint Tooling refactoring
ClosedPublic

Authored by etienneb on May 4 2016, 3:45 PM.

Diff Detail

Event Timeline

etienneb updated this revision to Diff 56214.May 4 2016, 3:45 PM
etienneb retitled this revision from to [draft] FixItHint Tooling refactoring.
etienneb updated this object.
etienneb added reviewers: alexfh, klimek.

If this is what you wanted Alex, I'll pursue writing unittests/docs and making a complete patch to land.

See some example on how to use it:
http://reviews.llvm.org/D19807

alexfh edited edge metadata.May 10 2016, 7:00 AM

If this is what you wanted Alex, I'll pursue writing unittests/docs and making a complete patch to land.

See some example on how to use it:
http://reviews.llvm.org/D19807

Yes, this looks reasonable.

include/clang/Tooling/Fixit.h
2

nit: Should be FixIt (note the capital I).

36

Do we want to expose getSourceRange as an API? If no, it should also be in the namespace internal.

56

I wonder whether we should later extend this to remove comments attached to nodes like Stmt and FunctionDecl? It's out of this patches scope, but maybe add a FIXME to sketch the further development plans.

alexfh edited edge metadata.May 10 2016, 7:00 AM
alexfh edited subscribers, added: cfe-commits; removed: klimek.
etienneb retitled this revision from [draft] FixItHint Tooling refactoring to [clang-tidy] FixItHint Tooling refactoring.May 10 2016, 8:56 AM
etienneb updated this revision to Diff 56781.May 10 2016, 12:32 PM
etienneb marked 3 inline comments as done.

add unittests

etienneb retitled this revision from [clang-tidy] FixItHint Tooling refactoring to [tooling] FixItHint Tooling refactoring.May 10 2016, 12:32 PM
etienneb updated this revision to Diff 56790.May 10 2016, 1:11 PM

more unittests

alexfh added inline comments.May 10 2016, 1:41 PM
include/clang/Tooling/Fixit.h
2

nit: s/FixIt Hint/FixItHint/, since this is a reference to the type.

lib/Tooling/CMakeLists.txt
10

Please rename the files as well (s/Fixit/FixIt/).

unittests/Tooling/CMakeLists.txt
15

s/FixitTest/FixItTest/

unittests/Tooling/FixitTest.cpp
35

Automatic captures always seem suspicious to me. What exactly does this lambda need to capture? If just this, I'd rather make the capture list explicit.

54

Could you add a test where getText returns an empty string?

120

One character range is boring. Can you make the parameter longer and also verify whether the range is a token range or a character range?

etienneb updated this revision to Diff 56825.May 10 2016, 3:17 PM
etienneb marked 5 inline comments as done.

address alexfh comments

alexfh accepted this revision.May 11 2016, 1:26 AM
alexfh edited edge metadata.

LG. Thanks!

unittests/Tooling/FixItTest.cpp
37 ↗(On Diff #56826)

Let's either put the tests in the clang::tooling::<anonymous> namespace (not common for unit tests in this specific directory, but nevertheless reasonable, imo) or add using declarations for tooling::fixit::getText and other tested functions to reduce the amount of boilerplate.

This revision is now accepted and ready to land.May 11 2016, 1:26 AM
etienneb updated this revision to Diff 56907.May 11 2016, 7:06 AM
etienneb marked an inline comment as done.
etienneb edited edge metadata.

fix nits

I added the "using statements".
landing.

include/clang/Tooling/Fixit.h
36

Good question.
I moved it into the internal namespace.

If it's become needed, we can re-expose it.

56

I like the idea. I didn't think about comments and other syntactical elements that may be related to a Node.
But, I believe we will have a other set of functions for Node and comments.

An other concept that I believe it's missing is to provide helper to append expression (operators) and stay semantically correct with operator precedence. Some cases needed to add parentheses.

unittests/Tooling/FixitTest.cpp
54

see line 68, already there!

120

In this case, it's not one character... it's one token.
As it's a "token range", the whole token is used.

But, I can use an expression too.
Not a bad idea: added but in 'createRemoval'

There is already a reand at line 138:

EXPECT_EQ("input.cc:2:26 <Spelling=input.cc:1:37>",
EXPECT_EQ("input.cc:2:26 <Spelling=input.cc:1:45>",
etienneb closed this revision.May 11 2016, 7:37 AM