question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling Fields that Reference Variables

See original GitHub issue

Problem statement

Currently there is a referencesVariables function that is supposed to tell blockly whether a field references variables. But the way blockly gets the variables after it knows they are being referenced is pretty inflexible.

Blockly.Block.prototype.getVars = function() {
  var vars = [];
  for (var i = 0, input; input = this.inputList[i]; i++) {
    for (var j = 0, field; field = input.fieldRow[j]; j++) {
      if (field.referencesVariables()) {
        vars.push(field.getValue());
      }
    }
  }
  return vars;
};

This expects the value of the field to be a variable name, but this is not necessarily true of custom fields. The value could be two variable names, or a variable name and a const, really anything.

Proposals

  1. Add a getReferencedVariables() function that fields could override instead of referencesVariables().
  2. Remove referencesVariables(), instead add a type property to fields, and then have getVars check if the field is a variable field before calling getValue(). This means only variable fields would be allowed to reference variables.

Additional Information

N/A

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
BeksOmegacommented, Jun 2, 2019

Could I work on this ?

Yeah definitely! Once one of the blockly people gives a reply about which proposal they like.

0reactions
RoboErikGcommented, Jun 3, 2019

@abhinavsagar feel free to update the jsdoc (or let us know if it’s affecting you in some way). =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference Variables
A reference variable does not store its own values. Instead, when you reference the reference variable, OpenROAD uses the values in the corresponding...
Read more >
Handle references - Progress Software
Examples of handle references include CURRENT-WINDOW and BUFFER bCust:HANDLE (from the previous example). You can access the handle to a static handle-based ...
Read more >
Reference Variable in Java - GeeksforGeeks
Reference variables hold the objects/values of reference types in Java. ... It is used if parent class and child class have the same...
Read more >
Reference variables - IBM
A new reference variable has a null value by default, and causes a NullValueException when you use it to try to access a...
Read more >
References to fields, measures, and variables - Qlik | Help
You should not use the same name for a field and a variable (or a measure). But if you do and there is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found