OLD | NEW |
| (Empty) |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 from catapult_base.refactor import snippet | |
6 | |
7 | |
8 class AnnotatedSymbol(snippet.Symbol): | |
9 def __init__(self, symbol_type, children): | |
10 super(AnnotatedSymbol, self).__init__(symbol_type, children) | |
11 self._modified = False | |
12 | |
13 @property | |
14 def modified(self): | |
15 if self._modified: | |
16 return True | |
17 return super(AnnotatedSymbol, self).modified | |
18 | |
19 def __setattr__(self, name, value): | |
20 if (hasattr(self.__class__, name) and | |
21 isinstance(getattr(self.__class__, name), property)): | |
22 self._modified = True | |
23 return super(AnnotatedSymbol, self).__setattr__(name, value) | |
24 | |
25 def Cut(self, child): | |
26 for i in xrange(len(self._children)): | |
27 if self._children[i] == child: | |
28 self._modified = True | |
29 del self._children[i] | |
30 break | |
31 else: | |
32 raise ValueError('%s is not in %s.' % (child, self)) | |
33 | |
34 def Paste(self, child): | |
35 self._modified = True | |
36 self._children.append(child) | |
OLD | NEW |