Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor ast update #2409

Merged
merged 18 commits into from
Apr 25, 2019
Merged

Cursor ast update #2409

merged 18 commits into from
Apr 25, 2019

Conversation

alschmiedt
Copy link
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

Proposed Changes

Contains:

  1. Adds ability to exit toolbox by pushing 'E'
  2. When moving from stack to workspace places cursor above stack
  3. Add Tests
  4. Fixes for AST Node class from Keyboard nav ast node #2391
  5. Refactors Cursor and Cursor_Svg to use AST_Node ( needs review )

Reason for Changes

Test Coverage

Tested on:

Additional Information

Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general comment: we need a way to describe an AST node "for" a given connection, block, etc. Representing? Pointing to? Wrapping? Pick one and be consistent in all comments. (I like "pointing to")

Several comments start with "Pattern". Those are comments that apply to multiple places in the code, but that I didn't tag every single spot. Please update anything you find with that pattern in code you touched in this PR, but you don't need to hunt down every use of it in your code.

@@ -66,9 +68,36 @@ Blockly.Navigation.STATE_TOOLBOX = 3;

/**
* The current state the user is in.
* Initialized to workspace state since a user enters navigation mode by shift
* clicking on a block or workspace.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

core/ast_node.js Outdated
/*
* The type of the location.
* @type String
* One of Blockly.ASTNode.types
* @type string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern: use @type {string} instead of @type string, and for other type annotations on properties. I think it's mostly here and in navigation.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

core/ast_node.js Outdated
};

/**
* The amount to move the workspace coordinate.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/**
* Create an ast node from a field.
* @param {?Blockly.Field} field The location of the ast node.
* @return {?Blockly.ASTNode} An ast node for a field.
* @param {Blockly.Field} field The location of the ast node.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern: move to a consistent version of AST Node in comments (from the current mix of astnode, ast node, ASTNode, AST Node, AST node)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

core/ast_node.js Outdated
if (connection.type === Blockly.INPUT_VALUE) {
astNode = new Blockly.ASTNode(Blockly.ASTNode.types.INPUT, connection);
astNode = Blockly.ASTNode.createInputNode(connection.getParentInput());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern: since you aren't doing anything to the astNode after the if/else, return the new node immediately, and return null at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -82,7 +83,7 @@ Blockly.CursorSvg.CURSOR_REFERENCE = null;

/**
* Parent svg element.
* This is generally a block unless the cursor is on the workspace
* This is generally a block unless the cursor is on the workspace.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This is generally a block's svg root, unless the cursor is on the workspace."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -146,15 +147,16 @@ Blockly.CursorSvg.prototype.setParent_ = function(newParent) {

/**
* Show the cursor using coordinates.
* @param {?goog.math.Coordinate} position The position of the cursor on the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up comment (you left a word)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Blockly.CursorSvg.prototype.update_ = function(position) {
this.showWithAnything_(position);
Blockly.CursorSvg.prototype.update_ = function() {
this.showWithAnything_();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving all ofshowWithAnything into here and deleting that function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

};

/**
* Get the insertion connection.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what the insertion connection is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -279,14 +320,16 @@ Blockly.Navigation.resetFlyout = function() {

/**
* Finds the best connection.
* @param {!Blockly.Block} block The block to be connected.
* @param {!Blockly.Connection} connection The connection to connect to.
* @param {Blockly.Block} block The block to be connected.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what the best connection is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@alschmiedt alschmiedt merged commit efbfdf7 into keyboard_nav Apr 25, 2019
@alschmiedt alschmiedt deleted the cursor_ast_update branch October 3, 2019 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants