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

Unified Diff: tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py

Issue 1620023002: Revert of Remove catapult_base from telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perf_cb_move
Patch Set: Created 4 years, 11 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
Index: tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py
diff --git a/tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py b/tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py
new file mode 100644
index 0000000000000000000000000000000000000000..8254aad9368de0d8f8db8fbd86c61c5fbdb5673c
--- /dev/null
+++ b/tools/telemetry/catapult_base/refactor/annotated_symbol/class_definition.py
@@ -0,0 +1,48 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import symbol
+
+from catapult_base.refactor.annotated_symbol import base_symbol
+
+
+__all__ = [
+ 'Class',
+]
+
+
+class Class(base_symbol.AnnotatedSymbol):
+ @classmethod
+ def Annotate(cls, symbol_type, children):
+ if symbol_type != symbol.stmt:
+ return None
+
+ compound_statement = children[0]
+ if compound_statement.type != symbol.compound_stmt:
+ return None
+
+ statement = compound_statement.children[0]
+ if statement.type == symbol.classdef:
+ return cls(statement.type, statement.children)
+ elif (statement.type == symbol.decorated and
+ statement.children[-1].type == symbol.classdef):
+ return cls(statement.type, statement.children)
+ else:
+ return None
+
+ @property
+ def suite(self):
+ raise NotImplementedError()
+
+ def FindChild(self, snippet_type, **kwargs):
+ return self.suite.FindChild(snippet_type, **kwargs)
+
+ def FindChildren(self, snippet_type):
+ return self.suite.FindChildren(snippet_type)
+
+ def Cut(self, child):
+ self.suite.Cut(child)
+
+ def Paste(self, child):
+ self.suite.Paste(child)

Powered by Google App Engine
This is Rietveld 408576698