Get rid of global GrDiffBuilder

* Replace the global GrDiffBuilder variable with named imports.
* Update gr-app-global-var-init.js

Change-Id: I0d07cd3ef56bf2fefebbfc29d31ed515e13b9d27
This commit is contained in:
Dmitrii Filippov
2020-03-23 20:44:31 +01:00
parent 016c984194
commit eca71692d2
9 changed files with 546 additions and 545 deletions

View File

@@ -177,7 +177,6 @@ module.exports = {
"GrChangeReplyInterface": "readonly",
"GrChangeViewApi": "readonly",
"GrCountStringFormatter": "readonly",
"GrDiffBuilder": "readonly",
"GrDiffBuilderBinary": "readonly",
"GrDiffBuilderImage": "readonly",
"GrDiffBuilderSideBySide": "readonly",

View File

@@ -14,7 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(window, GrDiffBuilder) {
import {GrDiffBuilder} from './gr-diff-builder.js';
(function(window) {
'use strict';
// Prevent redefinition.
@@ -44,4 +47,4 @@
};
window.GrDiffBuilderBinary = GrDiffBuilderBinary;
})(window, GrDiffBuilder);
})(window);

View File

@@ -21,7 +21,6 @@ import '../gr-diff-processor/gr-diff-processor.js';
import '../../shared/gr-hovercard/gr-hovercard.js';
import '../gr-ranged-comment-layer/gr-ranged-comment-layer.js';
import '../../../scripts/util.js';
import './gr-diff-builder.js';
import './gr-diff-builder-side-by-side.js';
import './gr-diff-builder-unified.js';
import './gr-diff-builder-image.js';
@@ -32,6 +31,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-diff-builder-element_html.js';
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
import {GrDiffBuilder} from './gr-diff-builder.js';
const DiffViewMode = {
SIDE_BY_SIDE: 'SIDE_BY_SIDE',

View File

@@ -58,6 +58,7 @@ import {dom, flush} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
import {GrDiffGroup} from '../gr-diff/gr-diff-group.js';
import {GrDiffBuilder} from './gr-diff-builder.js';
const DiffViewMode = {
SIDE_BY_SIDE: 'SIDE_BY_SIDE',

View File

@@ -14,7 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(window, GrDiffBuilder) {
import {GrDiffBuilder} from './gr-diff-builder.js';
(function(window) {
'use strict';
// Prevent redefinition.
@@ -116,4 +119,4 @@
};
window.GrDiffBuilderSideBySide = GrDiffBuilderSideBySide;
})(window, GrDiffBuilder);
})(window);

View File

@@ -15,8 +15,9 @@
* limitations under the License.
*/
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
import {GrDiffBuilder} from './gr-diff-builder.js';
(function(window, GrDiffBuilder) {
(function(window) {
'use strict';
// Prevent redefinition.
@@ -114,4 +115,4 @@ import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
};
window.GrDiffBuilderUnified = GrDiffBuilderUnified;
})(window, GrDiffBuilder);
})(window);

View File

@@ -29,6 +29,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-diff-host_html.js';
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {GrDiffBuilder} from '../gr-diff-builder/gr-diff-builder.js';
const MSG_EMPTY_BLAME = 'No blame information for this diff.';

View File

@@ -27,6 +27,7 @@ import {GrAnnotation} from './diff/gr-diff-highlight/gr-annotation.js';
import {GrAttributeHelper} from './plugins/gr-attribute-helper/gr-attribute-helper.js';
import {GrDiffLine} from './diff/gr-diff/gr-diff-line.js';
import {GrDiffGroup} from './diff/gr-diff/gr-diff-group.js';
import {GrDiffBuilder} from './diff/gr-diff-builder/gr-diff-builder.js';
export function initGlobalVariables() {
window.GrDisplayNameUtils = GrDisplayNameUtils;
@@ -34,4 +35,5 @@ export function initGlobalVariables() {
window.GrAttributeHelper = GrAttributeHelper;
window.GrDiffLine = GrDiffLine;
window.GrDiffGroup = GrDiffGroup;
window.GrDiffBuilder = GrDiffBuilder;
}