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

Unified Diff: tools/json_schema_compiler/schema_loader.py

Issue 515983003: Fixing json compiler preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 6 years, 4 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 | « tools/json_schema_compiler/preview.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/schema_loader.py
diff --git a/tools/json_schema_compiler/schema_loader.py b/tools/json_schema_compiler/schema_loader.py
index 261e8d0a72a5bd5c784118ed7e79e96bce5d6bf0..b8969910c6b693a6eed4c2da1e07f01d73b84997 100644
--- a/tools/json_schema_compiler/schema_loader.py
+++ b/tools/json_schema_compiler/schema_loader.py
@@ -51,6 +51,18 @@ class SchemaLoader(object):
self._include_rules = [(path, cpp_namespace_pattern)]
self._include_rules.extend(include_rules)
+ def ResolveNamespace(self, full_namespace):
+ filenames = GenerateFilenames(full_namespace)
+ for path, cpp_namespace in self._include_rules:
+ for filename in reversed(filenames):
+ filepath = os.path.join(path, filename);
+ if os.path.exists(os.path.join(self._root, filepath)):
+ return Model().AddNamespace(
+ self.LoadSchema(filepath)[0],
+ filepath,
+ environment=CppNamespaceEnvironment(cpp_namespace))
+ return None
+
def ResolveType(self, full_name, default_namespace):
name_parts = full_name.rsplit('.', 1)
if len(name_parts) == 1:
@@ -58,17 +70,9 @@ class SchemaLoader(object):
return None
return default_namespace
full_namespace, type_name = full_name.rsplit('.', 1)
- filenames = GenerateFilenames(full_namespace)
- for path, namespace in self._include_rules:
- for filename in reversed(filenames):
- filepath = os.path.join(path, filename);
- if os.path.exists(os.path.join(self._root, filepath)):
- namespace = Model().AddNamespace(
- self.LoadSchema(filepath)[0],
- filepath,
- environment=CppNamespaceEnvironment(namespace))
- if type_name in namespace.types:
- return namespace
+ namespace = self.ResolveNamespace(full_namespace)
+ if namespace and type_name in namespace.types:
+ return namespace
return None
def LoadSchema(self, schema):
« no previous file with comments | « tools/json_schema_compiler/preview.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698