OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Changes Blink-style names to Chrome-style names. Currently transforms: | 5 // Changes Blink-style names to Chrome-style names. Currently transforms: |
6 // fields: | 6 // fields: |
7 // int m_operationCount => int operation_count_ | 7 // int m_operationCount => int operation_count_ |
8 // variables (including parameters): | 8 // variables (including parameters): |
9 // int mySuperVariable => int my_super_variable | 9 // int mySuperVariable => int my_super_variable |
10 // constants: | 10 // constants: |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 // override from a given base class. Instead, the rewriter uses two matchers: | 425 // override from a given base class. Instead, the rewriter uses two matchers: |
426 // one that matches all method declarations in the Blink namespace, and | 426 // one that matches all method declarations in the Blink namespace, and |
427 // another which matches all overridden methods not in the Blink namespace. | 427 // another which matches all overridden methods not in the Blink namespace. |
428 // The second list is filtered against the first list to determine which | 428 // The second list is filtered against the first list to determine which |
429 // methods are inherited from Blink classes and need to be rewritten. | 429 // methods are inherited from Blink classes and need to be rewritten. |
430 auto blink_method_decl_matcher = | 430 auto blink_method_decl_matcher = |
431 id("decl", cxxMethodDecl(unless(anyOf( | 431 id("decl", cxxMethodDecl(unless(anyOf( |
432 // Overloaded operators have special names | 432 // Overloaded operators have special names |
433 // and should never be renamed. | 433 // and should never be renamed. |
434 isOverloadedOperator(), | 434 isOverloadedOperator(), |
435 // Similarly, constructors and destructors | 435 // Similarly, constructors, destructors, and |
436 // should not be considered for renaming. | 436 // conversion functions should not be |
437 cxxConstructorDecl(), cxxDestructorDecl())), | 437 // considered for renaming. |
| 438 cxxConstructorDecl(), cxxDestructorDecl(), |
| 439 cxxConversionDecl())), |
438 in_blink_namespace)); | 440 in_blink_namespace)); |
439 // Note that the matcher for overridden methods doesn't need to filter for | 441 // Note that the matcher for overridden methods doesn't need to filter for |
440 // special member functions: see implementation of FunctionDeclRewriter for | 442 // special member functions: see implementation of FunctionDeclRewriter for |
441 // the full explanation. | 443 // the full explanation. |
442 auto non_blink_overridden_method_decl_matcher = | 444 auto non_blink_overridden_method_decl_matcher = |
443 id("decl", cxxMethodDecl(isOverride(), unless(in_blink_namespace))); | 445 id("decl", cxxMethodDecl(isOverride(), unless(in_blink_namespace))); |
444 MethodDeclRewriter method_decl_rewriter(&replacements); | 446 MethodDeclRewriter method_decl_rewriter(&replacements); |
445 match_finder.addMatcher(blink_method_decl_matcher, &method_decl_rewriter); | 447 match_finder.addMatcher(blink_method_decl_matcher, &method_decl_rewriter); |
446 match_finder.addMatcher(non_blink_overridden_method_decl_matcher, | 448 match_finder.addMatcher(non_blink_overridden_method_decl_matcher, |
447 &method_decl_rewriter); | 449 &method_decl_rewriter); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 for (const auto& r : replacements) { | 520 for (const auto& r : replacements) { |
519 std::string replacement_text = r.getReplacementText().str(); | 521 std::string replacement_text = r.getReplacementText().str(); |
520 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 522 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
521 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 523 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
522 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 524 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
523 } | 525 } |
524 llvm::outs() << "==== END EDITS ====\n"; | 526 llvm::outs() << "==== END EDITS ====\n"; |
525 | 527 |
526 return 0; | 528 return 0; |
527 } | 529 } |
OLD | NEW |