Make comments more consistent.

This commit is contained in:
Neil Fraser
2021-06-08 15:41:08 -07:00
committed by Neil Fraser
parent 6a6c630f8c
commit cff7b359f4
22 changed files with 75 additions and 76 deletions

View File

@@ -509,7 +509,7 @@ Blockly.Block.prototype.getOnlyValueConnection_ = function() {
thisConnection.type == Blockly.connectionTypes.INPUT_VALUE &&
thisConnection.targetConnection) {
if (connection) {
return null; // More than one value input found.
return null; // More than one value input found.
}
connection = thisConnection;
}
@@ -1700,7 +1700,7 @@ Blockly.Block.prototype.validateTokens_ = function(tokens, argsCount) {
};
/**
* Inserts args in place of numerical tokens. String args are converted to json
* Inserts args in place of numerical tokens. String args are converted to JSON
* that defines a label field. If necessary an extra dummy input is added to
* the end of the elements.
* @param {!Array<!string|number>} tokens The tokens to interpolate
@@ -1742,9 +1742,9 @@ Blockly.Block.prototype.interpolateArguments_ =
};
/**
* Creates a field from the json definition of a field. If a field with the
* Creates a field from the JSON definition of a field. If a field with the
* given type cannot be found, this attempts to create a different field using
* the 'alt' property of the json definition (if it exists).
* the 'alt' property of the JSON definition (if it exists).
* @param {{alt:(string|undefined)}} element The element to try to turn into a
* field.
* @return {?Blockly.Field} The field defined by the JSON, or null if one
@@ -1764,7 +1764,7 @@ Blockly.Block.prototype.fieldFromJson_ = function(element) {
};
/**
* Creates an input from the json definition of an input. Sets the input's check
* Creates an input from the JSON definition of an input. Sets the input's check
* and alignment if they are provided.
* @param {!Object} element The JSON to turn into an input.
* @param {string} warningPrefix The prefix to add to warnings to help the

View File

@@ -493,8 +493,7 @@ Blockly.Connection.prototype.respawnShadow_ = function() {
var parentBlock = this.getSourceBlock();
var shadow = this.getShadowDom();
if (parentBlock.workspace && shadow) {
var blockShadow =
Blockly.Xml.domToBlock(shadow, parentBlock.workspace);
var blockShadow = Blockly.Xml.domToBlock(shadow, parentBlock.workspace);
if (blockShadow.outputConnection) {
this.connect(blockShadow.outputConnection);
} else if (blockShadow.previousConnection) {
@@ -646,11 +645,10 @@ Blockly.Connection.prototype.neighbours = function(_maxLimit) {
*/
Blockly.Connection.prototype.getParentInput = function() {
var parentInput = null;
var block = this.sourceBlock_;
var inputs = block.inputList;
for (var idx = 0; idx < block.inputList.length; idx++) {
if (inputs[idx].connection === this) {
parentInput = inputs[idx];
var inputs = this.sourceBlock_.inputList;
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].connection === this) {
parentInput = inputs[i];
break;
}
}
@@ -663,11 +661,12 @@ Blockly.Connection.prototype.getParentInput = function() {
* @return {string} The description.
*/
Blockly.Connection.prototype.toString = function() {
var msg;
var block = this.sourceBlock_;
if (!block) {
return 'Orphan Connection';
} else if (block.outputConnection == this) {
}
var msg;
if (block.outputConnection == this) {
msg = 'Output Connection of ';
} else if (block.previousConnection == this) {
msg = 'Previous Connection of ';

View File

@@ -88,13 +88,13 @@ Blockly.Css.CONTENT = [
'.blocklyWidgetDiv {',
'display: none;',
'position: absolute;',
'z-index: 99999;', /* big value for bootstrap3 compatibility */
'z-index: 99999;', /* big value for bootstrap3 compatibility */
'}',
'.injectionDiv {',
'height: 100%;',
'position: relative;',
'overflow: hidden;', /* So blocks in drag surface disappear at edges */
'overflow: hidden;', /* So blocks in drag surface disappear at edges */
'touch-action: none;',
'}',
@@ -125,7 +125,7 @@ Blockly.Css.CONTENT = [
'right: 0;',
'bottom: 0;',
'overflow: visible !important;',
'z-index: 50;', /* Display below toolbox, but above everything else. */
'z-index: 50;', /* Display below toolbox, but above everything else. */
'}',
'.blocklyBlockCanvas.blocklyCanvasTransitioning,',
@@ -143,7 +143,7 @@ Blockly.Css.CONTENT = [
'opacity: .9;',
'padding: 2px;',
'position: absolute;',
'z-index: 100000;', /* big value for bootstrap3 compatibility */
'z-index: 100000;', /* big value for bootstrap3 compatibility */
'}',
'.blocklyDropDownDiv {',
@@ -165,7 +165,7 @@ Blockly.Css.CONTENT = [
'}',
'.blocklyDropDownContent {',
'max-height: 300px;', // @todo: spec for maximum height.
'max-height: 300px;', // @todo: spec for maximum height.
'overflow: auto;',
'overflow-x: hidden;',
'position: relative;',
@@ -498,11 +498,11 @@ Blockly.Css.CONTENT = [
'}',
'.blocklyDropDownDiv .blocklyMenu {',
'background: inherit;', /* Compatibility with gapi, reset from goog-menu */
'border: inherit;', /* Compatibility with gapi, reset from goog-menu */
'background: inherit;', /* Compatibility with gapi, reset from goog-menu */
'border: inherit;', /* Compatibility with gapi, reset from goog-menu */
'font: normal 13px "Helvetica Neue", Helvetica, sans-serif;',
'outline: none;',
'position: relative;', /* Compatibility with gapi, reset from goog-menu */
'position: relative;', /* Compatibility with gapi, reset from goog-menu */
'z-index: 20000;', /* Arbitrary, but some apps depend on it... */
'}',
@@ -541,7 +541,7 @@ Blockly.Css.CONTENT = [
'background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;',
'float: left;',
'margin-left: -24px;',
'position: static;', /* Scroll with the menu. */
'position: static;', /* Scroll with the menu. */
'}',
'.blocklyMenuItemRtl .blocklyMenuItemCheckbox {',

View File

@@ -493,7 +493,7 @@ Blockly.DropDownDiv.getPositionBelowMetrics_ = function(
return {
initialX: xCoords.divX,
initialY : primaryY,
finalX: xCoords.divX, // X position remains constant during animation.
finalX: xCoords.divX, // X position remains constant during animation.
finalY: finalY,
arrowX: xCoords.arrowX,
arrowY: arrowY,
@@ -525,12 +525,12 @@ Blockly.DropDownDiv.getPositionAboveMetrics_ = function(
var arrowY = divSize.height - (Blockly.DropDownDiv.BORDER_SIZE * 2) -
(Blockly.DropDownDiv.ARROW_SIZE / 2);
var finalY = secondaryY - divSize.height - Blockly.DropDownDiv.PADDING_Y;
var initialY = secondaryY - divSize.height; // No padding on Y
var initialY = secondaryY - divSize.height; // No padding on Y.
return {
initialX: xCoords.divX,
initialY : initialY,
finalX: xCoords.divX, // X position remains constant during animation.
finalX: xCoords.divX, // X position remains constant during animation.
finalY: finalY,
arrowX: xCoords.arrowX,
arrowY: arrowY,
@@ -560,8 +560,8 @@ Blockly.DropDownDiv.getPositionTopOfPageMetrics_ = function(
return {
initialX: xCoords.divX,
initialY : 0,
finalX: xCoords.divX, // X position remains constant during animation.
finalY: 0, // Y position remains constant during animation.
finalX: xCoords.divX, // X position remains constant during animation.
finalY: 0, // Y position remains constant during animation.
arrowAtTop: null,
arrowX: null,
arrowY: null,

View File

@@ -281,7 +281,7 @@ Blockly.Events.filter = function(queueIn, forward) {
// Merge duplicates.
for (var i = 0, event; (event = queue[i]); i++) {
if (!event.isNull()) {
// Treat all ui events as the same type in hash table.
// Treat all UI events as the same type in hash table.
var eventType = event.isUiEvent ? Blockly.Events.UI : event.type;
var key = [eventType, event.blockId, event.workspaceId].join(' ');

View File

@@ -337,8 +337,8 @@ Blockly.FieldDropdown.prototype.dropdownCreate_ = function() {
var options = this.getOptions(false);
this.selectedMenuItem_ = null;
for (var i = 0; i < options.length; i++) {
var content = options[i][0]; // Human-readable text or image.
var value = options[i][1]; // Language-neutral value.
var content = options[i][0]; // Human-readable text or image.
var value = options[i][1]; // Language-neutral value.
if (typeof content == 'object') {
// An image, not text.
var image = new Image(content['width'], content['height']);

View File

@@ -100,8 +100,8 @@ Blockly.FieldMultilineInput.fromJson = function(options) {
* @package
*/
Blockly.FieldMultilineInput.prototype.toXml = function(fieldElement) {
// Replace '\n' characters with html-escaped equivalent '&#10'. This is
// needed so the plain-text representation of the xml produced by
// Replace '\n' characters with HTML-escaped equivalent '&#10'. This is
// needed so the plain-text representation of the XML produced by
// `Blockly.Xml.domToText` will appear on a single line (this is a limitation
// of the plain-text format).
fieldElement.textContent = this.getValue().replace(/\n/g, '&#10;');

View File

@@ -547,7 +547,7 @@ Blockly.FieldTextInput.prototype.isTabNavigable = function() {
*/
Blockly.FieldTextInput.prototype.getText_ = function() {
if (this.isBeingEdited_ && this.htmlInput_) {
// We are currently editing, return the html input value instead.
// We are currently editing, return the HTML input value instead.
return this.htmlInput_.value;
}
return null;

View File

@@ -129,7 +129,7 @@ Blockly.FieldVariable.prototype.configure_ = function(config) {
*/
Blockly.FieldVariable.prototype.initModel = function() {
if (this.variable_) {
return; // Initialization already happened.
return; // Initialization already happened.
}
var variable = Blockly.Variables.getOrCreateVariablePackage(
this.sourceBlock_.workspace, null,
@@ -300,7 +300,7 @@ Blockly.FieldVariable.prototype.doValueUpdate_ = function(newId) {
Blockly.FieldVariable.prototype.typeIsAllowed_ = function(type) {
var typeList = this.getVariableTypes_();
if (!typeList) {
return true; // If it's null, all types are valid.
return true; // If it's null, all types are valid.
}
for (var i = 0; i < typeList.length; i++) {
if (type == typeList[i]) {

View File

@@ -166,7 +166,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface,
mainWorkspace.getTheme().getClassName());
if (!wsOptions.hasCategories && wsOptions.languageTree) {
// Add flyout as an <svg> that is a sibling of the workspace svg.
// Add flyout as an <svg> that is a sibling of the workspace SVG.
var flyout = mainWorkspace.addFlyout(Blockly.utils.Svg.SVG);
Blockly.utils.dom.insertAfter(flyout, svg);
}

View File

@@ -384,7 +384,7 @@ Blockly.InsertionMarkerManager.prototype.shouldUpdatePreviews_ = function(
} else {
console.error('Only one of localConnection_ and closestConnection_ was set.');
}
} else { // No connection found.
} else { // No connection found.
// Only need to update if we were showing a preview before.
return !!(this.localConnection_ && this.closestConnection_);
}

View File

@@ -196,9 +196,9 @@ Blockly.Mutator.prototype.createEditor_ = function() {
this.workspace_.addChangeListener(Blockly.Events.disableOrphans);
// Mutator flyouts go inside the mutator workspace's <g> rather than in
// a top level svg. Instead of handling scale themselves, mutators
// a top level SVG. Instead of handling scale themselves, mutators
// inherit scale from the parent workspace.
// To fix this, scale needs to be applied at a different level in the dom.
// To fix this, scale needs to be applied at a different level in the DOM.
var flyoutSvg = hasFlyout ?
this.workspace_.addFlyout(Blockly.utils.Svg.G) : null;
var background = this.workspace_.createDom('blocklyMutatorBackground');

View File

@@ -261,14 +261,14 @@ Blockly.blockRendering.ConstantProvider = function() {
* to be the height of the text based on the font used.
* @type {number}
*/
this.FIELD_TEXT_HEIGHT = -1; // Dynamically set
this.FIELD_TEXT_HEIGHT = -1; // Dynamically set.
/**
* Text baseline. This constant is dynamically set in ``setFontConstants_``
* to be the baseline of the text based on the font used.
* @type {number}
*/
this.FIELD_TEXT_BASELINE = -1; // Dynamically set
this.FIELD_TEXT_BASELINE = -1; // Dynamically set.
/**
* A field's border rect corner radius.
@@ -855,7 +855,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makePuzzleTab = function() {
var halfHeight = height / 2;
var control1Y = halfHeight + overlap;
var control2Y = halfHeight + 0.5;
var control3Y = overlap; // 2.5
var control3Y = overlap; // 2.5
var endPoint1 = Blockly.utils.svgPaths.point(-width, forward * halfHeight);
var endPoint2 = Blockly.utils.svgPaths.point(width, forward * halfHeight);

View File

@@ -227,7 +227,7 @@ Blockly.blockRendering.Drawer.prototype.drawRightSideRow_ = function(row) {
/**
* Add steps for the bottom edge of a block, possibly including a notch
* for the next connection
* for the next connection.
* @protected
*/
Blockly.blockRendering.Drawer.prototype.drawBottom_ = function() {
@@ -449,7 +449,7 @@ Blockly.blockRendering.Drawer.prototype.positionNextConnection_ = function() {
if (bottomRow.connection) {
var connInfo = bottomRow.connection;
var x = connInfo.xPos; // Already contains info about startX
var x = connInfo.xPos; // Already contains info about startX.
var connX = (this.info_.RTL ? -x : x);
connInfo.connectionModel.setOffsetInBlock(connX, bottomRow.baseline);
}

View File

@@ -197,7 +197,7 @@ Blockly.geras.Drawer.prototype.positionNextConnection_ = function() {
if (bottomRow.connection) {
var connInfo = bottomRow.connection;
var x = connInfo.xPos; // Already contains info about startX
var x = connInfo.xPos; // Already contains info about startX.
var connX = (this.info_.RTL ? -x : x) +
(this.constants_.DARK_PATH_OFFSET / 2);
connInfo.connectionModel.setOffsetInBlock(

View File

@@ -214,23 +214,23 @@ Blockly.zelos.ConstantProvider = function() {
* @package
*/
this.SHAPE_IN_SHAPE_PADDING = {
1: { // Outer shape: hexagon.
0: 5 * this.GRID_UNIT, // Field in hexagon.
1: 2 * this.GRID_UNIT, // Hexagon in hexagon.
2: 5 * this.GRID_UNIT, // Round in hexagon.
3: 5 * this.GRID_UNIT // Square in hexagon.
1: { // Outer shape: hexagon.
0: 5 * this.GRID_UNIT, // Field in hexagon.
1: 2 * this.GRID_UNIT, // Hexagon in hexagon.
2: 5 * this.GRID_UNIT, // Round in hexagon.
3: 5 * this.GRID_UNIT // Square in hexagon.
},
2: { // Outer shape: round.
0: 3 * this.GRID_UNIT, // Field in round.
1: 3 * this.GRID_UNIT, // Hexagon in round.
2: 1 * this.GRID_UNIT, // Round in round.
3: 2 * this.GRID_UNIT // Square in round.
2: { // Outer shape: round.
0: 3 * this.GRID_UNIT, // Field in round.
1: 3 * this.GRID_UNIT, // Hexagon in round.
2: 1 * this.GRID_UNIT, // Round in round.
3: 2 * this.GRID_UNIT // Square in round.
},
3: { // Outer shape: square.
0: 2 * this.GRID_UNIT, // Field in square.
1: 2 * this.GRID_UNIT, // Hexagon in square.
2: 2 * this.GRID_UNIT, // Round in square.
3: 2 * this.GRID_UNIT // Square in square.
3: { // Outer shape: square.
0: 2 * this.GRID_UNIT, // Field in square.
1: 2 * this.GRID_UNIT, // Hexagon in square.
2: 2 * this.GRID_UNIT, // Round in square.
3: 2 * this.GRID_UNIT // Square in square.
}
};

View File

@@ -113,7 +113,7 @@ Blockly.Themes.HighContrast.setComponentStyle('selectedGlowSize', 1);
Blockly.Themes.HighContrast.setComponentStyle('replacementGlowColour', '#000000');
Blockly.Themes.HighContrast.setFontStyle({
'family': null, // Use default font-family
'weight': null, // Use default font-weight
'family': null, // Use default font-family.
'weight': null, // Use default font-weight.
'size': 16
});

View File

@@ -406,7 +406,7 @@ Blockly.Toolbox.prototype.render = function(toolboxDef) {
*/
Blockly.Toolbox.prototype.renderContents_ = function(toolboxDef) {
// This is for performance reasons. By using document fragment we only have to
// add to the dom once.
// add to the DOM once.
var fragment = document.createDocumentFragment();
for (var i = 0, toolboxItemDef; (toolboxItemDef = toolboxDef[i]); i++) {
this.createToolboxItem_(toolboxItemDef, fragment);
@@ -426,7 +426,7 @@ Blockly.Toolbox.prototype.createToolboxItem_ = function(toolboxItemDef, fragment
var registryName = toolboxItemDef['kind'];
// Categories that are collapsible are created using a class registered under
// a diffferent name.
// a different name.
if (registryName.toUpperCase() == 'CATEGORY' &&
Blockly.utils.toolbox.isCategoryCollapsible(
/** @type {!Blockly.utils.toolbox.CategoryInfo} */(toolboxItemDef))) {
@@ -443,7 +443,7 @@ Blockly.Toolbox.prototype.createToolboxItem_ = function(toolboxItemDef, fragment
if (toolboxItemDom) {
fragment.appendChild(toolboxItemDom);
}
// Adds the id to the html element that can receive a click.
// Adds the ID to the HTML element that can receive a click.
// This is used in onClick_ to find the toolboxItem that was clicked.
if (toolboxItem.getClickTarget) {
toolboxItem.getClickTarget().setAttribute('id', toolboxItem.getId());

View File

@@ -345,7 +345,7 @@ Blockly.utils.toolbox.xmlToJsonArray_ = function(toolboxDef) {
var tagName = child.tagName.toUpperCase();
obj['kind'] = tagName;
// Store the xml for a block
// Store the XML for a block.
if (tagName == 'BLOCK') {
obj['blockxml'] = child;
} else if (child.childNodes && child.childNodes.length > 0) {

View File

@@ -1787,7 +1787,7 @@ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) {
// This is needed as for some browser/system combinations which do not
// set deltaX.
x = this.scrollX - scrollDelta.y;
y = this.scrollY; // Don't scroll vertically
y = this.scrollY; // Don't scroll vertically.
}
this.scroll(x, y);
}
@@ -2213,8 +2213,8 @@ Blockly.WorkspaceSvg.prototype.setScale = function(newScale) {
this.scrollX -= metrics.absoluteLeft;
this.scrollY -= metrics.absoluteTop;
// // The scroll values and the view values are additive inverses of
// // each other, so when we subtract from one we have to add to the other.
// The scroll values and the view values are additive inverses of
// each other, so when we subtract from one we have to add to the other.
metrics.viewLeft += metrics.absoluteLeft;
metrics.viewTop += metrics.absoluteTop;

View File

@@ -166,7 +166,7 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
element.setAttribute('type', block.type);
if (!opt_noId) {
// It's important to use setAttribute here otherwise IE11 won't serialize
// the block's id when domToText is called.
// the block's ID when domToText is called.
element.setAttribute('id', block.id);
}
if (block.mutationToDom) {
@@ -637,7 +637,7 @@ Blockly.Xml.domToVariables = function(xmlVariables, workspace) {
Blockly.Xml.childNodeTagMap;
/**
* Creates a mapping of childNodes for each supported xml tag for the provided
* Creates a mapping of childNodes for each supported XML tag for the provided
* xmlBlock. Logs a warning for any encountered unsupported tags.
* @param {!Element} xmlBlock XML block element.
* @return {!Blockly.Xml.childNodeTagMap} The childNode map from nodeName to
@@ -765,8 +765,8 @@ Blockly.Xml.applyFieldTagNodes_ = function(xmlChildren, block) {
};
/**
* Finds any enclosed blocks or shadows within this xml node.
* @param {!Element} xmlNode The xml node to extract child block info from.
* Finds any enclosed blocks or shadows within this XML node.
* @param {!Element} xmlNode The XML node to extract child block info from.
* @return {{childBlockElement: ?Element, childShadowElement: ?Element}} Any
* found child block.
* @private

View File

@@ -22,8 +22,8 @@ Blockly.Python['procedures_defreturn'] = function(block) {
var globals = [];
var workspace = block.workspace;
var variables = Blockly.Variables.allUsedVarModels(workspace) || [];
for (var i = 0, variable; variable = variables[i]; i++) {
varName = variable.name;
for (var i = 0, variable; (variable = variables[i]); i++) {
var varName = variable.name;
if (block.getVars().indexOf(varName) == -1) {
globals.push(Blockly.Python.nameDB_.getName(varName,
Blockly.VARIABLE_CATEGORY_NAME));