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