org.stjs.generator.check.expression
Class IdentifierGlobalScopeNameClashCheck
java.lang.Object
org.stjs.generator.check.expression.IdentifierGlobalScopeNameClashCheck
- All Implemented Interfaces:
- CheckContributor<com.sun.source.tree.IdentifierTree>, VisitorContributor<com.sun.source.tree.IdentifierTree,Void,GenerationContext<Void>,CheckVisitor>
public class IdentifierGlobalScopeNameClashCheck
- extends Object
- implements CheckContributor<com.sun.source.tree.IdentifierTree>
this class checks that you don't use in the same method variables or parameters with the same name as a global scoped
field. This is to avoid situations like this one:
void m() {
if (true) {
int x = 0;
}
int y = GlobalVars.x;
}
After generation you'll have:
function m() {
if (true) {
var x = 0;
}
var y = x;
}
The global x will be in fact hidden by the local variable.
- Author:
- acraciun
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IdentifierGlobalScopeNameClashCheck
public IdentifierGlobalScopeNameClashCheck()
checkGlobalScope
public static Void checkGlobalScope(com.sun.source.tree.ExpressionTree tree,
String name,
GenerationContext<Void> context)
visit
public Void visit(CheckVisitor visitor,
com.sun.source.tree.IdentifierTree tree,
GenerationContext<Void> context)
- Specified by:
visit in interface VisitorContributor<com.sun.source.tree.IdentifierTree,Void,GenerationContext<Void>,CheckVisitor>
Copyright © 2014. All Rights Reserved.