Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: tools/vim/chromium.ycm_extra_conf.py

Issue 368313003: Improve YouCompleteMe handling of Blink header without source files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: os.path.join Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/vim/chromium.ycm_extra_conf.py
diff --git a/tools/vim/chromium.ycm_extra_conf.py b/tools/vim/chromium.ycm_extra_conf.py
index 0f3daf131b1f8dc3c1da6f87ee30852919dfcf10..71863115871ef2288cc612705101b9f42af5c61e 100644
--- a/tools/vim/chromium.ycm_extra_conf.py
+++ b/tools/vim/chromium.ycm_extra_conf.py
@@ -130,9 +130,19 @@ def GetClangCommandFromNinjaForFilename(chrome_root, filename):
# Chromium's includes are relative to that.
chrome_flags = ['-I' + os.path.join(chrome_root)]
+ # Default file to get a reasonable approximation of the flags for a Blink
+ # file.
+ blink_root = os.path.join(chrome_root, 'third_party', 'WebKit')
+ default_blink_file = os.path.join(blink_root, 'Source', 'core', 'Init.cpp')
+
# Header files can't be built. Instead, try to match a header file to its
# corresponding source file.
if filename.endswith('.h'):
+ # Add config.h to Blink headers, which won't have it by default.
+ if filename.startswith(blink_root):
+ chrome_flags.append('-include')
+ chrome_flags.append(os.path.join(blink_root, 'Source', 'config.h'))
+
alternates = ['.cc', '.cpp']
for alt_extension in alternates:
alt_name = filename[:-2] + alt_extension
@@ -140,9 +150,14 @@ def GetClangCommandFromNinjaForFilename(chrome_root, filename):
filename = alt_name
break
else:
- # If this is a standalone .h file with no source, the best we can do is
- # try to use the default flags.
- return chrome_flags
+ if filename.startswith(blink_root):
+ # If this is a Blink file, we can at least try to get a reasonable
+ # approximation.
+ filename = default_blink_file
+ else:
+ # If this is a standalone .h file with no source, the best we can do is
+ # try to use the default flags.
+ return chrome_flags
# Ninja needs the path to the source file from the output build directory.
# Cut off the common part and /.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698