OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 | 31 |
32 /** | 32 /** |
33 * @constructor | 33 * @constructor |
34 * @extends {WebInspector.Object} | 34 * @extends {WebInspector.Object} |
35 * @implements {WebInspector.ContentProvider} | 35 * @implements {WebInspector.ContentProvider} |
36 * @param {!WebInspector.Project} project | 36 * @param {!WebInspector.Project} project |
37 * @param {string} parentPath | 37 * @param {string} url |
38 * @param {string} name | |
39 * @param {string} originURL | |
40 * @param {!WebInspector.ResourceType} contentType | 38 * @param {!WebInspector.ResourceType} contentType |
41 */ | 39 */ |
42 WebInspector.UISourceCode = function(project, parentPath, name, originURL, conte
ntType) | 40 WebInspector.UISourceCode = function(project, url, contentType) |
43 { | 41 { |
44 this._project = project; | 42 this._project = project; |
45 this._parentPath = parentPath; | 43 this._path = url; |
46 this._name = name; | 44 this._originURL = url; |
47 this._originURL = originURL; | 45 |
| 46 var pathComponents = WebInspector.ParsedURL.splitURLIntoPathComponents(url); |
| 47 this._host = pathComponents[0]; |
| 48 this._parentPath = pathComponents.slice(0, -1).join("/"); |
| 49 this._name = pathComponents[pathComponents.length - 1]; |
| 50 |
48 this._contentType = contentType; | 51 this._contentType = contentType; |
49 /** @type {!Array.<function(?string)>} */ | 52 /** @type {!Array.<function(?string)>} */ |
50 this._requestContentCallbacks = []; | 53 this._requestContentCallbacks = []; |
51 | 54 |
52 /** @type {!Array.<!WebInspector.Revision>} */ | 55 /** @type {!Array.<!WebInspector.Revision>} */ |
53 this.history = []; | 56 this.history = []; |
54 this._hasUnsavedCommittedChanges = false; | 57 this._hasUnsavedCommittedChanges = false; |
55 | 58 |
56 /** @type {!Array<!WebInspector.UISourceCode.Message>} */ | 59 /** @type {!Array<!WebInspector.UISourceCode.Message>} */ |
57 this._messages = []; | 60 this._messages = []; |
58 } | 61 } |
59 | 62 |
60 /** | 63 /** |
61 * @enum {string} | 64 * @enum {string} |
62 */ | 65 */ |
63 WebInspector.UISourceCode.Events = { | 66 WebInspector.UISourceCode.Events = { |
64 WorkingCopyChanged: "WorkingCopyChanged", | 67 WorkingCopyChanged: "WorkingCopyChanged", |
65 WorkingCopyCommitted: "WorkingCopyCommitted", | 68 WorkingCopyCommitted: "WorkingCopyCommitted", |
66 TitleChanged: "TitleChanged", | 69 TitleChanged: "TitleChanged", |
67 SourceMappingChanged: "SourceMappingChanged", | 70 SourceMappingChanged: "SourceMappingChanged", |
68 MessageAdded: "MessageAdded", | 71 MessageAdded: "MessageAdded", |
69 MessageRemoved: "MessageRemoved", | 72 MessageRemoved: "MessageRemoved", |
70 } | 73 } |
71 | 74 |
72 WebInspector.UISourceCode.prototype = { | 75 WebInspector.UISourceCode.prototype = { |
73 /** | 76 /** |
74 * @return {string} | 77 * @return {string} |
75 */ | 78 */ |
| 79 path: function() |
| 80 { |
| 81 return this._path; |
| 82 }, |
| 83 |
| 84 /** |
| 85 * @return {string} |
| 86 */ |
76 name: function() | 87 name: function() |
77 { | 88 { |
78 return this._name; | 89 return this._name; |
79 }, | 90 }, |
80 | 91 |
81 /** | 92 /** |
82 * @return {string} | 93 * @return {string} |
83 */ | 94 */ |
84 parentPath: function() | 95 parentPath: function() |
85 { | 96 { |
86 return this._parentPath; | 97 return this._parentPath; |
87 }, | 98 }, |
88 | 99 |
89 /** | 100 /** |
90 * @return {string} | 101 * @return {string} |
91 */ | 102 */ |
92 path: function() | 103 host: function() |
93 { | 104 { |
94 return this._parentPath ? this._parentPath + "/" + this._name : this._na
me; | 105 return this._host; |
95 }, | 106 }, |
96 | 107 |
97 /** | 108 /** |
98 * @return {string} | 109 * @return {string} |
99 */ | 110 */ |
100 fullDisplayName: function() | 111 fullDisplayName: function() |
101 { | 112 { |
102 return this._project.displayName() + "/" + (this._parentPath ? this._par
entPath + "/" : "") + this.displayName(true); | 113 return this._parentPath.replace(/^(?:https?|file)\:\/\//, "") + "/" + th
is.displayName(true); |
103 }, | 114 }, |
104 | 115 |
105 /** | 116 /** |
106 * @param {boolean=} skipTrim | 117 * @param {boolean=} skipTrim |
107 * @return {string} | 118 * @return {string} |
108 */ | 119 */ |
109 displayName: function(skipTrim) | 120 displayName: function(skipTrim) |
110 { | 121 { |
111 var displayName = this.name() || WebInspector.UIString("(index)"); | 122 var displayName = this.name() || WebInspector.UIString("(index)"); |
112 return skipTrim ? displayName : displayName.trimEnd(100); | 123 return skipTrim ? displayName : displayName.trimEnd(100); |
113 }, | 124 }, |
114 | 125 |
115 /** | 126 /** |
116 * @return {string} | 127 * @return {string} |
117 */ | 128 */ |
118 uri: function() | 129 uri: function() |
119 { | 130 { |
120 var path = this.path(); | 131 return this._path; |
121 if (!this._project.url()) | |
122 return path; | |
123 if (!path) | |
124 return this._project.url(); | |
125 return this._project.url() + "/" + path; | |
126 }, | 132 }, |
127 | 133 |
128 /** | 134 /** |
129 * @return {string} | 135 * @return {string} |
130 */ | 136 */ |
131 originURL: function() | 137 originURL: function() |
132 { | 138 { |
133 return this._originURL; | 139 return this._originURL; |
134 }, | 140 }, |
135 | 141 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 }, | 184 }, |
179 | 185 |
180 /** | 186 /** |
181 * @param {string} name | 187 * @param {string} name |
182 * @param {string} originURL | 188 * @param {string} originURL |
183 * @param {!WebInspector.ResourceType=} contentType | 189 * @param {!WebInspector.ResourceType=} contentType |
184 */ | 190 */ |
185 _updateName: function(name, originURL, contentType) | 191 _updateName: function(name, originURL, contentType) |
186 { | 192 { |
187 var oldURI = this.uri(); | 193 var oldURI = this.uri(); |
| 194 this._path = this._path.substring(0, this._path.length - this._name.leng
th) + name; |
188 this._name = name; | 195 this._name = name; |
189 if (originURL) | 196 if (originURL) |
190 this._originURL = originURL; | 197 this._originURL = originURL; |
191 if (contentType) | 198 if (contentType) |
192 this._contentType = contentType; | 199 this._contentType = contentType; |
193 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.TitleChan
ged, oldURI); | 200 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.TitleChan
ged, oldURI); |
194 }, | 201 }, |
195 | 202 |
196 /** | 203 /** |
197 * @override | 204 * @override |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 isEqual: function(another) | 864 isEqual: function(another) |
858 { | 865 { |
859 return this._uiSourceCode === another._uiSourceCode && this.text() === a
nother.text() && this.level() === another.level() && this.range().equal(another.
range()); | 866 return this._uiSourceCode === another._uiSourceCode && this.text() === a
nother.text() && this.level() === another.level() && this.range().equal(another.
range()); |
860 }, | 867 }, |
861 | 868 |
862 remove: function() | 869 remove: function() |
863 { | 870 { |
864 this._uiSourceCode.removeMessage(this); | 871 this._uiSourceCode.removeMessage(this); |
865 } | 872 } |
866 } | 873 } |
OLD | NEW |