[include-fixer] A refactoring of IncludeFixerContext.
Summary:
No functional changes in this patch. It is a refactoring (pull out a
structure representing the symbol being queried).
This is a preparing step for inserting missing namespace qualifiers to all
instances of an unidentified symbol.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D22510
llvm-svn: 275980
diff --git a/clang-tools-extra/include-fixer/tool/clang-include-fixer.py b/clang-tools-extra/include-fixer/tool/clang-include-fixer.py
index ff15b8d..eb02565 100644
--- a/clang-tools-extra/include-fixer/tool/clang-include-fixer.py
+++ b/clang-tools-extra/include-fixer/tool/clang-include-fixer.py
@@ -127,7 +127,8 @@
return
include_fixer_context = json.loads(stdout)
- symbol = include_fixer_context["SymbolIdentifier"]
+ query_symbol_info = include_fixer_context["QuerySymbolInfo"]
+ symbol = query_symbol_info["RawIdentifier"]
# The header_infos is already sorted by include-fixer.
header_infos = include_fixer_context["HeaderInfos"]
# Deduplicate headers while keeping the order, so that the same header would
@@ -151,8 +152,7 @@
try:
# If there is only one suggested header, insert it directly.
if len(unique_headers) == 1 or maximum_suggested_headers == 1:
- InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
+ InsertHeaderToVimBuffer({"QuerySymbolInfo": query_symbol_info,
"HeaderInfos": header_infos}, text)
print "Added #include {0} for {1}.".format(unique_headers[0], symbol)
return
@@ -163,8 +163,7 @@
header for header in header_infos if header["Header"] == selected]
# Insert a selected header.
- InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
+ InsertHeaderToVimBuffer({"QuerySymbolInfo": query_symbol_info,
"HeaderInfos": selected_header_infos}, text)
print "Added #include {0} for {1}.".format(selected, symbol)
except Exception as error: