Get rid of global GrDiffLine
* Replace the global GrDiffLine variable with named imports. * Update gr-app-global-var-init.js Change-Id: I7c9bc17bfa7c0d9bbd745219cd091d94cdb4cac4
This commit is contained in:
@@ -183,7 +183,6 @@ module.exports = {
|
||||
"GrDiffBuilderSideBySide": "readonly",
|
||||
"GrDiffBuilderUnified": "readonly",
|
||||
"GrDiffGroup": "readonly",
|
||||
"GrDiffLine": "readonly",
|
||||
"GrDomHook": "readonly",
|
||||
"GrDomHooksManager": "readonly",
|
||||
"GrEditConstants": "readonly",
|
||||
|
||||
@@ -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/gr-diff-line.js';
|
||||
import '../gr-diff/gr-diff-group.js';
|
||||
import './gr-diff-builder.js';
|
||||
import './gr-diff-builder-side-by-side.js';
|
||||
|
||||
@@ -49,7 +49,6 @@ limitations under the License.
|
||||
<script type="module">
|
||||
import '../../../test/common-test-setup.js';
|
||||
import '../../../scripts/util.js';
|
||||
import '../gr-diff/gr-diff-line.js';
|
||||
import '../gr-diff/gr-diff-group.js';
|
||||
import './gr-diff-builder.js';
|
||||
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
|
||||
@@ -57,6 +56,7 @@ import '../../shared/gr-rest-api-interface/mock-diff-response_test.js';
|
||||
import './gr-diff-builder-element.js';
|
||||
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';
|
||||
const DiffViewMode = {
|
||||
SIDE_BY_SIDE: 'SIDE_BY_SIDE',
|
||||
UNIFIED: 'UNIFIED_DIFF',
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
(function(window, GrDiffBuilder) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ limitations under the License.
|
||||
<script type="module">
|
||||
import '../../../test/common-test-setup.js';
|
||||
import '../../../scripts/util.js';
|
||||
import '../gr-diff/gr-diff-line.js';
|
||||
import '../gr-diff/gr-diff-group.js';
|
||||
import './gr-diff-builder.js';
|
||||
import './gr-diff-builder-unified.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
suite('GrDiffBuilderUnified tests', () => {
|
||||
let prefs;
|
||||
let outputEl;
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function(window, GrDiffGroup, GrDiffLine) {
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
(function(window, GrDiffGroup) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
@@ -622,4 +624,4 @@ ${commit.commit_msg}`;
|
||||
};
|
||||
|
||||
window.GrDiffBuilder = GrDiffBuilder;
|
||||
})(window, GrDiffGroup, GrDiffLine);
|
||||
})(window, GrDiffGroup);
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
import '../gr-diff/gr-diff-line.js';
|
||||
import '../gr-diff/gr-diff-group.js';
|
||||
import '../../../scripts/util.js';
|
||||
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
||||
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
const WHOLE_FILE = -1;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ limitations under the License.
|
||||
<script type="module">
|
||||
import '../../../test/common-test-setup.js';
|
||||
import './gr-diff-processor.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
suite('gr-diff-processor tests', () => {
|
||||
const WHOLE_FILE = -1;
|
||||
const loremIpsum =
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {GrDiffLine} from './gr-diff-line.js';
|
||||
|
||||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ limitations under the License.
|
||||
<script src="/components/wct-browser-legacy/browser.js"></script>
|
||||
<script type="module">
|
||||
import '../../../test/common-test-setup.js';
|
||||
import './gr-diff-line.js';
|
||||
import './gr-diff-group.js';
|
||||
import {GrDiffLine} from './gr-diff-line.js';
|
||||
suite('gr-diff-group tests', () => {
|
||||
test('delta line pairs', () => {
|
||||
let group = new GrDiffGroup(GrDiffGroup.Type.DELTA);
|
||||
|
||||
@@ -14,68 +14,60 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
// Prevent redefinition.
|
||||
if (window.GrDiffLine) { return; }
|
||||
/**
|
||||
* @constructor
|
||||
* @param {GrDiffLine.Type} type
|
||||
* @param {number|string=} opt_beforeLine
|
||||
* @param {number|string=} opt_afterLine
|
||||
*/
|
||||
export function GrDiffLine(type, opt_beforeLine, opt_afterLine) {
|
||||
this.type = type;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {GrDiffLine.Type} type
|
||||
* @param {number|string=} opt_beforeLine
|
||||
* @param {number|string=} opt_afterLine
|
||||
*/
|
||||
function GrDiffLine(type, opt_beforeLine, opt_afterLine) {
|
||||
this.type = type;
|
||||
/** @type {number|string} */
|
||||
this.beforeNumber = opt_beforeLine || 0;
|
||||
|
||||
/** @type {number|string} */
|
||||
this.beforeNumber = opt_beforeLine || 0;
|
||||
/** @type {number|string} */
|
||||
this.afterNumber = opt_afterLine || 0;
|
||||
|
||||
/** @type {number|string} */
|
||||
this.afterNumber = opt_afterLine || 0;
|
||||
/** @type {boolean} */
|
||||
this.hasIntralineInfo = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.hasIntralineInfo = false;
|
||||
/** @type {!Array<GrDiffLine.Highlights>} */
|
||||
this.highlights = [];
|
||||
|
||||
/** @type {!Array<GrDiffLine.Highlights>} */
|
||||
this.highlights = [];
|
||||
/** @type {?Array<Object>} ?Array<!GrDiffGroup> */
|
||||
this.contextGroups = null;
|
||||
|
||||
/** @type {?Array<Object>} ?Array<!GrDiffGroup> */
|
||||
this.contextGroups = null;
|
||||
this.text = '';
|
||||
}
|
||||
|
||||
this.text = '';
|
||||
}
|
||||
/** @enum {string} */
|
||||
GrDiffLine.Type = {
|
||||
ADD: 'add',
|
||||
BOTH: 'both',
|
||||
BLANK: 'blank',
|
||||
CONTEXT_CONTROL: 'contextControl',
|
||||
REMOVE: 'remove',
|
||||
};
|
||||
|
||||
/** @enum {string} */
|
||||
GrDiffLine.Type = {
|
||||
ADD: 'add',
|
||||
BOTH: 'both',
|
||||
BLANK: 'blank',
|
||||
CONTEXT_CONTROL: 'contextControl',
|
||||
REMOVE: 'remove',
|
||||
};
|
||||
/**
|
||||
* A line highlight object consists of three fields:
|
||||
* - contentIndex: The index of the chunk `content` field (the line
|
||||
* being referred to).
|
||||
* - startIndex: Index of the character where the highlight should begin.
|
||||
* - endIndex: (optional) Index of the character where the highlight should
|
||||
* end. If omitted, the highlight is meant to be a continuation onto the
|
||||
* next line.
|
||||
*
|
||||
* @typedef {{
|
||||
* contentIndex: number,
|
||||
* startIndex: number,
|
||||
* endIndex: number
|
||||
* }}
|
||||
*/
|
||||
GrDiffLine.Highlights;
|
||||
|
||||
/**
|
||||
* A line highlight object consists of three fields:
|
||||
* - contentIndex: The index of the chunk `content` field (the line
|
||||
* being referred to).
|
||||
* - startIndex: Index of the character where the highlight should begin.
|
||||
* - endIndex: (optional) Index of the character where the highlight should
|
||||
* end. If omitted, the highlight is meant to be a continuation onto the
|
||||
* next line.
|
||||
*
|
||||
* @typedef {{
|
||||
* contentIndex: number,
|
||||
* startIndex: number,
|
||||
* endIndex: number
|
||||
* }}
|
||||
*/
|
||||
GrDiffLine.Highlights;
|
||||
GrDiffLine.FILE = 'FILE';
|
||||
|
||||
GrDiffLine.FILE = 'FILE';
|
||||
|
||||
GrDiffLine.BLANK_LINE = new GrDiffLine(GrDiffLine.Type.BLANK);
|
||||
|
||||
window.GrDiffLine = GrDiffLine;
|
||||
})(window);
|
||||
GrDiffLine.BLANK_LINE = new GrDiffLine(GrDiffLine.Type.BLANK);
|
||||
|
||||
@@ -24,7 +24,6 @@ import '../gr-diff-selection/gr-diff-selection.js';
|
||||
import '../gr-syntax-themes/gr-syntax-theme.js';
|
||||
import '../gr-ranged-comment-themes/gr-ranged-comment-theme.js';
|
||||
import '../../../scripts/hiddenscroll.js';
|
||||
import './gr-diff-line.js';
|
||||
import './gr-diff-group.js';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||
@@ -33,6 +32,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
|
||||
import {htmlTemplate} from './gr-diff_html.js';
|
||||
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
|
||||
import {GrDiffLine} from './gr-diff-line.js';
|
||||
|
||||
const ERR_COMMENT_ON_EDIT = 'You cannot comment on an edit.';
|
||||
const ERR_COMMENT_ON_EDIT_BASE = 'You cannot comment on the base patch set ' +
|
||||
|
||||
@@ -21,6 +21,7 @@ import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-l
|
||||
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-ranged-comment-layer_html.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
// Polymer 1 adds # before array's key, while Polymer 2 doesn't
|
||||
const HOVER_PATH_PATTERN = /^(commentRanges\.\#?\d+)\.hovering$/;
|
||||
|
||||
@@ -35,6 +35,7 @@ import '../../../test/common-test-setup.js';
|
||||
import '../gr-diff/gr-diff-line.js';
|
||||
import './gr-ranged-comment-layer.js';
|
||||
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
suite('gr-ranged-comment-layer', () => {
|
||||
let element;
|
||||
|
||||
@@ -18,12 +18,12 @@ import '../../../scripts/bundled-polymer.js';
|
||||
|
||||
import '../../shared/gr-lib-loader/gr-lib-loader.js';
|
||||
import '../../../scripts/util.js';
|
||||
import '../gr-diff/gr-diff-line.js';
|
||||
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
|
||||
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
||||
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-syntax-layer_html.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
const LANGUAGE_MAP = {
|
||||
'application/dart': 'dart',
|
||||
|
||||
@@ -35,6 +35,7 @@ import '../../../test/common-test-setup.js';
|
||||
import '../../shared/gr-rest-api-interface/mock-diff-response_test.js';
|
||||
import './gr-syntax-layer.js';
|
||||
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
|
||||
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
|
||||
|
||||
suite('gr-syntax-layer tests', () => {
|
||||
let sandbox;
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
import {GrDisplayNameUtils} from '../scripts/gr-display-name-utils/gr-display-name-utils.js';
|
||||
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';
|
||||
|
||||
export function initGlobalVariables() {
|
||||
window.GrDisplayNameUtils = GrDisplayNameUtils;
|
||||
window.GrAnnotation = GrAnnotation;
|
||||
window.GrAttributeHelper = GrAttributeHelper;
|
||||
window.GrDiffLine = GrDiffLine;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user