Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
3e292608
Commit
3e292608
authored
May 09, 2019
by
Evan W. Patton
Committed by
Jeffrey Schiller
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix translations of event params when switching languages
Change-Id: I11fcadeac62427a9f03a5ef1173c3ca3a2523b06
parent
897d96d3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
35 deletions
+82
-35
appinventor/blocklyeditor/src/blocks/components.js
appinventor/blocklyeditor/src/blocks/components.js
+16
-1
appinventor/blocklyeditor/src/blocks/lexical-variables.js
appinventor/blocklyeditor/src/blocks/lexical-variables.js
+11
-6
appinventor/blocklyeditor/src/blocks/procedures.js
appinventor/blocklyeditor/src/blocks/procedures.js
+4
-0
appinventor/blocklyeditor/src/field_lexical_variable.js
appinventor/blocklyeditor/src/field_lexical_variable.js
+47
-24
appinventor/blocklyeditor/src/field_parameter_flydown.js
appinventor/blocklyeditor/src/field_parameter_flydown.js
+4
-4
No files found.
appinventor/blocklyeditor/src/blocks/components.js
View file @
3e292608
...
@@ -440,7 +440,22 @@ Blockly.Blocks.component_event = {
...
@@ -440,7 +440,22 @@ Blockly.Blocks.component_event = {
},
},
declaredNames
:
function
()
{
// [lyn, 10/13/13] Interface with Blockly.LexicalVariable.renameParam
declaredNames
:
function
()
{
// [lyn, 10/13/13] Interface with Blockly.LexicalVariable.renameParam
return
this
.
getVars
();
var
names
=
[];
for
(
var
i
=
0
,
param
;
param
=
this
.
getField
(
'
VAR
'
+
i
);
i
++
)
{
names
.
push
(
param
.
getText
());
if
(
param
.
eventparam
&&
param
.
eventparam
!=
param
.
getText
())
{
names
.
push
(
param
.
eventparam
);
}
}
return
names
;
},
declaredVariables
:
function
()
{
var
names
=
[];
for
(
var
i
=
0
,
param
;
param
=
this
.
getField
(
'
VAR
'
+
i
);
i
++
)
{
names
.
push
(
param
.
getText
());
}
return
names
;
},
},
blocksInScope
:
function
()
{
// [lyn, 10/13/13] Interface with Blockly.LexicalVariable.renameParam
blocksInScope
:
function
()
{
// [lyn, 10/13/13] Interface with Blockly.LexicalVariable.renameParam
...
...
appinventor/blocklyeditor/src/blocks/lexical-variables.js
View file @
3e292608
...
@@ -96,10 +96,11 @@ Blockly.Blocks['global_declaration'] = {
...
@@ -96,10 +96,11 @@ Blockly.Blocks['global_declaration'] = {
this
.
setTooltip
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP
);
this
.
setTooltip
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP
);
},
},
getVars
:
function
()
{
getVars
:
function
()
{
return
[
this
.
getFieldValue
(
'
NAME
'
)];
var
field
=
this
.
getField
(
'
NAME
'
);
return
field
?
[
field
.
getText
()]
:
[];
},
},
renameVar
:
function
(
oldName
,
newName
)
{
renameVar
:
function
(
oldName
,
newName
)
{
if
(
Blockly
.
Names
.
equals
(
oldName
,
this
.
getFieldValue
(
'
VAR
'
)))
{
if
(
Blockly
.
Names
.
equals
(
oldName
,
this
.
getFieldValue
(
'
NAME
'
)))
{
this
.
setFieldValue
(
newName
,
'
NAME
'
);
this
.
setFieldValue
(
newName
,
'
NAME
'
);
}
}
},
},
...
@@ -131,7 +132,7 @@ Blockly.Blocks['lexical_variable_get'] = {
...
@@ -131,7 +132,7 @@ Blockly.Blocks['lexical_variable_get'] = {
Blockly
.
LexicalVariable
.
eventParamDomToMutation
(
this
,
xmlElement
);
Blockly
.
LexicalVariable
.
eventParamDomToMutation
(
this
,
xmlElement
);
},
},
getVars
:
function
()
{
getVars
:
function
()
{
return
[
this
.
getFieldValue
(
'
VAR
'
)]
;
return
this
.
getFieldValue
(
'
VAR
'
)
;
},
},
renameLexicalVar
:
function
(
oldName
,
newName
)
{
renameLexicalVar
:
function
(
oldName
,
newName
)
{
// console.log("Renaming lexical variable from " + oldName + " to " + newName);
// console.log("Renaming lexical variable from " + oldName + " to " + newName);
...
@@ -193,7 +194,7 @@ Blockly.Blocks['lexical_variable_set'] = {
...
@@ -193,7 +194,7 @@ Blockly.Blocks['lexical_variable_set'] = {
Blockly
.
LexicalVariable
.
eventParamDomToMutation
(
this
,
xmlElement
);
Blockly
.
LexicalVariable
.
eventParamDomToMutation
(
this
,
xmlElement
);
},
},
getVars
:
function
()
{
getVars
:
function
()
{
return
[
this
.
getFieldValue
(
'
VAR
'
)]
;
return
this
.
getFieldValue
(
'
VAR
'
)
;
},
},
renameLexicalVar
:
Blockly
.
Blocks
.
lexical_variable_get
.
renameLexicalVar
,
renameLexicalVar
:
Blockly
.
Blocks
.
lexical_variable_get
.
renameLexicalVar
,
renameFree
:
function
(
freeSubstitution
)
{
renameFree
:
function
(
freeSubstitution
)
{
...
@@ -453,14 +454,17 @@ Blockly.Blocks['local_declaration_statement'] = {
...
@@ -453,14 +454,17 @@ Blockly.Blocks['local_declaration_statement'] = {
},
},
getVars
:
function
()
{
getVars
:
function
()
{
var
varList
=
[];
var
varList
=
[];
for
(
var
i
=
0
,
input
;
input
=
this
.
getField
Value
(
'
VAR
'
+
i
);
i
++
)
{
for
(
var
i
=
0
,
input
;
input
=
this
.
getField
(
'
VAR
'
+
i
);
i
++
)
{
varList
.
push
(
input
);
varList
.
push
(
input
.
getText
()
);
}
}
return
varList
;
return
varList
;
},
},
declaredNames
:
function
()
{
// Interface with Blockly.LexicalVariable.renameParam
declaredNames
:
function
()
{
// Interface with Blockly.LexicalVariable.renameParam
return
this
.
getVars
();
return
this
.
getVars
();
},
},
declaredVariables
:
function
()
{
return
this
.
getVars
();
},
initializerConnections
:
function
()
{
// [lyn, 11/16/13 ] Return all the initializer connections
initializerConnections
:
function
()
{
// [lyn, 11/16/13 ] Return all the initializer connections
var
connections
=
[];
var
connections
=
[];
for
(
var
i
=
0
,
input
;
input
=
this
.
getInput
(
'
DECL
'
+
i
);
i
++
)
{
for
(
var
i
=
0
,
input
;
input
=
this
.
getInput
(
'
DECL
'
+
i
);
i
++
)
{
...
@@ -588,6 +592,7 @@ Blockly.Blocks['local_declaration_expression'] = {
...
@@ -588,6 +592,7 @@ Blockly.Blocks['local_declaration_expression'] = {
saveConnections
:
Blockly
.
Blocks
.
local_declaration_statement
.
saveConnections
,
saveConnections
:
Blockly
.
Blocks
.
local_declaration_statement
.
saveConnections
,
getVars
:
Blockly
.
Blocks
.
local_declaration_statement
.
getVars
,
getVars
:
Blockly
.
Blocks
.
local_declaration_statement
.
getVars
,
declaredNames
:
Blockly
.
Blocks
.
local_declaration_statement
.
declaredNames
,
declaredNames
:
Blockly
.
Blocks
.
local_declaration_statement
.
declaredNames
,
declaredVariables
:
Blockly
.
Blocks
.
local_declaration_statement
.
declaredVariables
,
renameVar
:
Blockly
.
Blocks
.
local_declaration_statement
.
renameVar
,
renameVar
:
Blockly
.
Blocks
.
local_declaration_statement
.
renameVar
,
renameVars
:
Blockly
.
Blocks
.
local_declaration_statement
.
renameVars
,
renameVars
:
Blockly
.
Blocks
.
local_declaration_statement
.
renameVars
,
renameBound
:
Blockly
.
Blocks
.
local_declaration_statement
.
renameBound
,
renameBound
:
Blockly
.
Blocks
.
local_declaration_statement
.
renameBound
,
...
...
appinventor/blocklyeditor/src/blocks/procedures.js
View file @
3e292608
...
@@ -413,6 +413,9 @@ Blockly.Blocks['procedures_defnoreturn'] = {
...
@@ -413,6 +413,9 @@ Blockly.Blocks['procedures_defnoreturn'] = {
declaredNames
:
function
()
{
// [lyn, 10/11/13] return the names of all parameters of this procedure
declaredNames
:
function
()
{
// [lyn, 10/11/13] return the names of all parameters of this procedure
return
this
.
getVars
();
return
this
.
getVars
();
},
},
declaredVariables
:
function
()
{
return
this
.
getVars
();
},
renameVar
:
function
(
oldName
,
newName
)
{
renameVar
:
function
(
oldName
,
newName
)
{
this
.
renameVars
(
Blockly
.
Substitution
.
simpleSubstitution
(
oldName
,
newName
));
this
.
renameVars
(
Blockly
.
Substitution
.
simpleSubstitution
(
oldName
,
newName
));
},
},
...
@@ -506,6 +509,7 @@ Blockly.Blocks['procedures_defreturn'] = {
...
@@ -506,6 +509,7 @@ Blockly.Blocks['procedures_defreturn'] = {
getProcedureDef
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
getProcedureDef
,
getProcedureDef
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
getProcedureDef
,
getVars
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
getVars
,
getVars
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
getVars
,
declaredNames
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
declaredNames
,
declaredNames
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
declaredNames
,
declaredVariables
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
declaredVariables
,
renameVar
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
renameVar
,
renameVar
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
renameVar
,
renameVars
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
renameVars
,
renameVars
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
renameVars
,
renameBound
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
renameBound
,
renameBound
:
Blockly
.
Blocks
.
procedures_defnoreturn
.
renameBound
,
...
...
appinventor/blocklyeditor/src/field_lexical_variable.js
View file @
3e292608
...
@@ -87,7 +87,7 @@ Blockly.FieldLexicalVariable.prototype.setValue = function(text) {
...
@@ -87,7 +87,7 @@ Blockly.FieldLexicalVariable.prototype.setValue = function(text) {
* Update the eventparam mutation associated with the field's source block.
* Update the eventparam mutation associated with the field's source block.
*/
*/
Blockly
.
FieldLexicalVariable
.
prototype
.
updateMutation
=
function
()
{
Blockly
.
FieldLexicalVariable
.
prototype
.
updateMutation
=
function
()
{
var
text
=
this
.
get
Value
();
var
text
=
this
.
get
Text
();
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
getParent
())
{
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
getParent
())
{
this
.
sourceBlock_
.
eventparam
=
undefined
;
this
.
sourceBlock_
.
eventparam
=
undefined
;
if
(
text
.
indexOf
(
Blockly
.
globalNamePrefix
+
'
'
)
===
0
)
{
if
(
text
.
indexOf
(
Blockly
.
globalNamePrefix
+
'
'
)
===
0
)
{
...
@@ -96,7 +96,7 @@ Blockly.FieldLexicalVariable.prototype.updateMutation = function() {
...
@@ -96,7 +96,7 @@ Blockly.FieldLexicalVariable.prototype.updateMutation = function() {
}
}
var
i
,
parent
=
this
.
sourceBlock_
.
getParent
();
var
i
,
parent
=
this
.
sourceBlock_
.
getParent
();
while
(
parent
)
{
while
(
parent
)
{
var
variables
=
parent
.
getVars
()
;
var
variables
=
parent
.
declaredVariables
?
parent
.
declaredVariables
()
:
[]
;
if
(
parent
.
type
!=
'
component_event
'
)
{
if
(
parent
.
type
!=
'
component_event
'
)
{
for
(
i
=
0
;
i
<
variables
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
variables
.
length
;
i
++
)
{
if
(
variables
[
i
]
==
text
)
{
if
(
variables
[
i
]
==
text
)
{
...
@@ -205,22 +205,25 @@ Blockly.FieldLexicalVariable.prototype.getNamesInScope = function () {
...
@@ -205,22 +205,25 @@ Blockly.FieldLexicalVariable.prototype.getNamesInScope = function () {
/**
/**
* @param block
* @param block
* @returns {
list} A list of all global and lexical names in scope at the given block.
* @returns {
Array.<Array.<string>>} A list of pairs representing the translated
*
Global names are listed in sorted order before lexical names in sorted order
.
*
and untranslated name of every variable in the scope of the current block
.
*/
*/
// [lyn, 11/15/13] Refactored to work on any block
// [lyn, 11/15/13] Refactored to work on any block
Blockly
.
FieldLexicalVariable
.
getNamesInScope
=
function
(
block
)
{
Blockly
.
FieldLexicalVariable
.
getNamesInScope
=
function
(
block
)
{
var
globalNames
=
Blockly
.
FieldLexicalVariable
.
getGlobalNames
();
// from global variable declarations
var
globalNames
=
Blockly
.
FieldLexicalVariable
.
getGlobalNames
();
// from global variable declarations
// [lyn, 11/24/12] Sort and remove duplicates from namespaces
// [lyn, 11/24/12] Sort and remove duplicates from namespaces
globalNames
=
Blockly
.
LexicalVariable
.
sortAndRemoveDuplicates
(
globalNames
);
globalNames
=
Blockly
.
LexicalVariable
.
sortAndRemoveDuplicates
(
globalNames
);
globalNames
=
globalNames
.
map
(
Blockly
.
prefixGlobalMenuName
).
map
(
function
(
name
)
{
return
[
name
,
name
];
});
var
allLexicalNames
=
Blockly
.
FieldLexicalVariable
.
getLexicalNamesInScope
(
block
);
var
allLexicalNames
=
Blockly
.
FieldLexicalVariable
.
getLexicalNamesInScope
(
block
);
// Return a list of all names in scope: global names followed by lexical ones.
// Return a list of all names in scope: global names followed by lexical ones.
return
globalNames
.
map
(
Blockly
.
prefixGlobalMenuName
).
concat
(
allLexicalNames
);
return
globalNames
.
concat
(
allLexicalNames
);
}
}
/**
/**
* @param block
* @param block
* @returns {
list
} A list of all lexical names (in sorted order) in scope at the point of the given block
* @returns {
Array.<Array.<string>>
} A list of all lexical names (in sorted order) in scope at the point of the given block
* If Blockly.usePrefixInYail is true, returns names prefixed with labels like "param", "local", "index";
* If Blockly.usePrefixInYail is true, returns names prefixed with labels like "param", "local", "index";
* otherwise returns unprefixed names.
* otherwise returns unprefixed names.
*/
*/
...
@@ -257,9 +260,9 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
...
@@ -257,9 +260,9 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
for
(
i
=
0
;
i
<
params
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
params
.
length
;
i
++
)
{
rememberName
(
params
[
i
],
procedureParamNames
,
Blockly
.
procedureParameterPrefix
);
rememberName
(
params
[
i
],
procedureParamNames
,
Blockly
.
procedureParameterPrefix
);
}
}
}
else
if
(
parent
.
category
===
"
Component
"
&&
parent
.
getEventTypeObject
&&
parent
.
declaredName
s
)
{
}
else
if
(
parent
.
category
===
"
Component
"
&&
parent
.
getEventTypeObject
&&
parent
.
getParameter
s
)
{
// Parameter names in event handlers
// Parameter names in event handlers
params
=
parent
.
declaredNames
(
);
params
=
parent
.
getParameters
().
map
(
function
(
entry
)
{
return
entry
[
'
name
'
]
}
);
for
(
var
j
=
0
;
j
<
params
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
params
.
length
;
j
++
)
{
rememberName
(
params
[
j
],
handlerParamNames
,
Blockly
.
handlerParameterPrefix
);
rememberName
(
params
[
j
],
handlerParamNames
,
Blockly
.
handlerParameterPrefix
);
}
}
...
@@ -290,8 +293,7 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
...
@@ -290,8 +293,7 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
}
}
if
(
!
Blockly
.
usePrefixInYail
){
// Only a single namespace
if
(
!
Blockly
.
usePrefixInYail
){
// Only a single namespace
allLexicalNames
=
procedureParamNames
.
concat
(
handlerParamNames
)
allLexicalNames
=
procedureParamNames
.
concat
(
loopNames
)
.
concat
(
loopNames
)
.
concat
(
rangeNames
)
.
concat
(
rangeNames
)
.
concat
(
localNames
);
.
concat
(
localNames
);
allLexicalNames
=
Blockly
.
LexicalVariable
.
sortAndRemoveDuplicates
(
allLexicalNames
);
allLexicalNames
=
Blockly
.
LexicalVariable
.
sortAndRemoveDuplicates
(
allLexicalNames
);
...
@@ -306,13 +308,21 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
...
@@ -306,13 +308,21 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
// note: correctly handles case where some prefixes are the same
// note: correctly handles case where some prefixes are the same
allLexicalNames
=
allLexicalNames
=
procedureParamNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
procedureParameterPrefix
)
)
procedureParamNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
procedureParameterPrefix
)
)
.
concat
(
handlerParamNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
handlerParameterPrefix
)
))
.
concat
(
loopNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
loopParameterPrefix
)
))
.
concat
(
loopNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
loopParameterPrefix
)
))
.
concat
(
rangeNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
loopRangeParameterPrefix
)
))
.
concat
(
rangeNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
loopRangeParameterPrefix
)
))
.
concat
(
localNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
localNamePrefix
)
));
.
concat
(
localNames
.
map
(
Blockly
.
possiblyPrefixMenuNameWith
(
Blockly
.
localNamePrefix
)
));
allLexicalNames
=
Blockly
.
LexicalVariable
.
sortAndRemoveDuplicates
(
allLexicalNames
);
allLexicalNames
=
Blockly
.
LexicalVariable
.
sortAndRemoveDuplicates
(
allLexicalNames
);
}
}
return
allLexicalNames
;
return
allLexicalNames
.
map
(
function
(
name
)
{
return
[
name
,
name
]
}).
concat
(
handlerParamNames
.
map
(
function
(
name
)
{
var
translatedName
=
block
.
workspace
.
getTopWorkspace
().
getComponentDatabase
()
.
getInternationalizedParameterName
(
name
);
var
prefix
=
Blockly
.
usePrefixInYail
?
Blockly
.
handlerParameterPrefix
:
innermostPrefix
[
name
];
return
[
Blockly
.
possiblyPrefixMenuNameWith
(
prefix
)(
translatedName
),
name
];
})
);
}
}
/**
/**
...
@@ -322,15 +332,7 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
...
@@ -322,15 +332,7 @@ Blockly.FieldLexicalVariable.getLexicalNamesInScope = function (block) {
*/
*/
Blockly
.
FieldLexicalVariable
.
dropdownCreate
=
function
()
{
Blockly
.
FieldLexicalVariable
.
dropdownCreate
=
function
()
{
var
variableList
=
this
.
getNamesInScope
();
// [lyn, 11/10/12] Get all global, parameter, and local names
var
variableList
=
this
.
getNamesInScope
();
// [lyn, 11/10/12] Get all global, parameter, and local names
// Variables are not language-specific, use the name as both the user-facing
return
variableList
.
length
==
0
?
[
"
"
,
"
"
]
:
variableList
;
// text and the internal representation.
var
options
=
[];
// [lyn, 11/10/12] Ensure variable list isn't empty
if
(
variableList
.
length
==
0
)
variableList
=
[
"
"
];
for
(
var
x
=
0
;
x
<
variableList
.
length
;
x
++
)
{
options
[
x
]
=
[
variableList
[
x
],
variableList
[
x
]];
}
return
options
;
};
};
/**
/**
...
@@ -561,7 +563,15 @@ Blockly.LexicalVariable.renameParamRenamingCapturables = function (sourceBlock,
...
@@ -561,7 +563,15 @@ Blockly.LexicalVariable.renameParamRenamingCapturables = function (sourceBlock,
throw
"
Blockly.LexicalVariable.renamingCapturables: oldName
"
+
oldName
+
throw
"
Blockly.LexicalVariable.renamingCapturables: oldName
"
+
oldName
+
"
is not in declarations {
"
+
namesDeclaredHere
.
join
(
'
,
'
)
+
"
}
"
;
"
is not in declarations {
"
+
namesDeclaredHere
.
join
(
'
,
'
)
+
"
}
"
;
}
}
var
namesDeclaredAbove
=
Blockly
.
FieldLexicalVariable
.
getNamesInScope
(
sourceBlock
);
var
namesDeclaredAbove
=
[];
Blockly
.
FieldLexicalVariable
.
getNamesInScope
(
sourceBlock
)
.
map
(
function
(
pair
)
{
if
(
pair
[
0
]
==
pair
[
1
])
{
namesDeclaredAbove
.
push
(
pair
[
0
]);
}
else
{
namesDeclaredAbove
.
push
(
pair
[
0
],
pair
[
1
]);
}
});
// uses translated param names
var
declaredNames
=
namesDeclaredHere
.
concat
(
namesDeclaredAbove
);
var
declaredNames
=
namesDeclaredHere
.
concat
(
namesDeclaredAbove
);
// Should really check which forbidden names are free vars in the body of declBlock.
// Should really check which forbidden names are free vars in the body of declBlock.
if
(
declaredNames
.
indexOf
(
newName
)
!=
-
1
)
{
if
(
declaredNames
.
indexOf
(
newName
)
!=
-
1
)
{
...
@@ -890,7 +900,7 @@ Blockly.LexicalVariable.referenceResult = function (block, name, prefix, env) {
...
@@ -890,7 +900,7 @@ Blockly.LexicalVariable.referenceResult = function (block, name, prefix, env) {
}
}
// Base case: getters/setters is where all the interesting action occurs
// Base case: getters/setters is where all the interesting action occurs
if
((
block
.
type
===
"
lexical_variable_get
"
)
||
(
block
.
type
===
"
lexical_variable_set
"
))
{
if
((
block
.
type
===
"
lexical_variable_get
"
)
||
(
block
.
type
===
"
lexical_variable_set
"
))
{
var
possiblyPrefixedReferenceName
=
block
.
getField
Value
(
'
VAR
'
);
var
possiblyPrefixedReferenceName
=
block
.
getField
(
'
VAR
'
).
getText
(
);
var
unprefixedPair
=
Blockly
.
unprefixName
(
possiblyPrefixedReferenceName
);
var
unprefixedPair
=
Blockly
.
unprefixName
(
possiblyPrefixedReferenceName
);
var
referencePrefix
=
unprefixedPair
[
0
];
var
referencePrefix
=
unprefixedPair
[
0
];
var
referenceName
=
unprefixedPair
[
1
];
var
referenceName
=
unprefixedPair
[
1
];
...
@@ -918,6 +928,9 @@ Blockly.LexicalVariable.referenceResult = function (block, name, prefix, env) {
...
@@ -918,6 +928,9 @@ Blockly.LexicalVariable.referenceResult = function (block, name, prefix, env) {
capturables
.
push
(
referenceName
);
capturables
.
push
(
referenceName
);
}
}
}
}
if
(
block
.
eventparam
)
{
// also capture untranslated param names
capturables
.
push
(
block
.
eventparam
);
}
}
}
/* console.log("referenceResult from block of type " + block.type +
/* console.log("referenceResult from block of type " + block.type +
" with name " + name +
" with name " + name +
...
@@ -1043,7 +1056,7 @@ Blockly.LexicalVariable.getEventParam = function (block) {
...
@@ -1043,7 +1056,7 @@ Blockly.LexicalVariable.getEventParam = function (block) {
||
(
parent
.
type
===
"
local_declaration_statement
"
||
(
parent
.
type
===
"
local_declaration_statement
"
&&
parent
.
getInputTargetBlock
(
'
STACK
'
)
==
child
)
// only body is in scope of names
&&
parent
.
getInputTargetBlock
(
'
STACK
'
)
==
child
)
// only body is in scope of names
)
{
)
{
var
params
=
parent
.
declaredName
s
();
// [lyn, 10/13/13] Names from block, not localNames_ instance var
var
params
=
parent
.
getVar
s
();
// [lyn, 10/13/13] Names from block, not localNames_ instance var
if
(
params
.
indexOf
(
name
)
!=
-
1
)
{
if
(
params
.
indexOf
(
name
)
!=
-
1
)
{
return
null
;
// Name is locally bound, not an event parameter.
return
null
;
// Name is locally bound, not an event parameter.
}
}
...
@@ -1076,6 +1089,16 @@ Blockly.LexicalVariable.eventParamDomToMutation = function (block, xmlElement) {
...
@@ -1076,6 +1089,16 @@ Blockly.LexicalVariable.eventParamDomToMutation = function (block, xmlElement) {
if
(
childNode
.
nodeName
.
toLowerCase
()
==
'
eventparam
'
)
{
if
(
childNode
.
nodeName
.
toLowerCase
()
==
'
eventparam
'
)
{
var
untranslatedEventName
=
childNode
.
getAttribute
(
'
name
'
);
var
untranslatedEventName
=
childNode
.
getAttribute
(
'
name
'
);
block
.
eventparam
=
untranslatedEventName
;
// special property viewed by Blockly.LexicalVariable.eventParameterDict
block
.
eventparam
=
untranslatedEventName
;
// special property viewed by Blockly.LexicalVariable.eventParameterDict
if
(
!
Blockly
.
Events
.
isEnabled
()
&&
!
block
.
isInFlyout
)
{
// Loading or flyout
setTimeout
(
function
()
{
Blockly
.
Events
.
disable
();
// we don't want to save this change since it is visual
block
.
fieldVar_
.
setValue
(
untranslatedEventName
);
block
.
fieldVar_
.
setText
(
block
.
workspace
.
getTopWorkspace
().
getComponentDatabase
().
getInternationalizedParameterName
(
untranslatedEventName
));
block
.
eventparam
=
untranslatedEventName
;
block
.
workspace
.
requestErrorChecking
(
block
);
Blockly
.
Events
.
enable
();
},
0
);
}
}
}
}
}
}
}
...
...
appinventor/blocklyeditor/src/field_parameter_flydown.js
View file @
3e292608
...
@@ -92,14 +92,14 @@ Blockly.FieldParameterFlydown.prototype.flydownBlocksXML_ = function() {
...
@@ -92,14 +92,14 @@ Blockly.FieldParameterFlydown.prototype.flydownBlocksXML_ = function() {
var
getterSetterXML
=
var
getterSetterXML
=
'
<xml>
'
+
'
<xml>
'
+
'
<block type="lexical_variable_get">
'
+
mutation
+
'
<block type="lexical_variable_get">
'
+
mutation
+
'
<
title
name="VAR">
'
+
'
<
field
name="VAR">
'
+
name
+
name
+
'
</
title
>
'
+
'
</
field
>
'
+
'
</block>
'
+
'
</block>
'
+
'
<block type="lexical_variable_set">
'
+
mutation
+
'
<block type="lexical_variable_set">
'
+
mutation
+
'
<
title
name="VAR">
'
+
'
<
field
name="VAR">
'
+
name
+
name
+
'
</
title
>
'
+
'
</
field
>
'
+
'
</block>
'
+
'
</block>
'
+
'
</xml>
'
;
'
</xml>
'
;
return
getterSetterXML
;
return
getterSetterXML
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment