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

Unified Diff: build/android/gyp/java_cpp_enum.py

Issue 2503763004: Fix comment preservation in java_cpp_enum.py. (Closed)
Patch Set: Create separate test for comment preservation w/prefix-stripping Created 4 years, 1 month 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 | build/android/gyp/java_cpp_enum_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/java_cpp_enum.py
diff --git a/build/android/gyp/java_cpp_enum.py b/build/android/gyp/java_cpp_enum.py
index 16da07f1cce566205a908a5c660eefe5a9390162..1b38316cc70e6d817c884faba386bbe6167b5a93 100755
--- a/build/android/gyp/java_cpp_enum.py
+++ b/build/android/gyp/java_cpp_enum.py
@@ -90,16 +90,20 @@ class EnumDefinition(object):
if not all([w.startswith(prefix_to_strip) for w in self.entries.keys()]):
prefix_to_strip = ''
- entries = collections.OrderedDict()
- for (k, v) in self.entries.iteritems():
- stripped_key = k.replace(prefix_to_strip, '', 1)
- if isinstance(v, basestring):
- stripped_value = v.replace(prefix_to_strip, '', 1)
- else:
- stripped_value = v
- entries[stripped_key] = stripped_value
+ def StripEntries(entries):
+ ret = collections.OrderedDict()
+ for (k, v) in entries.iteritems():
+ stripped_key = k.replace(prefix_to_strip, '', 1)
+ if isinstance(v, basestring):
+ stripped_value = v.replace(prefix_to_strip, '', 1)
+ else:
+ stripped_value = v
+ ret[stripped_key] = stripped_value
+
+ return ret
- self.entries = entries
+ self.entries = StripEntries(self.entries)
+ self.comments = StripEntries(self.comments)
class DirectiveSet(object):
class_name_override_key = 'CLASS_NAME_OVERRIDE'
@@ -208,9 +212,9 @@ class HeaderParser(object):
enum_value = enum_entry.groups()[2]
self._current_definition.AppendEntry(enum_key, enum_value)
if self._current_comments:
- self._current_definition.AppendEntryComment(
- enum_key, ' '.join(self._current_comments))
- self._current_comments = []
+ self._current_definition.AppendEntryComment(
+ enum_key, ' '.join(self._current_comments))
+ self._current_comments = []
self._current_enum_entry = ''
def _AddToCurrentEnumEntry(self, line):
« no previous file with comments | « no previous file | build/android/gyp/java_cpp_enum_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698