You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2013/01/07 16:43:51 UTC
svn commit: r1429851 - in /flex/whiteboard/mschmalle/falconjx:
compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/
compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/
Author: erikdebruin
Date: Mon Jan 7 15:43:51 2013
New Revision: 1429851
URL: http://svn.apache.org/viewvc?rev=1429851&view=rev
Log:
Adding tests and code to handle 'constant' Field Members.
Modified:
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java?rev=1429851&r1=1429850&r2=1429851&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java Mon Jan 7 15:43:51 2013
@@ -137,54 +137,49 @@ public class TestGoogFieldMembers extend
//--------------------------------------------------------------------------
@Override
- @Ignore
@Test
public void testConstant()
{
IVariableNode node = getField("static const foo;");
visitor.visitVariable(node);
- // TODO (mschmalle) is * type even possible for a constant?
- assertOut("");
+ assertOut("/**\n * @const\n * @type {*}\n */\nA.foo");
}
@Override
- @Ignore
@Test
public void testConstant_withType()
{
IVariableNode node = getField("static const foo:int;");
visitor.visitVariable(node);
- assertOut("");
+ assertOut("/**\n * @const\n * @type {number}\n */\nA.foo");
}
@Override
- @Ignore
@Test
public void testConstant_withTypeValue()
{
IVariableNode node = getField("static const foo:int = 420;");
visitor.visitVariable(node);
- assertOut("");
+ assertOut("/**\n * @const\n * @type {number}\n */\nA.foo = 420");
}
@Override
- @Ignore
@Test
public void testConstant_withNamespaceTypeValue()
{
IVariableNode node = getField("private static const foo:int = 420;");
visitor.visitVariable(node);
- assertOut("");
+ assertOut("/**\n * @private\n * @const\n * @type {number}\n */\nA.foo = 420");
}
@Override
- @Ignore
@Test
public void testConstant_withCustomNamespaceTypeValue()
{
IVariableNode node = getField("mx_internal static const foo:int = 420;");
visitor.visitVariable(node);
- assertOut("");
+ // we ignore custom namespaces completely (are there side effects I'm missing?)
+ assertOut("/**\n * @const\n * @type {number}\n */\nA.foo = 420");
}
@Override
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java?rev=1429851&r1=1429850&r2=1429851&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java Mon Jan 7 15:43:51 2013
@@ -26,8 +26,7 @@ public class JSGoogDocEmitter extends JS
@Override
public void emitConst(IVariableNode node)
{
- // TODO Auto-generated method stub
-
+ write(" * @const\n");
}
@Override
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java?rev=1429851&r1=1429850&r2=1429851&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java Mon Jan 7 15:43:51 2013
@@ -91,6 +91,9 @@ public class JSGoogEmitter extends JSEmi
getDoc().emitProtected(node);
}
+ if (node.isConst())
+ getDoc().emitConst(node);
+
getDoc().emitType(node);
getDoc().end();
@@ -220,7 +223,12 @@ public class JSGoogEmitter extends JSEmi
IClassDefinition definition = getClassDefinition(node);
emitJSDocVariable(node);
- write(definition.getQualifiedName() + ".prototype." + node.getName());
+
+ String root = "";
+ if (!node.isConst())
+ root = "prototype.";
+ write(definition.getQualifiedName() + "." + root + node.getName());
+
IExpressionNode vnode = node.getAssignedValueNode();
if (vnode != null)
{