Author: mschmalle
Date: Thu Feb 14 12:12:40 2013
New Revision: 1446140
URL: http://svn.apache.org/r1446140
Log:
Flex:FalconJx
- All AMD tests in, using test-files dir
- special compile method for allowing a main to be passed using a source folder
for deps.
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/AMDTestProjectBase.java
(with props)
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassA.java
(with props)
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassB.java
(with props)
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceI.java
(with props)
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceIOther.java
(with props)
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceISub.java
(with props)
flex/falcon/trunk/compiler.jx.tests/test-files/amd/
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/HelloWorld.as
(with props)
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/A.as
(with props)
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/B.as
(with props)
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/I.as
(with props)
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/IOther.as
(with props)
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/ISub.as
(with props)
Modified:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDPackage.java
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/amd/TempTools.java
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/AMDTestProjectBase.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/AMDTestProjectBase.java?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/AMDTestProjectBase.java
(added)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/AMDTestProjectBase.java
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,193 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.amd;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.clients.IBackend;
+import org.apache.flex.compiler.internal.as.codegen.TestWalkerBase;
+import org.apache.flex.compiler.internal.js.driver.amd.AMDBackend;
+import org.apache.flex.compiler.internal.units.SourceCompilationUnitFactory;
+import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
+import org.apache.flex.compiler.mxml.MXMLNamespaceMapping;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.apache.flex.compiler.tree.as.ITypeNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.utils.EnvProperties;
+import org.apache.flex.utils.FilenameNormalization;
+
+/**
+ * This class tests the production of AMD JavaScript for AS package.
+ *
+ * @author Michael Schmalle
+ */
+public abstract class AMDTestProjectBase extends TestWalkerBase
+{
+ private static EnvProperties env = EnvProperties.initiate();
+
+ protected IFileNode fileNode;
+
+ protected IClassNode classNode;
+
+ protected IInterfaceNode interfaceNode;
+
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ String qualifiedName = getTypeUnderTest();
+ String target = qualifiedName.replace(".", File.separator);
+
+ target = FilenameNormalization
+ .normalize("test-files/amd/simple-project/src"
+ + File.separator + target + ".as");
+
+ fileNode = compile(target);
+ ITypeNode type = (ITypeNode) findFirstDescendantOfType(fileNode,
+ ITypeNode.class);
+ if (type instanceof IClassNode)
+ classNode = (IClassNode) type;
+ else if (type instanceof IInterfaceNode)
+ interfaceNode = (IInterfaceNode) type;
+
+ }
+
+ abstract protected String getTypeUnderTest();
+
+ protected IFileNode compile(String main)
+ {
+ List<File> sourcePaths = new ArrayList<File>();
+ addSourcePaths(sourcePaths);
+ project.setSourcePath(sourcePaths);
+
+ List<File> libraries = new ArrayList<File>();
+ libraries.add(new File(FilenameNormalization.normalize(env.FPSDK
+ + "\\11.1\\playerglobal.swc")));
+
+ addLibrary(libraries);
+ project.setLibraries(libraries);
+
+ // Use the MXML 2009 manifest.
+ List<IMXMLNamespaceMapping> namespaceMappings = new
ArrayList<IMXMLNamespaceMapping>();
+ IMXMLNamespaceMapping mxml2009 = new MXMLNamespaceMapping(
+ "http://ns.adobe.com/mxml/2009", env.SDK
+ + "\\frameworks\\mxml-2009-manifest.xml");
+ namespaceMappings.add(mxml2009);
+ project.setNamespaceMappings(namespaceMappings);
+
+ ICompilationUnit cu = null;
+ String normalizedMainFileName = FilenameNormalization.normalize(main);
+
+ SourceCompilationUnitFactory compilationUnitFactory = project
+ .getSourceCompilationUnitFactory();
+ File normalizedMainFile = new File(normalizedMainFileName);
+ if
(compilationUnitFactory.canCreateCompilationUnit(normalizedMainFile))
+ {
+ Collection<ICompilationUnit> mainFileCompilationUnits = workspace
+ .getCompilationUnits(normalizedMainFileName, project);
+ for (ICompilationUnit cu2 : mainFileCompilationUnits)
+ {
+ if (cu2 != null)
+ cu = cu2;
+ }
+ }
+
+ IFileNode fileNode = null;
+ try
+ {
+ fileNode = (IFileNode) cu.getSyntaxTreeRequest().get().getAST();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+
+ return fileNode;
+ }
+
+ @Override
+ protected void addSourcePaths(List<File> sourcePaths)
+ {
+ super.addSourcePaths(sourcePaths);
+ sourcePaths.add(new File(FilenameNormalization
+ .normalize("test-files/amd/simple-project/src")));
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new AMDBackend();
+ }
+
+ protected IVariableNode findField(String name, IClassNode node)
+ {
+ IDefinitionNode[] nodes = node.getAllMemberNodes();
+ for (IDefinitionNode inode : nodes)
+ {
+ if (inode.getName().equals(name))
+ return (IVariableNode) inode;
+ }
+ return null;
+ }
+
+ protected IFunctionNode findFunction(String name, IClassNode node)
+ {
+ IDefinitionNode[] nodes = node.getAllMemberNodes();
+ for (IDefinitionNode inode : nodes)
+ {
+ if (inode.getName().equals(name))
+ return (IFunctionNode) inode;
+ }
+ return null;
+ }
+
+ protected IGetterNode findGetter(String name, IClassNode node)
+ {
+ IDefinitionNode[] nodes = node.getAllMemberNodes();
+ for (IDefinitionNode inode : nodes)
+ {
+ if (inode.getName().equals(name) && inode instanceof IGetterNode)
+ return (IGetterNode) inode;
+ }
+ return null;
+ }
+
+ protected ISetterNode findSetter(String name, IClassNode node)
+ {
+ IDefinitionNode[] nodes = node.getAllMemberNodes();
+ for (IDefinitionNode inode : nodes)
+ {
+ if (inode.getName().equals(name) && inode instanceof ISetterNode)
+ return (ISetterNode) inode;
+ }
+ return null;
+ }
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/AMDTestProjectBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassA.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassA.java?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassA.java
(added)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassA.java
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,178 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.amd;
+
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of AMD JavaScript for the test project,
class
+ * A.
+ *
+ * @author Michael Schmalle
+ */
+public class TestAMDClassA extends AMDTestProjectBase
+{
+ // !!! the errors have to do with how I change 'this' on member expressions
+
+
//--------------------------------------------------------------------------
+ // Class A
+
//--------------------------------------------------------------------------
+
+ @Test
+ public void test_field_msg()
+ {
+ IVariableNode vnode = findField("_msg", classNode);
+ visitor.visitVariable(vnode);
+ assertOut("_msg$1: {\n\tvalue:0,\n\twritable:true\n}");
+ }
+
+ @Test
+ public void test_constructor()
+ {
+ IFunctionNode vnode = findFunction("A", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("function A(msg) {\n\tthis.msg = msg;\n}");
+ }
+
+ @Test
+ public void test_get_msg()
+ {
+ IGetterNode node = findGetter("msg", classNode);
+ visitor.visitGetter(node);
+ assertOut("msg: {\n\tget: function msg$get() {\n\t\treturn
String(this._msg$1);\n\t},"
+ + "\n\tset: function msg$set(value) {\n\t\tthis._msg$1 =
parseInt(value, 10);\n\t}\n}");
+ }
+
+ @Test
+ public void test_set_msg()
+ {
+ ISetterNode node = findSetter("msg", classNode);
+ visitor.visitSetter(node);
+ assertOut("msg: {\n\tget: function msg$get() {\n\t\treturn
String(this._msg$1);\n\t},"
+ + "\n\tset: function msg$set(value) {\n\t\tthis._msg$1 =
parseInt(value, 10);\n\t}\n}");
+ }
+
+ @Test
+ public void test_secret()
+ {
+ IFunctionNode vnode = findFunction("secret", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("secret$1: function secret(n) {\n\treturn this.msg + n;\n}");
+ }
+
+ @Test
+ public void test_foo()
+ {
+ IFunctionNode vnode = findFunction("foo", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("foo: function foo(x) {\n\treturn
this.secret$1(A.bar(x));\n}");
+ }
+
+ @Test
+ public void test_baz()
+ {
+ IFunctionNode vnode = findFunction("baz", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("baz: function baz() {\n\tvar tmp = AS3.bind(this, "
+ + "\"secret$1\");\n\treturn tmp(\"-bound\");\n}");
+ }
+
+ @Test
+ public void test_bar()
+ {
+ IFunctionNode vnode = findFunction("bar", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("bar: function bar(x) {\n\treturn x + 1;\n}");
+ }
+
+ @Test
+ public void test_file()
+ {
+ // not going to put this test production in until everything is
concrete and agreed upon
+ visitor.visitFile(fileNode);
+ //assertOut("");
+ }
+
+ @Override
+ protected String getTypeUnderTest()
+ {
+ return "com.acme.A";
+ }
+}
+
+/*
+
+--------------------------------------------------------------------------------
+02-07-2013
+Current Production of visitFile()
+--------------------------------------------------------------------------------
+
+define(["exports", "runtime/AS3", "classes/I", "classes/String",
"classes/parseInt", "classes/trace"], function($exports, AS3, I, String,
parseInt, trace) {
+ "use strict";
+ AS3.compilationUnit($exports, function($primaryDeclaration){
+ function A(msg) {
+ this.msg = msg;
+ }
+ $primaryDeclaration(AS3.class_({
+ package_: "com.acme",
+ class_: "A",
+ implements_: [
+ I
+ ],
+ members: {
+ constructor: A,
+ _msg$1: {
+ value:0,
+ writable:true
+ },
+ msg: {
+ get: function msg$get() {
+ return String(this._msg$1);
+ },
+ set: function msg$set(value) {
+ this._msg$1 = parseInt(value, 10);
+ }
+ },
+ secret$1: function secret(n) {
+ return this.msg + n;
+ },
+ foo: function foo(x) {
+ return this.secret$1(A.bar(x));
+ },
+ baz: function baz() {
+ var tmp = AS3.bind(this, "secret$1");
+ return tmp("-bound");
+ }
+ },
+ staticMembers: {
+ bar: function bar(x) {
+ return x + 1;
+ }
+ }
+ }));
+ trace("Class A is initialized!");
+ });
+});
+
+*/
Propchange:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassA.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassB.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassB.java?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassB.java
(added)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassB.java
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,93 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.amd;
+
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of AMD JavaScript for the test project,
class
+ * B.
+ *
+ * @author Michael Schmalle
+ */
+public class TestAMDClassB extends AMDTestProjectBase
+{
+
//--------------------------------------------------------------------------
+ // Class B
+
//--------------------------------------------------------------------------
+
+ @Test
+ public void test_nowPlusOne()
+ {
+ IFunctionNode vnode = findFunction("nowPlusOne", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("nowPlusOne: function nowPlusOne() {\n\treturn new
Date(B.now.getTime() + 60 * 60 * 1000);\n}");
+ }
+
+ @Test
+ public void test_constructor()
+ {
+ IFunctionNode vnode = findFunction("B", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("function B(msg, count) {\n\tthis.barfoo = (A._ ||
A._$get()).bar(3);" +
+ "\n\tSuper.call(this, msg);\n\tthis.count =
count;\n\ttrace(\"now: \" + B.now);\n}");
+ }
+
+ @Test
+ public void test_count()
+ {
+ IVariableNode node = findField("count", classNode);
+ visitor.visitVariable(node);
+ assertOut("count: {\n\tvalue:0,\n\twritable:true\n}");
+ }
+
+ @Test
+ public void test_override_foo()
+ {
+ IFunctionNode vnode = findFunction("foo", classNode);
+ visitor.visitFunction(vnode);
+ assertOut("foo: function foo(x) {\n\treturn this.foo$2(x + 2) +
\"-sub\";\n}");
+ }
+
+ @Test
+ public void test_now()
+ {
+ IVariableNode node = findField("now", classNode);
+ visitor.visitVariable(node);
+ assertOut("B.now = new Date()");
+ }
+
+ @Test
+ public void test_file()
+ {
+ // not going to put this test production in until everything is
concrete and agreed upon
+ visitor.visitFile(fileNode);
+ //assertOut("");
+ }
+
+ @Override
+ protected String getTypeUnderTest()
+ {
+ return "com.acme.B";
+ }
+
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDClassB.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java?rev=1446140&r1=1446139&r2=1446140&view=diff
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java
(original)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java
Thu Feb 14 12:12:40 2013
@@ -38,7 +38,7 @@ import org.junit.Test;
public class TestAMDEmiter extends TestWalkerBase
{
@Ignore
- @Test
+ @Test
public void testSimple()
{
String code = "package com.example.components {"
@@ -54,6 +54,7 @@ public class TestAMDEmiter extends TestW
assertOut("package com.example.components {\n\tpublic class
MyTextButton extends TextButton {\n\t\tcom.example.components.MyTextButton =
function() {\n\t\t\tif (foo() != 42)
{\n\t\t\t\tbar();\n\t\t\t}\n\t\t}\n\t\tprivate var _privateVar:String = \"do
\";\n\t\tpublic var publicProperty:Number =
100;\n\t\tcom.example.components.MyTextButton.prototype.myFunction =
function(value) {\n\t\t\treturn \"Don't \" + _privateVar +
value;\n\t\t}\n\t}\n}");
}
+ @Ignore
@Test
public void testSimpleMethod()
{
@@ -62,6 +63,7 @@ public class TestAMDEmiter extends TestW
assertOut("A.prototype.method1 = function() {\n}");
}
+ @Ignore
@Test
public void testSimpleParameterReturnType()
{
@@ -70,6 +72,7 @@ public class TestAMDEmiter extends TestW
assertOut("A.prototype.method1 = function(bar) {\n}");
}
+ @Ignore
@Test
public void testSimpleMultipleParameter()
{
@@ -78,6 +81,7 @@ public class TestAMDEmiter extends TestW
assertOut("A.prototype.method1 = function(bar, baz, goo) {\n}");
}
+ @Ignore
@Test
public void testDefaultParameter()
{
@@ -99,6 +103,7 @@ public class TestAMDEmiter extends TestW
+ "\n\treturn p1 + p2 + p3 + p4;\n}");
}
+ @Ignore
@Test
public void testDefaultParameter_Body()
{
@@ -119,6 +124,7 @@ public class TestAMDEmiter extends TestW
+ "if (a)\n\t\tfoo();\n}");
}
+ @Ignore
@Test
public void testDefaultParameter_NoBody_Alternate()
{
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceI.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceI.java?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceI.java
(added)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceI.java
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,50 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.amd;
+
+import org.junit.Test;
+
+/**
+ * This class tests the production of AMD JavaScript for the test project,
+ * interface I.
+ *
+ * @author Michael Schmalle
+ */
+public class TestAMDInterfaceI extends AMDTestProjectBase
+{
+
//--------------------------------------------------------------------------
+ // Interface I
+
//--------------------------------------------------------------------------
+
+ @Test
+ public void test_file()
+ {
+ visitor.visitFile(fileNode);
+ assertOut("define([\"exports\", \"runtime/AS3\"], function($exports,
AS3) {" +
+ "\n\t\"use strict\"; \n\tAS3.interface_($exports,
{\n\t\tpackage_: " +
+ "\"com.acme\",\n\t\tinterface_: \"I\"\n\t});\n});");
+ }
+
+ @Override
+ protected String getTypeUnderTest()
+ {
+ return "com.acme.I";
+ }
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceI.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceIOther.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceIOther.java?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceIOther.java
(added)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceIOther.java
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,50 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.amd;
+
+import org.junit.Test;
+
+/**
+ * This class tests the production of AMD JavaScript for the test project,
+ * interface com.acme.sub.IOther.
+ *
+ * @author Michael Schmalle
+ */
+public class TestAMDInterfaceIOther extends AMDTestProjectBase
+{
+
//--------------------------------------------------------------------------
+ // Interface IOther
+
//--------------------------------------------------------------------------
+
+ @Test
+ public void test_file()
+ {
+ visitor.visitFile(fileNode);
+ assertOut("define([\"exports\", \"runtime/AS3\"], function($exports,
AS3) {" +
+ "\n\t\"use strict\"; \n\tAS3.interface_($exports,
{\n\t\tpackage_: " +
+ "\"com.acme.sub\",\n\t\tinterface_:
\"IOther\"\n\t});\n});");
+ }
+
+ @Override
+ protected String getTypeUnderTest()
+ {
+ return "com.acme.sub.IOther";
+ }
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceIOther.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceISub.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceISub.java?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceISub.java
(added)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceISub.java
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.amd;
+
+import org.junit.Test;
+
+/**
+ * This class tests the production of AMD JavaScript for the test project,
+ * interface com.acme.sub.ISub.
+ *
+ * @author Michael Schmalle
+ */
+public class TestAMDInterfaceISub extends AMDTestProjectBase
+{
+
//--------------------------------------------------------------------------
+ // Interface ISub
+
//--------------------------------------------------------------------------
+
+ @Test
+ public void test_file()
+ {
+ visitor.visitFile(fileNode);
+ assertOut("define([\"exports\", \"runtime/AS3\",
\"classes/com/acme/I\"], " +
+ "function($exports, AS3, I) {\n\t\"use strict\";
\n\tAS3.interface_($exports, {" +
+ "\n\t\tpackage_: \"com.acme.sub\",\n\t\tinterface_:
\"ISub\"\n\t\textends_: " +
+ "[\n\t\t\tI\n\t\t]\n\t});\n});");
+ }
+
+ @Override
+ protected String getTypeUnderTest()
+ {
+ return "com.acme.sub.ISub";
+ }
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDInterfaceISub.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDPackage.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDPackage.java?rev=1446140&r1=1446139&r2=1446140&view=diff
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDPackage.java
(original)
+++
flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDPackage.java
Thu Feb 14 12:12:40 2013
@@ -19,10 +19,14 @@
package org.apache.flex.compiler.internal.js.codegen.amd;
+import java.io.IOException;
+
import org.apache.flex.compiler.clients.IBackend;
import org.apache.flex.compiler.internal.as.codegen.TestPackage;
import org.apache.flex.compiler.internal.js.driver.amd.AMDBackend;
import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -32,42 +36,6 @@ import org.junit.Test;
*/
public class TestAMDPackage extends TestPackage
{
- /*
- * $0 = defineClass|defineInterface
- * $1 = "./I", "as3/trace", "as3/bind"
- * $2 = I, trace, bind_
- *
- *
-define(["exports", "runtime/AS3", $1],
- function($0, $2) {
- "use strict";
-
- // constructor
- function A(arg/~:String~/) {
- A.$$ && A.$$(); // execute static code once on first usage
-L# this.msg = msg;
- }
-
- // private method
- function secret(n) {
-L# return this.msg + n; // add 'this'
- }
-
- return definedClass(A, { implements_: I,
- members: {
- }
- },
-
- staticMembers: {
- },
-
- staticCode: function() {
-
- }
- });
-
- });
- */
@Override
@Test
@@ -75,7 +43,7 @@ L# return this.msg + n; // add 'thi
{
IFileNode node = getFileNode("package{}");
visitor.visitFile(node);
- assertOut("define();");
+ assertOut("");
}
@Override
@@ -84,7 +52,7 @@ L# return this.msg + n; // add 'thi
{
IFileNode node = getFileNode("package foo {}");
visitor.visitFile(node);
- assertOut("define();");
+ assertOut("");
}
@Override
@@ -93,7 +61,7 @@ L# return this.msg + n; // add 'thi
{
IFileNode node = getFileNode("package foo.bar.baz {}");
visitor.visitFile(node);
- assertOut("define();");
+ assertOut("");
}
@Override
@@ -102,11 +70,13 @@ L# return this.msg + n; // add 'thi
{
IFileNode node = getFileNode("package {public class A{}}");
visitor.visitFile(node);
- String code = writer.toString();
- assertOut("define([\"exports\", \"AS3\"], function($exports, AS3) {" +
- "\n\t\"use strict\"; AS3.class_($exports,\n\tfunction()
{" +
- "\n\t\tvar Super=Object._;\n\t\tvar
super$=Super.prototype;\n\t\t" +
- "return {\n\t\t\tclass_: \"A\",\n\t\t\textends_:
Super\n\t\t};\n\t});\n});");
+ //assertOut("");
+ }
+
+ @Ignore
+ @Test
+ public void testPackageSimple_TestA() throws IOException
+ {
}
@Override
@@ -136,9 +106,23 @@ L# return this.msg + n; // add 'thi
//assertOut("");
}
+ //@Test
+ public void testMethod()
+ {
+ IFunctionNode node = getMethod("function foo(){}");
+ visitor.visitFunction(node);
+ assertOut("A.prototype.foo = function() {\n}");
+ }
+
@Override
protected IBackend createBackend()
{
return new AMDBackend();
}
+
+ protected IFileNode getFile(String code)
+ {
+ IFileNode node = getFileNode(code);
+ return node;
+ }
}
Added:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/HelloWorld.as
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/HelloWorld.as?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/HelloWorld.as
(added)
+++
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/HelloWorld.as
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package {
+
+import com.acme.A;
+import com.acme.B;
+import com.acme.I;
+import com.acme.sub.IOther;
+import com.acme.sub.ISub;
+
+//noinspection JSUnusedGlobalSymbols
+public class HelloWorld {
+
+ //noinspection JSUnusedGlobalSymbols
+ public function HelloWorld() {
+ trace(B.now);
+ trace(B.nowPlusOne());
+
+ var b:B = new B('hello ');
+ trace("b = new B('hello '):", b);
+ trace("b.foo(3):", b.foo(3));
+ trace("b.baz():", b.baz());
+ trace("b is A:", b is A);
+ trace("b is B:", b is B);
+ trace("b is I:", b is I);
+ trace("b is ISub:", b is ISub);
+ trace("b is IOther:", b is IOther);
+
+ var a:A = new A('123');
+ trace("a = new A('123'):", a);
+ trace("a is A:", a is A);
+ trace("a is B:", a is B);
+ trace("a is I:", a is I);
+ trace("a is ISub:", a is ISub);
+ trace("a is IOther:", a is IOther);
+ }
+}
+}
\ No newline at end of file
Propchange:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/HelloWorld.as
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/A.as
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/A.as?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/A.as
(added)
+++
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/A.as
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme {
+public class A implements I {
+
+ public function A(msg:String) {
+ this.msg = msg;
+ }
+
+ private var _msg:int;
+
+ public function get msg():String {
+ return String(this._msg);
+ }
+
+ trace("Class A is initialized!");
+
+ public function set msg(value:String):void {
+ this._msg = parseInt(value, 10);
+ }
+
+ private function secret(n) {
+ return msg + n;
+ }
+
+ public function foo(x) {
+ return this.secret(A.bar(x));
+ }
+
+ public function baz() {
+ var tmp = this.secret;
+ return tmp("-bound");
+ }
+
+ public static function bar(x) {
+ return x + 1;
+ }
+
+}
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/A.as
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/B.as
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/B.as?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/B.as
(added)
+++
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/B.as
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme {
+import com.acme.sub.IOther;
+import com.acme.sub.ISub;
+
+public class B extends A implements IOther, ISub {
+
+ public static function nowPlusOne() {
+ return new Date(B.now.getTime() + 60*60*1000);
+ }
+
+ public function B(msg, count) {
+ super(msg);
+ this.count = count;
+ trace("now: " + B.now);
+ }
+
+ public var count = 0;
+
+ public var barfoo = A.bar(3);
+
+ public override function foo(x) {
+ return super.foo(x + 2) + "-sub";
+ }
+
+ public static var now = new Date();
+
+}
+}
Propchange:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/B.as
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/I.as
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/I.as?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/I.as
(added)
+++
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/I.as
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme {
+public interface I {
+
+ function get msg():String;
+
+}
+}
\ No newline at end of file
Propchange:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/I.as
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/IOther.as
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/IOther.as?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/IOther.as
(added)
+++
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/IOther.as
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,25 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme.sub {
+
+public interface IOther {
+
+}
+}
\ No newline at end of file
Propchange:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/IOther.as
------------------------------------------------------------------------------
svn:eol-style = native
Added:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/ISub.as
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/ISub.as?rev=1446140&view=auto
==============================================================================
---
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/ISub.as
(added)
+++
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/ISub.as
Thu Feb 14 12:12:40 2013
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme.sub {
+import com.acme.I;
+
+public interface ISub extends I {
+
+ function foo(x);
+
+}
+}
\ No newline at end of file
Propchange:
flex/falcon/trunk/compiler.jx.tests/test-files/amd/simple-project/src/com/acme/sub/ISub.as
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/amd/TempTools.java
URL:
http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/amd/TempTools.java?rev=1446140&r1=1446139&r2=1446140&view=diff
==============================================================================
---
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/amd/TempTools.java
(original)
+++
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/amd/TempTools.java
Thu Feb 14 12:12:40 2013
@@ -431,4 +431,21 @@ public class TempTools
}
return null;
}
+
+ public static String toPackageName(String name)
+ {
+ if (!name.contains("."))
+ return name;
+ final String stem = name.substring(0, name.lastIndexOf("."));
+ return stem;
+ }
+
+ public static String toBaseName(String name)
+ {
+ if (!name.contains("."))
+ return name;
+ final String basename = name.substring(name.lastIndexOf(".") + 1);
+ return basename;
+ }
+
}