OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_GN_VISIBILITY_H_ | 5 #ifndef TOOLS_GN_VISIBILITY_H_ |
6 #define TOOLS_GN_VISIBILITY_H_ | 6 #define TOOLS_GN_VISIBILITY_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "tools/gn/label_pattern.h" | 12 #include "tools/gn/label_pattern.h" |
12 #include "tools/gn/source_dir.h" | 13 #include "tools/gn/source_dir.h" |
13 | 14 |
| 15 namespace base { |
| 16 class Value; |
| 17 } |
| 18 |
14 class Err; | 19 class Err; |
15 class Item; | 20 class Item; |
16 class Label; | 21 class Label; |
17 class Scope; | 22 class Scope; |
18 class Value; | 23 class Value; |
19 | 24 |
20 class Visibility { | 25 class Visibility { |
21 public: | 26 public: |
22 // Defaults to private visibility (only the current file). | 27 // Defaults to private visibility (only the current file). |
23 Visibility(); | 28 Visibility(); |
(...skipping 12 matching lines...) Expand all Loading... |
36 // Returns true if the target with the given label can depend on one with the | 41 // Returns true if the target with the given label can depend on one with the |
37 // current visibility. | 42 // current visibility. |
38 bool CanSeeMe(const Label& label) const; | 43 bool CanSeeMe(const Label& label) const; |
39 | 44 |
40 // Returns a string listing the visibility. |indent| number of spaces will | 45 // Returns a string listing the visibility. |indent| number of spaces will |
41 // be added on the left side of the output. If |include_brackets| is set, the | 46 // be added on the left side of the output. If |include_brackets| is set, the |
42 // result will be wrapped in "[ ]" and the contents further indented. The | 47 // result will be wrapped in "[ ]" and the contents further indented. The |
43 // result will end in a newline. | 48 // result will end in a newline. |
44 std::string Describe(int indent, bool include_brackets) const; | 49 std::string Describe(int indent, bool include_brackets) const; |
45 | 50 |
| 51 // Returns value representation of this visibility |
| 52 std::unique_ptr<base::Value> AsValue() const; |
| 53 |
46 // Helper function to check visibility between the given two items. If | 54 // Helper function to check visibility between the given two items. If |
47 // to is invisible to from, returns false and sets the error. | 55 // to is invisible to from, returns false and sets the error. |
48 static bool CheckItemVisibility(const Item* from, const Item* to, Err* err); | 56 static bool CheckItemVisibility(const Item* from, const Item* to, Err* err); |
49 | 57 |
50 // Helper function to fill an item's visibility from the "visibility" value | 58 // Helper function to fill an item's visibility from the "visibility" value |
51 // in the current scope. | 59 // in the current scope. |
52 static bool FillItemVisibility(Item* item, Scope* scope, Err* err); | 60 static bool FillItemVisibility(Item* item, Scope* scope, Err* err); |
53 | 61 |
54 private: | 62 private: |
55 std::vector<LabelPattern> patterns_; | 63 std::vector<LabelPattern> patterns_; |
56 | 64 |
57 DISALLOW_COPY_AND_ASSIGN(Visibility); | 65 DISALLOW_COPY_AND_ASSIGN(Visibility); |
58 }; | 66 }; |
59 | 67 |
60 #endif // TOOLS_GN_VISIBILITY_H_ | 68 #endif // TOOLS_GN_VISIBILITY_H_ |
OLD | NEW |