OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 #include "src/inspector/search-util.h" | 5 #include "src/inspector/search-util.h" |
6 | 6 |
7 #include "src/inspector/protocol/Protocol.h" | 7 #include "src/inspector/protocol/Protocol.h" |
8 #include "src/inspector/v8-inspector-impl.h" | 8 #include "src/inspector/v8-inspector-impl.h" |
9 #include "src/inspector/v8-inspector-session-impl.h" | 9 #include "src/inspector/v8-inspector-session-impl.h" |
10 #include "src/inspector/v8-regex.h" | 10 #include "src/inspector/v8-regex.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return protocol::Debugger::SearchMatch::create() | 125 return protocol::Debugger::SearchMatch::create() |
126 .setLineNumber(lineNumber) | 126 .setLineNumber(lineNumber) |
127 .setLineContent(lineContent) | 127 .setLineContent(lineContent) |
128 .build(); | 128 .build(); |
129 } | 129 } |
130 | 130 |
131 std::unique_ptr<V8Regex> createSearchRegex(V8InspectorImpl* inspector, | 131 std::unique_ptr<V8Regex> createSearchRegex(V8InspectorImpl* inspector, |
132 const String16& query, | 132 const String16& query, |
133 bool caseSensitive, bool isRegex) { | 133 bool caseSensitive, bool isRegex) { |
134 String16 regexSource = isRegex ? query : createSearchRegexSource(query); | 134 String16 regexSource = isRegex ? query : createSearchRegexSource(query); |
135 return wrapUnique(new V8Regex(inspector, regexSource, caseSensitive)); | 135 return std::unique_ptr<V8Regex>( |
| 136 new V8Regex(inspector, regexSource, caseSensitive)); |
136 } | 137 } |
137 | 138 |
138 } // namespace | 139 } // namespace |
139 | 140 |
140 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> | 141 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> |
141 searchInTextByLinesImpl(V8InspectorSession* session, const String16& text, | 142 searchInTextByLinesImpl(V8InspectorSession* session, const String16& text, |
142 const String16& query, const bool caseSensitive, | 143 const String16& query, const bool caseSensitive, |
143 const bool isRegex) { | 144 const bool isRegex) { |
144 std::unique_ptr<V8Regex> regex = createSearchRegex( | 145 std::unique_ptr<V8Regex> regex = createSearchRegex( |
145 static_cast<V8InspectorSessionImpl*>(session)->inspector(), query, | 146 static_cast<V8InspectorSessionImpl*>(session)->inspector(), query, |
146 caseSensitive, isRegex); | 147 caseSensitive, isRegex); |
147 std::vector<std::pair<int, String16>> matches = | 148 std::vector<std::pair<int, String16>> matches = |
148 scriptRegexpMatchesByLines(*regex.get(), text); | 149 scriptRegexpMatchesByLines(*regex.get(), text); |
149 | 150 |
150 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> result; | 151 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> result; |
151 for (const auto& match : matches) | 152 for (const auto& match : matches) |
152 result.push_back(buildObjectForSearchMatch(match.first, match.second)); | 153 result.push_back(buildObjectForSearchMatch(match.first, match.second)); |
153 return result; | 154 return result; |
154 } | 155 } |
155 | 156 |
156 String16 findSourceURL(const String16& content, bool multiline) { | 157 String16 findSourceURL(const String16& content, bool multiline) { |
157 return findMagicComment(content, "sourceURL", multiline); | 158 return findMagicComment(content, "sourceURL", multiline); |
158 } | 159 } |
159 | 160 |
160 String16 findSourceMapURL(const String16& content, bool multiline) { | 161 String16 findSourceMapURL(const String16& content, bool multiline) { |
161 return findMagicComment(content, "sourceMappingURL", multiline); | 162 return findMagicComment(content, "sourceMappingURL", multiline); |
162 } | 163 } |
163 | 164 |
164 } // namespace v8_inspector | 165 } // namespace v8_inspector |
OLD | NEW |