OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Datatypes holding information extracted by the analyzer and used by later | 6 * Datatypes holding information extracted by the analyzer and used by later |
7 * phases of the compiler. | 7 * phases of the compiler. |
8 */ | 8 */ |
9 library info; | 9 library info; |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 /** | 60 /** |
61 * Checks if [input] is valid. It must be in [_baseDir] and must not be in | 61 * Checks if [input] is valid. It must be in [_baseDir] and must not be in |
62 * the [_outputDir]. | 62 * the [_outputDir]. |
63 * | 63 * |
64 * Adds emitted error/warning messages to [messages], if [messages] is | 64 * Adds emitted error/warning messages to [messages], if [messages] is |
65 * supplied. | 65 * supplied. |
66 */ | 66 */ |
67 bool checkInputPath(String input, Messages messages) { | 67 bool checkInputPath(String input, Messages messages) { |
68 if (_mangleFilenames) return true; | 68 if (_mangleFilenames) return true; |
69 var canonicalized = path.normalize(input); | 69 var canonicalized = path.normalize(input); |
70 if (!path.relative(canonicalized, from: _outputDir).startsWith('../')) { | 70 var parentDir = '..${path.separator}'; |
| 71 if (!path.relative(canonicalized, from: _outputDir).startsWith(parentDir)) { |
71 messages.error( | 72 messages.error( |
72 'The file ${input} cannot be processed. ' | 73 'The file ${input} cannot be processed. ' |
73 'Files cannot be under the output folder (${_outputDir}).', | 74 'Files cannot be under the output folder (${_outputDir}).', |
74 null, file: input); | 75 null, file: input); |
75 return false; | 76 return false; |
76 } | 77 } |
77 if (path.relative(canonicalized, from: _baseDir).startsWith('../')) { | 78 if (path.relative(canonicalized, from: _baseDir).startsWith(parentDir)) { |
78 messages.error( | 79 messages.error( |
79 'The file ${input} cannot be processed. ' | 80 'The file ${input} cannot be processed. ' |
80 'All processed files must be under the base folder (${_baseDir}), you' | 81 'All processed files must be under the base folder (${_baseDir}), you' |
81 ' can specify the base folder using the --basedir flag.', | 82 ' can specify the base folder using the --basedir flag.', |
82 null, file: input); | 83 null, file: input); |
83 return false; | 84 return false; |
84 } | 85 } |
85 return true; | 86 return true; |
86 } | 87 } |
87 | 88 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } | 738 } |
738 | 739 |
739 visitChildren(ElementInfo info) { | 740 visitChildren(ElementInfo info) { |
740 for (var child in info.children) { | 741 for (var child in info.children) { |
741 var result = visit(child); | 742 var result = visit(child); |
742 if (result != null) return result; | 743 if (result != null) return result; |
743 } | 744 } |
744 return null; | 745 return null; |
745 } | 746 } |
746 } | 747 } |
OLD | NEW |