You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ft...@apache.org on 2015/06/27 19:21:47 UTC
[1/2] git commit: [flex-falcon] [refs/heads/develop] - Added jasmine
externs
Repository: flex-falcon
Updated Branches:
refs/heads/develop 62f22aa47 -> 9775608ba
Added jasmine externs
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/83664d7a
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/83664d7a
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/83664d7a
Branch: refs/heads/develop
Commit: 83664d7ad848f35282cdb16d78ff67c1714e4bae
Parents: 62f22aa
Author: Frédéric THOMAS <we...@gmail.com>
Authored: Sat Jun 27 17:42:09 2015 +0100
Committer: Frédéric THOMAS <we...@gmail.com>
Committed: Sat Jun 27 18:20:22 2015 +0100
----------------------------------------------------------------------
.gitignore | 1 +
build.xml | 29 +++++++-
compiler.jx/downloads.xml | 2 +
externs/jasmine/compile-config.xml | 92 +++++++++++++++++++++++++
externs/jasmine/jasmine-compile-config.xml | 39 +++++++++++
5 files changed, 161 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/83664d7a/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 7be0a50..aa3a5d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@ swfutils/
# files copied from google closure compiler
externs/js/externs
externs/jquery/externs
+externs/jasmine/externs
# debugger output folders
debugger/bin/
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/83664d7a/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 82c173b..99a403d 100644
--- a/build.xml
+++ b/build.xml
@@ -539,8 +539,8 @@
</target>
- <target name="extern.swcs" depends="externc.js.swc, externc.jquery.swc" />
- <target name="extern.swcs.clean" depends="externc.js.swc.clean, externc.jquery.swc.clean" />
+ <target name="extern.swcs" depends="externc.js.swc, externc.jquery.swc, externc.jasmine.swc" />
+ <target name="extern.swcs.clean" depends="externc.js.swc.clean, externc.jquery.swc.clean, externc.jasmine.swc.clean" />
<target name="extern.swcs.wipe" depends="extern.swcs.clean" >
<delete failonerror="false" includeEmptyDirs="true" >
<fileset dir="${basedir}/externs/js">
@@ -553,6 +553,11 @@
<include name="**/*.js"/>
</fileset>
</delete>
+ <delete failonerror="false" includeEmptyDirs="true" >
+ <fileset dir="${basedir}/externs/jasmine">
+ <include name="**/*.js"/>
+ </fileset>
+ </delete>
</target>
<target name="externc.js.swc.clean" >
@@ -561,6 +566,9 @@
<target name="externc.jquery.swc.clean" >
<delete dir="${basedir}/externs/jquery/out" failonerror="false" includeEmptyDirs="true"/>
</target>
+ <target name="externc.jasmine.swc.clean" >
+ <delete dir="${basedir}/externs/jasmine/out" failonerror="false" includeEmptyDirs="true"/>
+ </target>
<target name="externc.js.swc" >
<echo>${env.ASJS_HOME}</echo>
@@ -595,6 +603,23 @@
<arg value="-output=${basedir}/externs/jquery/out/bin/jquery-1.9.swc" />
</java>
</target>
+
+ <target name="externc.jasmine.swc" >
+ <echo>${env.ASJS_HOME}</echo>
+ <!--<java jar="${basedir}/compiler.jx/lib/externc.jar" fork="true"
+ failonerror="false">
+ <arg value="+flexlib=${env.ASJS_HOME}/frameworks" />
+ <arg value="-debug" />
+ <arg value="-load-config=${basedir}/externs/jasmine/jasmine-compile-config.xml" />
+ </java>-->
+ <java jar="${basedir}/compiler/generated/dist/sdk/lib/falcon-compc.jar" fork="true"
+ failonerror="true">
+ <arg value="+flexlib=${env.ASJS_HOME}/frameworks" />
+ <arg value="-debug" />
+ <arg value="-load-config=${basedir}/externs/jasmine/compile-config.xml" />
+ <arg value="-output=${basedir}/externs/jasmine/out/bin/jasmine-2.0.swc" />
+ </java>
+ </target>
<target name="binary-package"
description="Package binary files in zip and tar-gzip file.">
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/83664d7a/compiler.jx/downloads.xml
----------------------------------------------------------------------
diff --git a/compiler.jx/downloads.xml b/compiler.jx/downloads.xml
index 55d8e2d..2ebcb6f 100644
--- a/compiler.jx/downloads.xml
+++ b/compiler.jx/downloads.xml
@@ -251,9 +251,11 @@
</unjar>
<mkdir dir="${basedir}/../externs/js/externs" />
<mkdir dir="${basedir}/../externs/jquery/externs" />
+ <mkdir dir="${basedir}/../externs/jasmine/externs" />
<unzip src="${download.dir}/temp/externs/externs.zip" dest="${basedir}/../externs/js/externs" />
<get src="https://closureidl.googlecode.com/files/svg.js" dest="${basedir}/../externs/js/externs/svg.js"/>
<get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.9.js" dest="${basedir}/../externs/jquery/externs/jquery-1.9.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jasmine-2.0.js" dest="${basedir}/../externs/jasmine/externs/jasmine-2.0.js"/>
</target>
<target name="download-dependency-jar" if="project.download.jar" description="Downloads a jar to the lib directory.">
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/83664d7a/externs/jasmine/compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/jasmine/compile-config.xml b/externs/jasmine/compile-config.xml
new file mode 100644
index 0000000..abf867e
--- /dev/null
+++ b/externs/jasmine/compile-config.xml
@@ -0,0 +1,92 @@
+<!--
+
+ 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.
+
+-->
+<flex-config>
+
+ <compiler>
+ <accessible>true</accessible>
+
+ <!--
+ <external-library-path>
+ <path-element>${env.PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc</path-element>
+ <path-element>../../libs/framework.swc</path-element>
+ <path-element>../../libs/mx/mx.swc</path-element>
+ <path-element>../../libs/osmf.swc</path-element>
+ <path-element>../../libs/textLayout.swc</path-element>
+ </external-library-path>
+
+ <keep-as3-metadata>
+ <name>SkinPart</name>
+ </keep-as3-metadata>
+
+ <mxml>
+ <minimum-supported-version>4.0.0</minimum-supported-version>
+ </mxml>
+
+ <locale/>
+
+ <library-path/>
+
+ <namespaces>
+ <namespace>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ <manifest>manifest.xml</manifest>
+ </namespace>
+ </namespaces>
+ -->
+
+ <external-library-path>
+ <path-element>../js/out/bin/js.swc</path-element>
+ </external-library-path>
+
+ <source-path>
+ <path-element>out/as/classes</path-element>
+ <path-element>out/as/functions</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+ </compiler>
+
+ <include-sources>
+ <path-element>out/as/classes</path-element>
+ <path-element>out/as/functions</path-element>
+ </include-sources>
+
+ <!--
+ <include-file>
+ <name>defaults.css</name>
+ <path>defaults.css</path>
+ </include-file>
+ <include-file>
+ <name>assets/ErrorIndicator.png</name>
+ <path>assets/ErrorIndicator.png</path>
+ </include-file>
+ <include-file>
+ <name>assets/RequiredIndicator.png</name>
+ <path>assets/RequiredIndicator.png</path>
+ </include-file>
+
+ <include-namespaces>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ </include-namespaces>
+
+ <resource-bundle-list>bundles.properties</resource-bundle-list>
+
+ <target-player>${playerglobal.version}</target-player>
+ -->
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/83664d7a/externs/jasmine/jasmine-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/jasmine/jasmine-compile-config.xml b/externs/jasmine/jasmine-compile-config.xml
new file mode 100644
index 0000000..94d5bf2
--- /dev/null
+++ b/externs/jasmine/jasmine-compile-config.xml
@@ -0,0 +1,39 @@
+<!--
+
+ 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</name></exclude> 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.
+
+-->
+<flex-config>
+
+ <compiler>
+ <accessible>true</accessible>
+
+ <locale/>
+
+ <source-path>
+ <path-element>src</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+ </compiler>
+
+ <external>
+ <path-element>externs/jasmine-2.0.js</path-element>
+ </external>
+
+ <as-root>out/as</as-root>
+
+</flex-config>
[2/2] git commit: [flex-falcon] [refs/heads/develop] - Fix: EXTERNC -
IMPORT NOT EMITTED
Posted by ft...@apache.org.
Fix: EXTERNC - IMPORT NOT EMITTED
Imports relative to some function return type
are now emitted only if either the static member or the
return type class are not excluded.
This includes that:
Given a function A():ns.ReturnType
And A is not excluded
And ns.ReturnType is not excluded
Then the import of ns.ReturnType will occur.
Given a function A():ns.ReturnType
And A is not excluded
And ns.ReturnType is excluded
Then the import of ns.ReturnType will NOT occur.
Given a function A():ns.ReturnType
And A is excluded
And ns.ReturnType is not excluded
Then the import of ns.ReturnType will NOT occur.
Given a function A():ns.ReturnType
And B():ns.ReturnType
And B is excluded
And ns.ReturnType is not excluded
Then the import of ns.ReturnType still occur.
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/9775608b
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/9775608b
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/9775608b
Branch: refs/heads/develop
Commit: 9775608bab4674b8ff54ed86ed01c9135443939c
Parents: 83664d7
Author: Frédéric THOMAS <we...@gmail.com>
Authored: Sat Jun 27 18:07:19 2015 +0100
Committer: Frédéric THOMAS <we...@gmail.com>
Committed: Sat Jun 27 18:20:25 2015 +0100
----------------------------------------------------------------------
.../codegen/externals/ExternalsTestUtils.java | 3 +
.../codegen/externals/TestExternJasmine.java | 83 ++++++++++++++++++++
.../externals/reference/ClassReference.java | 50 +++++++++---
3 files changed, 123 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9775608b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
index 8cdca1b..b6989bc 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
@@ -37,6 +37,9 @@ public class ExternalsTestUtils
public static File EXTERNAL_JS_DIR = FilenameNormalization.normalize(new File(
"../externs/js/externs"));
+ public static File EXTERNAL_JASMINE_DIR = FilenameNormalization.normalize(new File(
+ "../externs/jasmine/externs"));
+
public static File AS_ROOT_DIR = new File(TEMP_DIR, "externals/as");
public static void addTestExcludesFull(ExternCConfiguration config)
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9775608b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
new file mode 100644
index 0000000..fdfd3ce
--- /dev/null
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
@@ -0,0 +1,83 @@
+/*
+ *
+ * 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.codegen.externals;
+
+import com.google.javascript.jscomp.Result;
+import org.apache.flex.compiler.clients.ExternCConfiguration;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.*;
+
+public class TestExternJasmine extends ExternalsTestBase
+{
+ @Test
+ public void test_classes() throws IOException
+ {
+ client.cleanOutput();
+ Result result = compile();
+ assertTrue(result.success);
+
+ String[] classes = {
+ "jasmine",
+ "jasmine.Clock"};
+
+ assertEquals(9, model.getClasses().size());
+ for (String className : classes)
+ {
+ assertTrue(model.hasClass(className));
+ }
+
+ client.emit();
+ }
+
+ @Test
+ public void test_members() throws IOException
+ {
+ client.cleanOutput();
+ Result result = compile();
+ assertTrue(result.success);
+
+ // jasmine
+ ClassReference jasmine = model.getClassReference("jasmine");
+ assertNotNull(jasmine);
+
+ assertTrue(jasmine.hasStaticMethod("clock"));
+ assertEquals("jasmine.Clock", jasmine.getMethod("clock").toReturnTypeAnnotationString());
+
+ assertTrue(jasmine.hasImport("jasmine.Clock"));
+
+ //Clock
+ ClassReference Clock = model.getClassReference("jasmine.Clock");
+ assertNotNull(Clock);
+ }
+
+ @Override
+ protected void configure(ExternCConfiguration install) throws IOException
+ {
+ config.setASRoot(ExternalsTestUtils.AS_ROOT_DIR);
+
+ String coreRoot = ExternalsTestUtils.EXTERNAL_JASMINE_DIR.getAbsolutePath();
+ config.addExternal(coreRoot + "/jasmine-2.0.js");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9775608b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
index d74684a..dfaf0a6 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
@@ -19,29 +19,24 @@
package org.apache.flex.compiler.internal.codegen.externals.reference;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;
-import org.apache.flex.compiler.internal.codegen.externals.utils.JSTypeUtils;
-
import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.JSDocInfoBuilder;
import com.google.javascript.rhino.JSTypeExpression;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.jstype.JSType;
+import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;
+import org.apache.flex.compiler.internal.codegen.externals.utils.JSTypeUtils;
+
+import java.io.File;
+import java.util.*;
+import java.util.Map.Entry;
public class ClassReference extends BaseReference
{
private boolean isFinal;
private int enumConstantCounter = 0;
- private List<String> imports = new ArrayList<String>();
+ private Set<String> imports = new HashSet<String>();
private MethodReference constructor;
private Map<String, FieldReference> fields = new HashMap<String, FieldReference>();
private Map<String, MethodReference> methods = new HashMap<String, MethodReference>();
@@ -121,7 +116,6 @@ public class ClassReference extends BaseReference
* @param node (FUNCTION [NAME, PARAM_LIST, BLOCK]), or (ASSIGN [FUNCTION
* [NAME, PARAM_LIST, BLOCK]])
* @param qualfiedName
- * @param comment
*/
public ClassReference(ReferenceModel model, Node node, String qualfiedName)
{
@@ -509,10 +503,35 @@ public class ClassReference extends BaseReference
MethodReference method = new MethodReference(getModel(), this, node,
functionName, comment, isStatic);
+
+ final String returnType = getReturnType(method);
+ if (returnType != null)
+ {
+ addImport(returnType);
+ }
+
methods.put(functionName, method);
return method;
}
+ private String getReturnType(final MethodReference method) {
+ String returnType = null;
+
+ final JSDocInfo comment = method.getComment();
+ if (method.isExcluded() == null && comment != null && comment.hasReturnType())
+ {
+ try {
+ final Node firstChild = comment.getReturnType().getRoot().getFirstChild();
+ returnType = firstChild.getString();
+ final ClassReference reference = new ClassReference(null, method.getNode(), returnType);
+ returnType = returnType.contains(".") ? getModel().isExcludedClass(reference) == null ? returnType : null : null;
+ } catch (Exception e) {
+ returnType = null;
+ }
+ }
+ return returnType;
+ }
+
public boolean isMethodOverrideFromInterface(MethodReference reference)
{
if (!hasImplementations())
@@ -614,6 +633,11 @@ public class ClassReference extends BaseReference
imports.add(qualifiedName);
}
+ public boolean hasImport(String qualifiedName)
+ {
+ return imports.contains(qualifiedName);
+ }
+
private boolean hasImplementations()
{
return getComment().getImplementedInterfaceCount() > 0;