Commit 1c2670c8 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

IDLCompiler: Fix behavior issues with Union

- Union.components was empty if no member types are user defined.
- Union.debug_info._location were not set
- Fix behavior of PathManager with Union
- Fix Location constructor with None filepath


Bug: 839389
Change-Id: Id115f6fd26b387ba6bc594a74f907ca0738b78f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1990887Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730083}
parent 7539399a
......@@ -76,10 +76,14 @@ class PathManager(object):
def __init__(self, idl_definition):
assert self._is_initialized, self._REQUIRE_INIT_MESSAGE
idl_path = PathManager.relpath_to_project_root(
posixpath.normpath(idl_definition.debug_info.location.filepath))
idl_basepath, _ = posixpath.splitext(idl_path)
self._idl_dir, self._idl_basename = posixpath.split(idl_basepath)
if isinstance(idl_definition, web_idl.Dictionary):
idl_path = PathManager.relpath_to_project_root(
posixpath.normpath(
idl_definition.debug_info.location.filepath))
idl_basepath, _ = posixpath.splitext(idl_path)
self._idl_dir, _ = posixpath.split(idl_basepath)
else:
self._idl_dir = None
components = sorted(idl_definition.components) # "core" < "modules"
......@@ -101,25 +105,9 @@ class PathManager(object):
self._impl_dir = self._component_reldirs[self._impl_component]
self._v8_bind_basename = name_style.file("v8",
idl_definition.identifier)
self._blink_dir = self._idl_dir
self._blink_basename = name_style.file(
blink_class_name(idl_definition))
@property
def idl_dir(self):
return self._idl_dir
def blink_path(self, filename=None, ext=None):
"""
Returns a path to a Blink implementation file relative to the project
root directory, e.g. "third_party/blink/renderer/..."
"""
return self._join(
dirpath=self._blink_dir,
filename=(filename or self._blink_basename),
ext=ext)
@property
def is_cross_components(self):
return self._is_cross_components
......@@ -154,7 +142,11 @@ class PathManager(object):
# TODO(crbug.com/1034398): Remove this API
def dict_path(self, filename=None, ext=None):
return self.blink_path(filename, ext)
assert self._idl_dir is not None
return self._join(
dirpath=self._idl_dir,
filename=(filename or self._blink_basename),
ext=ext)
@staticmethod
def _join(dirpath, filename, ext=None):
......
......@@ -151,9 +151,11 @@ class Location(object):
# idl_parser produces paths based on the working directory, which may
# not be the project root directory, e.g. "../../third_party/blink/...".
# Canonicalize the paths heuristically.
index = filepath.find(self._blink_path_prefix)
if index >= 0:
filepath = filepath[index + 1:]
if filepath is not None:
index = filepath.find(self._blink_path_prefix)
if index >= 0:
filepath = filepath[index + 1:]
self._filepath = filepath
self._line_number = line_number
self._position = position # Position number in a file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment