| 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.ProjectSearchConfig} | 7 * @implements {WebInspector.ProjectSearchConfig} |
| 8 * @param {string} query | 8 * @param {string} query |
| 9 * @param {boolean} ignoreCase | 9 * @param {boolean} ignoreCase |
| 10 * @param {boolean} isRegex | 10 * @param {boolean} isRegex |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 /** | 57 /** |
| 58 * @return {{query: string, ignoreCase: boolean, isRegex: boolean}} | 58 * @return {{query: string, ignoreCase: boolean, isRegex: boolean}} |
| 59 */ | 59 */ |
| 60 toPlainObject: function() | 60 toPlainObject: function() |
| 61 { | 61 { |
| 62 return { query: this.query(), ignoreCase: this.ignoreCase(), isRegex: th
is.isRegex() }; | 62 return { query: this.query(), ignoreCase: this.ignoreCase(), isRegex: th
is.isRegex() }; |
| 63 }, | 63 }, |
| 64 | 64 |
| 65 _parse: function() | 65 _parse: function() |
| 66 { | 66 { |
| 67 var filePattern = "-?file:(([^\\\\ ]|\\\\.)+)"; // After file: prefix: a
ny symbol except space and backslash or any symbol escaped with a backslash. | 67 var filePattern = "-?f(ile)?:(([^\\\\ ]|\\\\.)+)"; // After file: prefix
: any symbol except space and backslash or any symbol escaped with a backslash. |
| 68 var quotedPattern = "\"(([^\\\\\"]|\\\\.)+)\""; // Inside double quotes:
any symbol except double quote and backslash or any symbol escaped with a backs
lash. | 68 var quotedPattern = "\"(([^\\\\\"]|\\\\.)+)\""; // Inside double quotes:
any symbol except double quote and backslash or any symbol escaped with a backs
lash. |
| 69 | 69 |
| 70 // A word is a sequence of any symbols except space and backslash or any
symbols escaped with a backslash, that does not start with file:. | 70 // A word is a sequence of any symbols except space and backslash or any
symbols escaped with a backslash, that does not start with file:. |
| 71 var unquotedWordPattern = "((?!-?file:)[^\\\\ ]|\\\\.)+"; | 71 var unquotedWordPattern = "((?!-?f(ile)?:)[^\\\\ ]|\\\\.)+"; |
| 72 var unquotedPattern = unquotedWordPattern + "( +" + unquotedWordPattern
+ ")*"; // A word or several words separated by space(s). | 72 var unquotedPattern = unquotedWordPattern + "( +" + unquotedWordPattern
+ ")*"; // A word or several words separated by space(s). |
| 73 | 73 |
| 74 var pattern = "(" + filePattern + ")|(" + quotedPattern + ")|(" + unquot
edPattern + ")"; | 74 var pattern = "(" + filePattern + ")|(" + quotedPattern + ")|(" + unquot
edPattern + ")"; |
| 75 var regexp = new RegExp(pattern, "g"); | 75 var regexp = new RegExp(pattern, "g"); |
| 76 var queryParts = this._query.match(regexp) || []; | 76 var queryParts = this._query.match(regexp) || []; |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * @type {!Array.<!WebInspector.SearchConfig.QueryTerm>} | 79 * @type {!Array.<!WebInspector.SearchConfig.QueryTerm>} |
| 80 */ | 80 */ |
| 81 this._fileQueries = []; | 81 this._fileQueries = []; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 { | 139 { |
| 140 return query.substring(1, query.length - 1).replace(/\\(.)/g, "$1"); | 140 return query.substring(1, query.length - 1).replace(/\\(.)/g, "$1"); |
| 141 }, | 141 }, |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * @param {string} query | 144 * @param {string} query |
| 145 * @return {?WebInspector.SearchConfig.QueryTerm} | 145 * @return {?WebInspector.SearchConfig.QueryTerm} |
| 146 */ | 146 */ |
| 147 _parseFileQuery: function(query) | 147 _parseFileQuery: function(query) |
| 148 { | 148 { |
| 149 var match = query.match(/^(-)?file:/); | 149 var match = query.match(/^(-)?f(ile)?:/); |
| 150 if (!match) | 150 if (!match) |
| 151 return null; | 151 return null; |
| 152 var isNegative = !!match[1]; | 152 var isNegative = !!match[1]; |
| 153 query = query.substr(match[0].length); | 153 query = query.substr(match[0].length); |
| 154 var result = ""; | 154 var result = ""; |
| 155 for (var i = 0; i < query.length; ++i) { | 155 for (var i = 0; i < query.length; ++i) { |
| 156 var char = query[i]; | 156 var char = query[i]; |
| 157 if (char === "*") { | 157 if (char === "*") { |
| 158 result += ".*"; | 158 result += ".*"; |
| 159 } else if (char === "\\") { | 159 } else if (char === "\\") { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 174 /** | 174 /** |
| 175 * @constructor | 175 * @constructor |
| 176 * @param {string} text | 176 * @param {string} text |
| 177 * @param {boolean} isNegative | 177 * @param {boolean} isNegative |
| 178 */ | 178 */ |
| 179 WebInspector.SearchConfig.QueryTerm = function(text, isNegative) | 179 WebInspector.SearchConfig.QueryTerm = function(text, isNegative) |
| 180 { | 180 { |
| 181 this.text = text; | 181 this.text = text; |
| 182 this.isNegative = isNegative; | 182 this.isNegative = isNegative; |
| 183 } | 183 } |
| OLD | NEW |