tools/vim/chromium.ycm_extra_conf.py
def GetClangOptionsFromNinjaForFilename(chrome_root, filename):
  """Returns the Clang command line options needed for building |filename|.

  Command line options are based on the command used by ninja for building
  |filename|. If |filename| is a .h file, uses its companion .cc or .cpp file.
  If a suitable companion file can't be located or if ninja doesn't know about
  |filename|, then uses default source files in Blink and Chromium for
  determining the commandline.

  Args:
    chrome_root: (String) Path to src/.
    filename: (String) Absolute path to source file being edited.

  Returns:
    (List of Strings) The list of command line flags for this source file. Can
    be empty.
  """
  if not chrome_root:
    return []

  # Generally, everyone benefits from including Chromium's src/, because all of
  # Chromium's includes are relative to that.
  additional_flags = ['-I' + os.path.join(chrome_root)]

  # Version of Clang used to compile Chromium can be newer then version of
  # libclang that YCM uses for completion. So it's possible that YCM's libclang
  # doesn't know about some used warning options, which causes compilation
  # warnings (and errors, because of '-Werror');
  additional_flags.append('-Wno-unknown-warning-option')

  sys.path.append(os.path.join(chrome_root, 'tools', 'vim'))
  from ninja_output import GetNinjaOutputDirectory
  out_dir = GetNinjaOutputDirectory(chrome_root)

  basename, extension = os.path.splitext(filename)
  if extension == '.h':
    candidates = [basename + ext for ext in _header_alternates]
  else:
    candidates = [filename]

  clang_line = None
  buildable_extension = extension
  for candidate in candidates:
    clang_line = GetClangCommandLineFromNinjaForSource(out_dir, candidate)
    if clang_line:
      buildable_extension = os.path.splitext(candidate)[1]
      break

  additional_flags += _extension_flags.get(buildable_extension, [])

  if not clang_line:
    # If ninja didn't know about filename or it's companion files, then try a
    # default build target. It is possible that the file is new, or build.ninja
    # is stale.
    clang_line = GetClangCommandLineFromNinjaForSource(out_dir,
                                                       GetDefaultSourceFile(
                                                           chrome_root,
                                                           filename))

  if not clang_line:
    return additional_flags

  return GetClangOptionsFromCommandLine(clang_line, out_dir, additional_flags)
Returns the Clang command line options needed for building |filename|.

  Command line options are based on the command used by ninja for building
  |filename|. If |filename| is a .h file, uses its companion .cc or .cpp file.
  If a suitable companion file can't be located or if ninja doesn't know about
  |filename|, then uses default source files in Blink and Chromium for
  determining the commandline.

  Args:
    chrome_root: (String) Path to src/.
    filename: (String) Absolute path to source file being edited.

  Returns:
    (List of Strings) The list of command line flags for this source file. Can
    be empty.
  
Returns the Clang command line options needed for building |filename|.
Command line options are based on the command used by ninja for building
|filename|. If |filename| is a .h file, uses its companion .cc or .cpp file.
If a suitable companion file can't be located or if ninja doesn't know about
|filename|, then uses default source files in Blink and Chromium for
determining the commandline.
Returns the Clang command line options needed for building |filename| . Command line options are based on the command used by ninja for building |filename| . If |filename| is a . h file uses its companion . cc or . cpp file . If a suitable companion file can ' t be located or if ninja doesn ' t know about |filename| then uses default source files in Blink and Chromium for determining the commandline .
def GetClangOptionsFromNinjaForFilename(chrome_root, filename):
  if not chrome_root:
    return []
  additional_flags = ['-I' + os.path.join(chrome_root)]
  additional_flags.append('-Wno-unknown-warning-option')
  sys.path.append(os.path.join(chrome_root, 'tools', 'vim'))
  from ninja_output import GetNinjaOutputDirectory
  out_dir = GetNinjaOutputDirectory(chrome_root)
  basename, extension = os.path.splitext(filename)
  if extension == '.h':
    candidates = [basename + ext for ext in _header_alternates]
  else:
    candidates = [filename]
  clang_line = None
  buildable_extension = extension
  for candidate in candidates:
    clang_line = GetClangCommandLineFromNinjaForSource(out_dir, candidate)
    if clang_line:
      buildable_extension = os.path.splitext(candidate)[1]
      break
  additional_flags += _extension_flags.get(buildable_extension, [])
  if not clang_line:
    clang_line = GetClangCommandLineFromNinjaForSource(out_dir,
                                                       GetDefaultSourceFile(
                                                           chrome_root,
                                                           filename))
  if not clang_line:
    return additional_flags
  return GetClangOptionsFromCommandLine(clang_line, out_dir, additional_flags)
def GetClangOptionsFromNinjaForFilename ( chrome_root , filename ) : if not chrome_root : return [ ] additional_flags = [ '-I' + os . path . join ( chrome_root ) ] additional_flags . append ( '-Wno-unknown-warning-option' ) sys . path . append ( os . path . join ( chrome_root , 'tools' , 'vim' ) ) from ninja_output import GetNinjaOutputDirectory out_dir = GetNinjaOutputDirectory ( chrome_root ) basename , extension = os . path . splitext ( filename ) if extension == '.h' : candidates = [ basename + ext for ext in _header_alternates ] else : candidates = [ filename ] clang_line = None buildable_extension = extension for candidate in candidates : clang_line = GetClangCommandLineFromNinjaForSource ( out_dir , candidate ) if clang_line : buildable_extension = os . path . splitext ( candidate ) [ 1 ] break additional_flags += _extension_flags . get ( buildable_extension , [ ] ) if not clang_line : clang_line = GetClangCommandLineFromNinjaForSource ( out_dir , GetDefaultSourceFile ( chrome_root , filename ) ) if not clang_line : return additional_flags return GetClangOptionsFromCommandLine ( clang_line , out_dir , additional_flags )
Returns the Clang command line options needed for building |filename|.
Returns the Clang command line options needed for building |filename| .
"""Returns the Clang command line options needed for building |filename|.

  Command line options are based on the command used by ninja for building
  |filename|. If |filename| is a .h file, uses its companion .cc or .cpp file.
  If a suitable companion file can't be located or if ninja doesn't know about
  |filename|, then uses default source files in Blink and Chromium for
  determining the commandline.

  Args:
    chrome_root: (String) Path to src/.
    filename: (String) Absolute path to source file being edited.

  Returns:
    (List of Strings) The list of command line flags for this source file. Can
    be empty.
  """ # Generally, everyone benefits from including Chromium's src/, because all of # Chromium's includes are relative to that. # Version of Clang used to compile Chromium can be newer then version of # libclang that YCM uses for completion. So it's possible that YCM's libclang # doesn't know about some used warning options, which causes compilation # warnings (and errors, because of '-Werror'); # If ninja didn't know about filename or it's companion files, then try a # default build target. It is possible that the file is new, or build.ninja # is stale.
(List of Strings) The list of command line flags for this source file. Can
be empty.
( List of Strings ) The list of command line flags for this source file . Can be empty .
chrome_root
(String) Path to src/.
( String ) Path to src / .
filename
(String) Absolute path to source file being edited.
( String ) Absolute path to source file being edited .