You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/10/31 14:00:41 UTC
[1/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Repository: flex-falcon
Updated Branches:
refs/heads/feature-autobuild/closure-classpath-sources d5d45600c -> 3724c2ff9
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/files/Version.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/files/Version.as b/compiler-jx/src/test/resources/vf2js/files/Version.as
deleted file mode 100644
index 496ab63..0000000
--- a/compiler-jx/src/test/resources/vf2js/files/Version.as
+++ /dev/null
@@ -1,25 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
-import mx.core.mx_internal;
-
-/**
- * @private
- * Version string for this class.
- */
-mx_internal static const VERSION:String = "4.14.0.0";
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test.as
deleted file mode 100644
index d89743e..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test.as
+++ /dev/null
@@ -1,46 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 classes.A;
- import interfaces.IA;
- import interfaces.IC;
- import interfaces.IE;
-
- public class Test extends A implements IA, IE
- {
- public function Test()
- {
- super();
-
- var ia:IA = doSomething(IC) as IA
- }
-
- public function doSomething(ic:IC):IC
- {
- for (var i:int = 0; i < 3; i++ {
- var a:A = null;
- }
-
- super.doStuff();
-
- return ic;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test_result.js
deleted file mode 100644
index f547b18..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/Test_result.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * Test
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('Test');
-
-goog.require('classes.A');
-goog.require('interfaces.IA');
-goog.require('interfaces.IC');
-goog.require('interfaces.IE');
-goog.require('org.apache.flex.utils.Language');
-
-
-
-/**
- * @constructor
- * @extends {classes.A}
- * @implements {interfaces.IA}
- * @implements {interfaces.IE}
- */
-Test = function() {
- Test.base(this, 'constructor');
- var /** @type {interfaces.IA} */ ia = org.apache.flex.utils.Language.as(this.doSomething(interfaces.IC), interfaces.IA);
-};
-goog.inherits(Test, classes.A);
-
-
-/**
- * @export
- * @param {interfaces.IC} ic
- * @return {interfaces.IC}
- */
-Test.prototype.doSomething = function(ic) {
- for (var /** @type {number} */ i = 0; i < 3; i++) {
- var /** @type {classes.A} */ a = null;
- }
- this.superClass_.doStuff.call(this);
- return ic;
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-Test.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Test', qName: 'Test'}], interfaces: [interfaces.IA, interfaces.IE] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A.as
deleted file mode 100644
index 20a6a11..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A.as
+++ /dev/null
@@ -1,32 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 classes
-{
- public class A extends C
- {
- public function A()
- {
- super();
- }
-
- public function doStuff():void{
- trace("STUFF!!!");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A_result.js
deleted file mode 100644
index 842e665..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/A_result.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * classes.A
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('classes.A');
-
-goog.require('classes.C');
-
-
-
-/**
- * @constructor
- * @extends {classes.C}
- */
-classes.A = function() {
- classes.A.base(this, 'constructor');
-};
-goog.inherits(classes.A, classes.C);
-
-
-/**
- * @export
- */
-classes.A.prototype.doStuff = function() {
- org.apache.flex.utils.Language.trace("STUFF!!!");
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-classes.A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'A', qName: 'classes.A'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B.as
deleted file mode 100644
index b410e59..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B.as
+++ /dev/null
@@ -1,25 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 classes
-{
- public class B
- {
- public function B() {}
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B_result.js
deleted file mode 100644
index d8e3b89..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/B_result.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * classes.B
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('classes.B');
-
-
-
-/**
- * @constructor
- */
-classes.B = function() {};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-classes.B.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'B', qName: 'classes.B'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C.as
deleted file mode 100644
index d414a26..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C.as
+++ /dev/null
@@ -1,25 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 classes
-{
- public class C
- {
- public function C() {}
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C_result.js
deleted file mode 100644
index c3b72f4..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/classes/C_result.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * classes.C
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('classes.C');
-
-
-
-/**
- * @constructor
- */
-classes.C = function() {};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-classes.C.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'C', qName: 'classes.C'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA.as
deleted file mode 100644
index 5fbd6c2..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA.as
+++ /dev/null
@@ -1,22 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 interfaces
-{
- public interface IA extends IC {}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA_result.js
deleted file mode 100644
index 2a00144..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IA_result.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * interfaces.IA
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('interfaces.IA');
-
-goog.require('interfaces.IC');
-
-
-
-/**
- * @interface
- * @extends {interfaces.IC}
- */
-interfaces.IA = function() {
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-interfaces.IA.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IA', qName: 'interfaces.IA'}], interfaces: [interfaces.IC] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB.as
deleted file mode 100644
index a995635..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB.as
+++ /dev/null
@@ -1,22 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 interfaces
-{
- public interface IB {}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB_result.js
deleted file mode 100644
index d4933c8..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IB_result.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * interfaces.IB
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('interfaces.IB');
-
-
-
-/**
- * @interface
- */
-interfaces.IB = function() {
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-interfaces.IB.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IB', qName: 'interfaces.IB'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC.as
deleted file mode 100644
index 9183bac..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC.as
+++ /dev/null
@@ -1,22 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 interfaces
-{
- public interface IC extends ID {}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC_result.js
deleted file mode 100644
index 9e5298b..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IC_result.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * interfaces.IC
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('interfaces.IC');
-
-goog.require('interfaces.ID');
-
-
-
-/**
- * @interface
- * @extends {interfaces.ID}
- */
-interfaces.IC = function() {
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-interfaces.IC.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IC', qName: 'interfaces.IC'}], interfaces: [interfaces.ID] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID.as
deleted file mode 100644
index d5e9543..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID.as
+++ /dev/null
@@ -1,22 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 interfaces
-{
- public interface ID {}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID_result.js
deleted file mode 100644
index a730bbb..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/ID_result.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * interfaces.ID
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('interfaces.ID');
-
-
-
-/**
- * @interface
- */
-interfaces.ID = function() {
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-interfaces.ID.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'ID', qName: 'interfaces.ID'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE.as b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE.as
deleted file mode 100644
index d2c7ce1..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE.as
+++ /dev/null
@@ -1,26 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 interfaces
-{
- public interface IE {
- function myMethod():void;
- function get myProp():String;
- function set myProp(value:String):void;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE_result.js b/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE_result.js
deleted file mode 100644
index 63d68c7..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/interfaces/interfaces/IE_result.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * interfaces.IE
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('interfaces.IE');
-
-
-
-/**
- * @interface
- */
-interfaces.IE = function() {
-};
-
-
-interfaces.IE.prototype.myMethod = function() {};
-
-
-/**
- * @return {string}
- */
-interfaces.IE.prototype.get_myProp = function() {};
-
-
-/**
- * @param {string} value
- */
-interfaces.IE.prototype.set_myProp = function(value) {};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-interfaces.IE.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'IE', qName: 'interfaces.IE'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass.as b/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass.as
deleted file mode 100644
index 52541c2..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass.as
+++ /dev/null
@@ -1,68 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 mx.core.mx_internal;
-
-import bases.HelperBaseClass;
-
-use namespace mx_internal;
-
-public class SomeSDKClass
-{
- public function SomeSDKClass() {};
-
- private var number:Number = 'Got it: ' + this.getString();
-
- public function getString():String
- {
- return Helper.helperFunction();
- }
-
- public function someFunction():String
- {
- helperBaseClass.doSomething();
- }
-
- mx_internal var helperBaseClass:HelperBaseClass = new HelperBaseClass();
-}
-
-}
-
-import bases.HelperBaseClass;
-
-class Helper extends HelperBaseClass
-{
-
- public static function helperFunction():String {
- return "Hello world";
- }
-
- public function Helper(url:String) {
- url_ = url;
- }
-
- private var url_:String;
-
- public function get url():String {
- return url_;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass_result.js b/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass_result.js
deleted file mode 100644
index fd32667..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/sdk/SomeSDKClass_result.js
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * SomeSDKClass
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('SomeSDKClass');
-
-goog.require('bases.HelperBaseClass');
-goog.require('mx.core.mx_internal');
-goog.require('org.apache.flex.utils.Language');
-
-
-
-/**
- * @constructor
- */
-SomeSDKClass = function() {
- this.number = 'Got it: ' + this.getString();
-
- this.helperBaseClass = new bases.HelperBaseClass();
-};
-
-
-/**
- * @private
- * @type {number}
- */
-SomeSDKClass.prototype.number;
-
-
-/**
- * @export
- * @return {string}
- */
-SomeSDKClass.prototype.getString = function() {
- return Helper.helperFunction();
-};
-
-
-/**
- * @export
- * @return {string}
- */
-SomeSDKClass.prototype.someFunction = function() {
- this.helperBaseClass.doSomething();
-};
-
-
-/**
- * @type {bases.HelperBaseClass}
- */
-SomeSDKClass.prototype.helperBaseClass;
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-SomeSDKClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'SomeSDKClass', qName: 'SomeSDKClass'}] };
-
-
-
-/**
- * @constructor
- * @extends {bases.HelperBaseClass}
- * @param {string} url
- */
-Helper = function(url) {
- Helper.base(this, 'constructor', url);
- this.url_ = url;
-};
-goog.inherits(Helper, bases.HelperBaseClass);
-
-
-/**
- * @export
- * @return {string}
- */
-Helper.helperFunction = function() {
- return "Hello world";
-};
-
-
-/**
- * @private
- * @type {string}
- */
-Helper.prototype.url_;
-
-
-/**
- * @export
- * @return {string}
- */
-Helper.prototype.get_url = function() {
- return this.url_;
-};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass.as b/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass.as
deleted file mode 100644
index 487990a..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass.as
+++ /dev/null
@@ -1,33 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 bases
-{
-
-public class HelperBaseClass
-{
-
- public function HelperBaseClass() {};
-
- public function doSomething():String {
- return 'doneSomething';
- }
-
-}
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass_result.js b/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass_result.js
deleted file mode 100644
index 2460bb0..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/sdk/bases/HelperBaseClass_result.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * bases.HelperBaseClass
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('bases.HelperBaseClass');
-
-
-
-/**
- * @constructor
- */
-bases.HelperBaseClass = function() {};
-
-
-/**
- * @export
- * @return {string}
- */
-bases.HelperBaseClass.prototype.doSomething = function() {
- return 'doneSomething';
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-bases.HelperBaseClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'HelperBaseClass', qName: 'bases.HelperBaseClass'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml b/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml
deleted file mode 100644
index 160b7c9..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project.mxml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
-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.
-
--->
-<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx"
- xmlns:example="example.*"
- minHeight="600"
- minWidth="955">
-
- <fx:Script><![CDATA[
-
- private var myComponent:Component = new Component();
-
- ]]></fx:Script>
-
- <fx:Declarations>
- <example:Component myProperty="oops" />
- </fx:Declarations>
-
-</s:Application>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js b/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js
deleted file mode 100644
index 0acd486..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/SimpleMXML_Project_result.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * SimpleMXML_Project
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('SimpleMXML_Project');
-
-goog.require('spark.components.Application');
-goog.require('example.Component');
-goog.require('org.apache.flex.utils.Language');
-
-
-
-
-/**
- * @constructor
- * @extends {spark.components.Application}
- */
-SimpleMXML_Project = function() {
- SimpleMXML_Project.base(this, 'constructor');
-
- /**
- * @private
- * @type {example.Component}
- */
- this.$ID0;
-};
-goog.inherits(SimpleMXML_Project, spark.components.Application);
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-SimpleMXML_Project.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'SimpleMXML_Project', qName: 'SimpleMXML_Project' }] };
-
-
-/**
- * @private
- * @type {example.Component}
- */
-SimpleMXML_Project.prototype.myComponent;
-
-
-/**
- * start
- *
- * @export
- */
-SimpleMXML_Project.prototype.start = function () {
-};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component.as b/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component.as
deleted file mode 100644
index 02c03c3..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component.as
+++ /dev/null
@@ -1,31 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 example
-{
-
- public class Component
- {
- public function Component()
- {
- super();
- }
-
- public var myProperty:Object = {};
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component_result.js b/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component_result.js
deleted file mode 100644
index 89b829f..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/simpleMXML/src/example/Component_result.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * example.Component
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('example.Component');
-
-
-
-/**
- * @constructor
- */
-example.Component = function() {
- ;
-};
-
-
-/**
- * @type {Object}
- */
-example.Component.prototype.myProperty = {};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-example.Component.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Component', qName: 'example.Component'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/super/Base.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/super/Base.as b/compiler-jx/src/test/resources/vf2js/projects/super/Base.as
deleted file mode 100644
index ee69d65..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/super/Base.as
+++ /dev/null
@@ -1,65 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 Super;
-
-public class Base extends Super
-{
- public static var myClassConst:String = new Number();
-
- public function Base()
- {
- super();
- };
-
- private var number:Number = this.getNumber();
-
- private var newText:String = this.text;
-
- private var newTextAgain:String = text;
-
- override public function get text():String
- {
- return "A" + super.text;
- };
-
- override public function set text(value:String):void
- {
- if (value != super.text)
- {
- super.text = "B" + value;
- }
- };
-
- public function getNumber():void
- {
- alert(super.doStuff());
-
- var x:Number = super.x;
- }
-
- override public function doStuff():Number
- {
- throw new Error("No way!");
- };
-
-}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/super/Base_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/super/Base_result.js b/compiler-jx/src/test/resources/vf2js/projects/super/Base_result.js
deleted file mode 100644
index 7ca1ad1..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/super/Base_result.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * Base
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('Base');
-
-goog.require('Super');
-goog.require('org.apache.flex.utils.Language');
-
-
-
-/**
- * @constructor
- * @extends {Super}
- */
-Base = function() {
-
- Base.myClassConst = new Number();
-
- this.number = this.getNumber();
-
- this.newText = this.get_text();
-
- this.newTextAgain = this.get_text();
- Base.base(this, 'constructor');
-};
-goog.inherits(Base, Super);
-
-
-/**
- * @type {string}
- */
-Base.myClassConst;
-
-
-/**
- * @private
- * @type {number}
- */
-Base.prototype.number;
-
-
-/**
- * @private
- * @type {string}
- */
-Base.prototype.newText;
-
-
-/**
- * @private
- * @type {string}
- */
-Base.prototype.newTextAgain;
-
-
-/**
- * @export
- * @return {string}
- * @override
- */
-Base.prototype.get_text = function() {
- return "A" + Base.base(this, 'get_text');
-};
-
-
-/**
- * @export
- * @param {string} value
- * @override
- */
-Base.prototype.set_text = function(value) {
- if (value != Base.base(this, 'get_text')) {
- Base.base(this, 'set_text', "B" + value);
- }
-};
-
-
-/**
- * @export
- */
-Base.prototype.getNumber = function() {
- alert(this.superClass_.doStuff.call(this));
- var /** @type {number} */ x = this.get_x();
-};
-
-
-/**
- * @export
- * @return {number}
- * @override
- */
-Base.prototype.doStuff = function() {
- throw new Error("No way!");
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-Base.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Base', qName: 'Base'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/super/Super.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/super/Super.as b/compiler-jx/src/test/resources/vf2js/projects/super/Super.as
deleted file mode 100644
index 3a2bca2..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/super/Super.as
+++ /dev/null
@@ -1,54 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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
-{
-
-public class Super
-{
- public function Super() {};
-
- private var _text:String = '';
-
- public function get text():String
- {
- return _text;
- };
-
- public function set text(value:String):void
- {
- if (value != _text)
- {
- _text = value;
- }
- };
-
- private var _x:Number = 5;
-
- public function get x():Number
- {
- return _x;
- };
-
- public function doStuff():Number
- {
- return "Stuff is done";
- };
-
-}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/projects/super/Super_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/projects/super/Super_result.js b/compiler-jx/src/test/resources/vf2js/projects/super/Super_result.js
deleted file mode 100644
index d8bfa78..0000000
--- a/compiler-jx/src/test/resources/vf2js/projects/super/Super_result.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * Super
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('Super');
-
-
-
-/**
- * @constructor
- */
-Super = function() {};
-
-
-/**
- * @private
- * @type {string}
- */
-Super.prototype._text = '';
-
-
-/**
- * @export
- * @return {string}
- */
-Super.prototype.get_text = function() {
- return this._text;
-};
-
-
-/**
- * @export
- * @param {string} value
- */
-Super.prototype.set_text = function(value) {
- if (value != this._text) {
- this._text = value;
- }
-};
-
-
-/**
- * @private
- * @type {number}
- */
-Super.prototype._x = 5;
-
-
-/**
- * @export
- * @return {number}
- */
-Super.prototype.get_x = function() {
- return this._x;
-};
-
-
-/**
- * @export
- * @return {number}
- */
-Super.prototype.doStuff = function() {
- return "Stuff is done";
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-Super.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Super', qName: 'Super'}] };
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemContext.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemContext.java b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemContext.java
new file mode 100644
index 0000000..cd29cf4
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemContext.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.clients.problems;
+
+/**
+ * Helper class to simplify access to the ProblemQuery instance without
+ * having to pass down the object in the methods signatures.
+ */
+public class ProblemContext {
+
+ private static ThreadLocal<ProblemQuery> problemQueryThreadLocal = new ThreadLocal<ProblemQuery>();
+
+ public static void initContext() {
+ problemQueryThreadLocal.set(new ProblemQuery());
+ }
+
+ public static ProblemQuery getContext() {
+ return problemQueryThreadLocal.get();
+ }
+
+ public static void clearContext() {
+ problemQueryThreadLocal.remove();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java b/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
index ea1e879..a4e94de 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
@@ -3067,6 +3067,10 @@ public class Configuration
return verboseStacktraces;
}
+ public boolean release() {
+ return !verboseStacktraces;
+ }
+
@Config
@Mapping({ "compiler", "verbose-stacktraces" })
public void setCompilerVerboseStacktraces(ConfigurationValue cv, boolean verboseStacktraces)
@@ -5582,6 +5586,7 @@ public class Configuration
/**
* Get target file path. Target file is the last file in the {@link #getFileSpecs()}.
+ * FIXME: Calling this target file is a bit misleading as it's sort of the "main" source file
*/
public String getTargetFile()
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/flex-compiler-oem/src/main/java/flex2/tools/MxmlJSC.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/main/java/flex2/tools/MxmlJSC.java b/flex-compiler-oem/src/main/java/flex2/tools/MxmlJSC.java
index 6aa1e63..014e0be 100644
--- a/flex-compiler-oem/src/main/java/flex2/tools/MxmlJSC.java
+++ b/flex-compiler-oem/src/main/java/flex2/tools/MxmlJSC.java
@@ -30,7 +30,6 @@ import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
import org.apache.flex.compiler.internal.driver.js.node.NodeBackend;
import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
-import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
import org.apache.flex.compiler.problems.ICompilerProblem;
import java.lang.reflect.InvocationTargetException;
@@ -78,9 +77,6 @@ public class MxmlJSC implements ProblemQueryProvider {
case GOOG:
backend = new GoogBackend();
break;
- case VF2JS:
- backend = new MXMLVF2JSBackend();
- break;
case JSC:
backend = new JSCBackend();
break;
[3/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
deleted file mode 100644
index 164806c..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSPublisher.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- *
- * 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.mxml.vf2js;
-
-import java.io.*;
-import java.net.URL;
-import java.util.*;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.filefilter.DirectoryFileFilter;
-import org.apache.commons.io.filefilter.FileFileFilter;
-import org.apache.commons.io.filefilter.FileFilterUtils;
-import org.apache.commons.io.filefilter.IOFileFilter;
-import org.apache.commons.io.filefilter.RegexFileFilter;
-import org.apache.flex.compiler.clients.problems.ProblemQuery;
-import org.apache.flex.compiler.codegen.js.IJSPublisher;
-import org.apache.flex.compiler.config.Configuration;
-import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogPublisher;
-import org.apache.flex.compiler.internal.driver.js.flexjs.JSCSSCompilationSession;
-import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
-import org.apache.flex.compiler.internal.graph.VF2JSDepsWriter;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.utils.VF2JSClosureCompilerWrapper;
-
-public class MXMLVF2JSPublisher extends JSGoogPublisher implements
- IJSPublisher
-{
-
- public static final String FLEXJS_OUTPUT_DIR_NAME = "bin";
- public static final String FLEXJS_INTERMEDIATE_DIR_NAME = "js-debug";
- public static final String FLEXJS_RELEASE_DIR_NAME = "js-release";
-
- class DependencyRecord
- {
- String path;
- String deps;
- String line;
- int lineNumber;
- }
-
- class DependencyLineComparator implements Comparator<DependencyRecord> {
- @Override
- public int compare(DependencyRecord o1, DependencyRecord o2) {
- return new Integer(o1.lineNumber).compareTo(o2.lineNumber);
- }
- }
-
- public MXMLVF2JSPublisher(Configuration config, FlexJSProject project)
- {
- super(config);
-
- this.isMarmotinniRun = ((JSGoogConfiguration) configuration)
- .getMarmotinni() != null;
- this.outputPathParameter = configuration.getOutput();
- this.useStrictPublishing = ((JSGoogConfiguration) configuration)
- .getStrictPublish();
-
- this.project = project;
- }
-
- private FlexJSProject project;
-
- private boolean isMarmotinniRun;
- private String outputPathParameter;
- private boolean useStrictPublishing;
-
- @Override
- public File getOutputFolder()
- {
- // (erikdebruin) - If there is a -marmotinni switch, we want
- // the output redirected to the directory it specifies.
- // - If there is an -output switch, use that path as the
- // output parent folder.
- if (isMarmotinniRun)
- {
- outputParentFolder = new File(
- ((JSGoogConfiguration) configuration).getMarmotinni());
- }
- else if (outputPathParameter != null)
- {
- outputParentFolder = new File(outputPathParameter);
- // FB usually specified -output <project-path>/bin-release/app.swf
- if (outputPathParameter.contains(".swf"))
- outputParentFolder = outputParentFolder.getParentFile().getParentFile();
- }
- else
- {
- outputParentFolder = new File(
- configuration.getTargetFileDirectory()).getParentFile();
- }
-
- outputParentFolder = new File(outputParentFolder,
- FLEXJS_OUTPUT_DIR_NAME);
-
- outputFolder = new File(outputParentFolder, File.separator
- + FLEXJS_INTERMEDIATE_DIR_NAME);
-
- // (erikdebruin) Marmotinni handles file management, so we
- // bypass the setup.
- if (!isMarmotinniRun)
- setupOutputFolder();
-
- return outputFolder;
- }
-
- @Override
- public boolean publish(ProblemQuery problems) throws IOException
- {
- boolean ok;
- boolean subsetGoog = true;
-
- final String intermediateDirPath = outputFolder.getPath();
- final File intermediateDir = new File(intermediateDirPath);
- File srcDir = new File(configuration.getTargetFile());
- srcDir = srcDir.getParentFile();
-
- final String projectName = FilenameUtils.getBaseName(configuration
- .getTargetFile());
- final String outputFileName = projectName
- + "." + JSSharedData.OUTPUT_EXTENSION;
-
- File releaseDir = new File(outputParentFolder, FLEXJS_RELEASE_DIR_NAME);
- final String releaseDirPath = releaseDir.getPath();
-
- if (!isMarmotinniRun)
- {
- if (releaseDir.exists())
- org.apache.commons.io.FileUtils.deleteQuietly(releaseDir);
-
- releaseDir.mkdirs();
- }
-
- // If the closure-lib parameter is empty we'll try to find the resources
- // in the classpath, dump its content to the output directory and use this
- // as closure-lib parameter.
- final String closureLibDirPath;
- if(((JSGoogConfiguration) configuration).isClosureLibSet()) {
- closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
- } else {
- // Check if the "goog/deps.js" is available in the classpath.
- URL resource = Thread.currentThread().getContextClassLoader().getResource("goog/deps.js");
- if(resource != null) {
- File closureLibDir = new File(intermediateDir.getParent(), "closure");
-
- // Only create and dump the content, if the directory does not exists.
- if(!closureLibDir.exists()) {
- if(!closureLibDir.mkdirs()) {
- throw new IOException(
- "Unable to create directory for closure-lib at " + closureLibDir.getAbsolutePath());
- }
-
- // Strip the url of the parts we don't need.
- // Unless we are not using some insanely complex setup
- // the resource will always be on the same machine.
- String resourceJarPath = resource.getFile();
- if(resourceJarPath.contains(":")) {
- resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
- }
- if(resourceJarPath.contains("!")) {
- resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
- }
- File resourceJar = new File(resourceJarPath);
-
- // Dump the closure lib from classpath.
- dumpJar(resourceJar, closureLibDir);
- }
- // The compiler automatically adds a "closure" to the lib dir path,
- // so we omit this here.
- closureLibDirPath = intermediateDir.getParentFile().getPath();
- }
- // Fallback to the default.
- else {
- closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
- }
- }
-
- final String closureGoogSrcLibDirPath = closureLibDirPath
- + "/closure/goog/";
- final String closureGoogTgtLibDirPath = intermediateDirPath
- + "/library/closure/goog";
- final String depsSrcFilePath = intermediateDirPath
- + "/library/closure/goog/deps.js";
- final String depsTgtFilePath = intermediateDirPath + "/deps.js";
- final String projectIntermediateJSFilePath = intermediateDirPath
- + File.separator + outputFileName;
- final String projectReleaseJSFilePath = releaseDirPath
- + File.separator + outputFileName;
-
- appendExportSymbol(projectIntermediateJSFilePath, projectName);
- appendEncodedCSS(projectIntermediateJSFilePath, projectName);
-
- if (!subsetGoog)
- {
- // (erikdebruin) We need to leave the 'goog' files and dependencies well
- // enough alone. We copy the entire library over so the
- // 'goog' dependencies will resolve without our help.
- FileUtils.copyDirectory(new File(closureGoogSrcLibDirPath), new File(closureGoogTgtLibDirPath));
- }
-
- VF2JSClosureCompilerWrapper compilerWrapper = new VF2JSClosureCompilerWrapper();
-
- VF2JSDepsWriter gdw = new VF2JSDepsWriter(intermediateDir, projectName, (JSGoogConfiguration) configuration);
- try
- {
- StringBuilder depsFileData = new StringBuilder();
- ok = gdw.generateDeps(problems, depsFileData);
- if (!subsetGoog)
- {
- writeFile(depsTgtFilePath, depsFileData.toString(), false);
- }
- else
- {
- String s = depsFileData.toString();
- int c = s.indexOf("'goog.");
- ArrayList<String> googreqs = new ArrayList<String>();
- while (c != -1)
- {
- int c2 = s.indexOf("'", c + 1);
- String googreq = s.substring(c, c2 + 1);
- googreqs.add(googreq);
- c = s.indexOf("'goog.", c2);
- }
- HashMap<String, DependencyRecord> defmap = new HashMap<String, DependencyRecord>();
- // read in goog's deps.js
- FileInputStream fis = new FileInputStream(closureGoogSrcLibDirPath + "/deps.js");
- Scanner scanner = new Scanner(fis, "UTF-8");
- String addDependency = "goog.addDependency('";
- int currentLine = 0;
- while (scanner.hasNextLine())
- {
- String googline = scanner.nextLine();
- if (googline.indexOf(addDependency) == 0)
- {
- int c1 = googline.indexOf("'", addDependency.length() + 1);
- String googpath = googline.substring(addDependency.length(), c1);
- String googdefs = googline.substring(googline.indexOf("[") + 1, googline.indexOf("]"));
- String googdeps = googline.substring(googline.lastIndexOf("[") + 1, googline.lastIndexOf("]"));
- String[] thedefs = googdefs.split(",");
- DependencyRecord deprec = new DependencyRecord();
- deprec.path = googpath;
- deprec.deps = googdeps;
- deprec.line = googline;
- deprec.lineNumber = currentLine;
- for (String def : thedefs)
- {
- def = def.trim();
- defmap.put(def, deprec);
- }
- }
- currentLine++;
- }
- // (erikdebruin) Prevent 'Resource leak' warning on line 212:
- scanner.close();
- ArrayList<DependencyRecord> subsetdeps = new ArrayList<DependencyRecord>();
- HashMap<String, String> gotgoog = new HashMap<String, String>();
- for (String req : googreqs)
- {
- DependencyRecord deprec = defmap.get(req);
- // if we've already processed this file, skip
- if (!gotgoog.containsKey(deprec.path))
- {
- gotgoog.put(deprec.path, null);
- subsetdeps.add(deprec);
- addDeps(subsetdeps, gotgoog, defmap, deprec.deps);
- }
- }
- // now we should have the subset of files we need in the order needed
- StringBuilder sb = new StringBuilder();
- sb.append("goog.addDependency('base.js', ['goog'], []);\n");
- File file = new File(closureGoogSrcLibDirPath + "/base.js");
- FileUtils.copyFileToDirectory(file, new File(closureGoogTgtLibDirPath));
- compilerWrapper.addJSSourceFile(file.getCanonicalPath());
- Collections.sort(subsetdeps, new DependencyLineComparator());
- for (DependencyRecord subsetdeprec : subsetdeps)
- {
- sb.append(subsetdeprec.line).append("\n");
- }
- writeFile(depsTgtFilePath, sb.toString() + depsFileData.toString(), false);
- // copy the required files
- for (String googfn : gotgoog.keySet())
- {
- file = new File(closureGoogSrcLibDirPath + File.separator + googfn);
- String dir = closureGoogTgtLibDirPath;
- if (googfn.contains("/"))
- {
- dir += File.separator + googfn.substring(0, googfn.lastIndexOf("/"));
- }
- FileUtils.copyFileToDirectory(file, new File(dir));
- compilerWrapper.addJSSourceFile(file.getCanonicalPath());
- }
- }
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- return false;
- }
-
- IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
- FileFilterUtils.suffixFileFilter(".png"));
- IOFileFilter gifSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
- FileFilterUtils.suffixFileFilter(".gif"));
- IOFileFilter jpgSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
- FileFilterUtils.suffixFileFilter(".jpg"));
- IOFileFilter assetFiles = FileFilterUtils.or(pngSuffixFilter,
- jpgSuffixFilter, gifSuffixFilter);
-
- FileUtils.copyDirectory(srcDir, intermediateDir, assetFiles);
- FileUtils.copyDirectory(srcDir, releaseDir, assetFiles);
-
- File srcDeps = new File(depsSrcFilePath);
-
- // ToDo (erikdebruin): yeah, right, hard coded the path, nice!
- File sdkDepsFile = new File("/Users/erik/Documents/ApacheFlex/git/flex-asjs/vf2js/frameworks/js/sdk-deps.js");
- if (sdkDepsFile.exists())
- FileUtils.copyFile(sdkDepsFile, new File(intermediateDirPath + File.separator + "sdk-deps.js"));
-
- writeHTML("intermediate", projectName, intermediateDirPath, gdw.additionalHTML);
- writeHTML("release", projectName, releaseDirPath, gdw.additionalHTML);
- writeCSS(projectName, intermediateDirPath);
- writeCSS(projectName, releaseDirPath);
-
- if (!subsetGoog)
- {
- // (erikdebruin) add 'goog' files
- Collection<File> files = org.apache.commons.io.FileUtils.listFiles(new File(
- closureGoogTgtLibDirPath), new RegexFileFilter("^.*(\\.js)"),
- DirectoryFileFilter.DIRECTORY);
- for (File file : files)
- {
- compilerWrapper.addJSSourceFile(file.getCanonicalPath());
- }
- }
-
- // (erikdebruin) add project files
- for (String filePath : gdw.filePathsInOrder)
- {
- compilerWrapper.addJSSourceFile(
- new File(filePath).getCanonicalPath());
- }
-
- compilerWrapper.setOptions(
- projectReleaseJSFilePath, useStrictPublishing);
-
- // (erikdebruin) Include the 'goog' deps to allow the compiler to resolve
- // dependencies.
- compilerWrapper.addJSSourceFile(
- closureGoogSrcLibDirPath + File.separator + "deps.js");
-
- List<String> externs = ((JSGoogConfiguration)configuration).getExternalJSLib();
- for (String extern : externs)
- {
- compilerWrapper.addJSExternsFile(extern);
- }
-
- compilerWrapper.targetFilePath = projectReleaseJSFilePath;
- compilerWrapper.compile();
-
- appendSourceMapLocation(projectReleaseJSFilePath, projectName);
-
- if (!isMarmotinniRun)
- {
- String allDeps = "";
- if (!subsetGoog)
- allDeps += FileUtils.readFileToString(srcDeps);
- allDeps += FileUtils.readFileToString(new File(depsTgtFilePath));
-
- FileUtils.writeStringToFile(srcDeps, allDeps);
-
- org.apache.commons.io.FileUtils.deleteQuietly(new File(depsTgtFilePath));
- }
-
- if (ok)
- System.out.println("The project '"
- + projectName
- + "' has been successfully compiled and optimized.");
-
- return true;
- }
-
- private void addDeps(ArrayList<DependencyRecord> subsetdeps, HashMap<String, String> gotgoog,
- HashMap<String, DependencyRecord> defmap, String deps)
- {
- if (deps.length() == 0)
- return;
-
- String[] deplist = deps.split(",");
- for (String dep : deplist)
- {
- dep = dep.trim();
- DependencyRecord deprec = defmap.get(dep);
- if (!gotgoog.containsKey(deprec.path))
- {
- gotgoog.put(deprec.path, null);
- // put addDependencyLine in subset file
- subsetdeps.add(deprec);
- addDeps(subsetdeps, gotgoog, defmap, deprec.deps);
- }
- }
- }
-
- private void appendExportSymbol(String path, String projectName)
- throws IOException
- {
- StringBuilder appendString = new StringBuilder();
- appendString
- .append("\n\n// Ensures the symbol will be visible after compiler renaming.\n");
- appendString.append("goog.exportSymbol('");
- appendString.append(projectName);
- appendString.append("', ");
- appendString.append(projectName);
- appendString.append(");\n");
- writeFile(path, appendString.toString(), true);
- }
-
- private void appendEncodedCSS(String path, String projectName)
- throws IOException
- {
- StringBuilder appendString = new StringBuilder();
- appendString.append("\n\n");
- appendString.append(projectName);
- appendString.append(".prototype.cssData = [");
- JSCSSCompilationSession cssSession = (JSCSSCompilationSession) project.getCSSCompilationSession();
- String s = cssSession.getEncodedCSS();
- int reqidx = s.indexOf("goog.require");
- if (reqidx != -1)
- {
- String reqs = s.substring(reqidx);
- s = s.substring(0, reqidx - 1);
- String fileData = readCode(new File(path));
- reqidx = fileData.indexOf("goog.require");
- String after = fileData.substring(reqidx);
- String before = fileData.substring(0, reqidx - 1);
- s = before + reqs + after + appendString.toString() + s;
- writeFile(path, s, false);
- }
- else
- {
- appendString.append(s);
- writeFile(path, appendString.toString(), true);
- }
- }
-
- protected String readCode(File file)
- {
- String code = "";
- try
- {
- BufferedReader in = new BufferedReader(new InputStreamReader(
- new FileInputStream(file), "UTF8"));
-
- String line = in.readLine();
-
- while (line != null)
- {
- code += line + "\n";
- line = in.readLine();
- }
- code = code.substring(0, code.length() - 1);
-
- in.close();
- }
- catch (Exception e)
- {
- // nothing to see, move along...
- }
-
- return code;
- }
-
- private void writeHTML(String type, String projectName, String dirPath, List<String> additionalHTML)
- throws IOException
- {
- StringBuilder htmlFile = new StringBuilder();
- htmlFile.append("<!DOCTYPE html>\n");
- htmlFile.append("<html>\n");
- htmlFile.append("<head>\n");
- htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
- htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
- htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"");
- htmlFile.append(projectName);
- htmlFile.append(".css\">\n");
-
- for (String s : additionalHTML)
- htmlFile.append(s).append("\n");
-
- if ("intermediate".equals(type))
- {
- htmlFile.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
- htmlFile.append("\t<script type=\"text/javascript\" src=\"./sdk-deps.js\"></script>\n");
- htmlFile.append("\t<script type=\"text/javascript\">\n");
- //htmlFile.append("\t\tgoog.require('mx.styles.StyleProtoChain');\n");
- htmlFile.append("\t\tgoog.require('mx.managers.SystemManager');\n");
- htmlFile.append("\t\tgoog.require('mx.managers.systemClasses.ChildManager');\n");
- //htmlFile.append("\t\tgoog.require('" + projectName + "');\n");
- htmlFile.append("\t</script>\n");
- }
- else
- {
- htmlFile.append("\t<script type=\"text/javascript\" src=\"./");
- htmlFile.append(projectName);
- htmlFile.append(".js\"></script>\n");
- }
-
- htmlFile.append("</head>\n");
- htmlFile.append("<body onload=\"init();\">\n");
- htmlFile.append("\t<script type=\"text/javascript\">\n");
- htmlFile.append("\t\t'use strict';\n");
- htmlFile.append("\t\t\n");
- htmlFile.append("\t\tfunction init() {\n");
- htmlFile.append("\t\t\tvar /** @type {flash.display.LoaderInfo} */ loaderInfo,\n");
- htmlFile.append("\t\t\t /** @type {flash.display.Stage} */ stage,\n");
- htmlFile.append("\t\t\t /** @type {mx.managers.SystemManager} */ systemManager,\n");
- htmlFile.append("\t\t\t /** @type {mx.managers.systemClasses.ChildManager} */ childManager;\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\tstage = new flash.display.Stage();\n");
- htmlFile.append("\t\t\twindow['apache-flex_stage'] = stage;\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\twindow['apache-flex_loaderInfo'] = new flash.display.LoaderInfo();\n");
- htmlFile.append("\t\t\twindow['apache-flex_loaderInfo'].get_parameters = function () {\n");
- htmlFile.append("\t\t\t\tvar /** @type {Object} */ infoObject;\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\t infoObject = {};\n");
- htmlFile.append("\t\t\t infoObject[\"resourceModuleURLs\"] = '';\n");
- htmlFile.append("\t\t\t \n");
- htmlFile.append("\t\t\t return infoObject;\n");
- htmlFile.append("\t\t\t}\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\tsystemManager = new mx.managers.SystemManager();\n");
- htmlFile.append("\t\t\tsystemManager.info = function () {\n");
- htmlFile.append("\t\t\t\tvar /** @type {Object} */ infoObject;\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\t infoObject = {};\n");
- htmlFile.append("\t\t\t infoObject[\"applicationDPI\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"backgroundAlpha\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"backgroundColor\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"backgroundImage\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"backgroundSize\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"cdRsls\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"compiledLocales\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"compiledResourceBundleNames\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"currentDomain\"] = new flash.system.ApplicationDomain();\n");
- htmlFile.append("\t\t\t infoObject[\"fonts\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"frames\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"mainClassName\"] = '").append(projectName).append("';\n");
- htmlFile.append("\t\t\t infoObject[\"mixins\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"preloader\"] = new mx.preloaders.DownloadProgressBar();\n");
- htmlFile.append("\t\t\t infoObject[\"rsls\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"runtimeDPIProvider\"] = new mx.core.RuntimeDPIProvider();\n");
- htmlFile.append("\t\t\t infoObject[\"useNativeDragManager\"] = '';\n");
- htmlFile.append("\t\t\t infoObject[\"usePreloader\"] = false; // we're not showing a preloader in JS\n");
- htmlFile.append("\t\t\t \n");
- htmlFile.append("\t\t\t return infoObject;\n");
- htmlFile.append("\t\t\t}\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\tchildManager = new mx.managers.systemClasses.ChildManager(systemManager);\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\tmx.managers.DragManagerImpl.sm = window['apache-flex_system-manager'];\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\tmx.core.FlexGlobals.topLevelApplication = {};\n");
- htmlFile.append("\t\t\t\n");
- htmlFile.append("\t\t\twindow['apache-flex_loaderInfo'].dispatchEvent(new flash.events.Event(flash.events.Event.INIT));\n");
- htmlFile.append("\t\t}\n");
- htmlFile.append("\t</script>\n");
- htmlFile.append("</body>\n");
- htmlFile.append("</html>");
-
- writeFile(dirPath + File.separator + "index.html", htmlFile.toString(),
- false);
- }
-
- private void writeCSS(String projectName, String dirPath)
- throws IOException
- {
- StringBuilder cssFile = new StringBuilder();
- JSCSSCompilationSession cssSession = (JSCSSCompilationSession) project.getCSSCompilationSession();
- cssFile.append(cssSession.emitCSS());
-
- writeFile(dirPath + File.separator + projectName + ".css",
- cssFile.toString(), false);
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java
deleted file mode 100644
index ae620f7..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * 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.driver.js.vf2js;
-
-import java.util.List;
-
-import org.apache.flex.compiler.clients.MXMLJSC;
-import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
-
-/**
- * The {@link JSVF2JSConfiguration} class holds all compiler arguments needed for
- * compiling ActionScript to JavaScript the 'goog' way.
- * <p>
- * Specific flags are implemented here for the configuration to be loaded by the
- * configure() method of {@link MXMLJSC}.
- * <p>
- * This class inherits all compiler arguments from the MXMLC compiler.
- *
- * @author Erik de Bruin
- */
-public class JSVF2JSConfiguration extends JSGoogConfiguration
-{
- public JSVF2JSConfiguration()
- {
- }
-
- //
- // 'closure-lib'
- //
-
- @Override
- public String getClosureLib()
- {
- try
- {
- if (closureLib.equals(""))
- {
- closureLib = getAbsolutePathFromPathRelativeToMXMLC(
- "../lib/google/closure-library");
- }
- }
- catch (Exception e) { /* better to try and fail... */ }
-
- return closureLib;
- }
-
- //
- // 'sdk-js-lib'
- //
-
- @Override
- public List<String> getSDKJSLib()
- {
- if (sdkJSLib.size() == 0)
- {
- try
- {
- String path = getAbsolutePathFromPathRelativeToMXMLC(
- "../../../../frameworks/js/vf2js/src");
-
- sdkJSLib.add(path);
- }
- catch (Exception e) { /* better to try and fail... */ }
- }
-
- return sdkJSLib;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
deleted file mode 100644
index d0030fe..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * 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.driver.js.vf2js;
-
-import java.io.FilterWriter;
-
-import org.apache.flex.compiler.codegen.js.IJSEmitter;
-import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
-import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.flex.compiler.internal.targets.FlexJSTarget;
-import org.apache.flex.compiler.internal.targets.JSTarget;
-import org.apache.flex.compiler.projects.IASProject;
-import org.apache.flex.compiler.targets.ITargetProgressMonitor;
-import org.apache.flex.compiler.targets.ITargetSettings;
-
-/**
- * @author Erik de Bruin
- */
-public class VF2JSBackend extends GoogBackend
-{
-
- @Override
- public IJSEmitter createEmitter(FilterWriter out)
- {
- IJSEmitter emitter = new JSVF2JSEmitter(out);
- emitter.setDocEmitter(createDocEmitter(emitter));
- return emitter;
- }
-
- @Override
- public JSTarget createTarget(IASProject project, ITargetSettings settings,
- ITargetProgressMonitor monitor)
- {
- return new FlexJSTarget(project, settings, monitor);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
deleted file mode 100644
index f69d499..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- *
- * 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.driver.mxml.vf2js;
-
-import java.io.FilterWriter;
-import java.util.List;
-
-import org.apache.flex.compiler.codegen.IDocEmitter;
-import org.apache.flex.compiler.codegen.as.IASEmitter;
-import org.apache.flex.compiler.codegen.js.IJSEmitter;
-import org.apache.flex.compiler.codegen.js.IJSWriter;
-import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
-import org.apache.flex.compiler.config.Configuration;
-import org.apache.flex.compiler.config.Configurator;
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.driver.IPublisher;
-import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSDocEmitter;
-import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
-import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
-import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
-import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSEmitter;
-import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSPublisher;
-import org.apache.flex.compiler.internal.driver.js.vf2js.JSVF2JSConfiguration;
-import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.targets.FlexJSTarget;
-import org.apache.flex.compiler.internal.targets.JSTarget;
-import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
-import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
-import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.projects.IASProject;
-import org.apache.flex.compiler.targets.ITargetProgressMonitor;
-import org.apache.flex.compiler.targets.ITargetSettings;
-import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.apache.flex.compiler.units.ICompilationUnit;
-import org.apache.flex.compiler.visitor.IBlockVisitor;
-import org.apache.flex.compiler.visitor.IBlockWalker;
-import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
-
-/**
- * A concrete implementation of the {@link IBackend} API where the
- * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
- *
- * @author Erik de Bruin
- */
-public class MXMLVF2JSBackend extends MXMLBackend
-{
-
- @Override
- public Configurator createConfigurator()
- {
- return new Configurator(JSVF2JSConfiguration.class);
- }
-
- @Override
- public IMXMLEmitter createMXMLEmitter(FilterWriter out)
- {
- return new MXMLVF2JSEmitter(out);
- }
-
- @Override
- public IMXMLBlockWalker createMXMLWalker(IASProject project,
- List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
- IASEmitter asEmitter, IBlockWalker asBlockWalker)
- {
- MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
- mxmlEmitter, asEmitter, asBlockWalker);
-
- ASNodeSwitch asStrategy = new ASNodeSwitch(
- (IBlockVisitor) asBlockWalker);
- walker.setASStrategy(asStrategy);
-
- MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
- walker.setMXMLStrategy(mxmlStrategy);
-
- return walker;
- }
-
- @Override
- public IDocEmitter createDocEmitter(IASEmitter emitter)
- {
- return new JSVF2JSDocEmitter((IJSEmitter) emitter);
- }
-
- @Override
- public IJSEmitter createEmitter(FilterWriter out)
- {
- IJSEmitter emitter = new JSVF2JSEmitter(out);
- emitter.setDocEmitter(createDocEmitter(emitter));
- return emitter;
- }
-
- @Override
- public IJSWriter createMXMLWriter(IASProject project,
- List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
- boolean enableDebug)
- {
- return new MXMLWriter(project, problems, compilationUnit, enableDebug);
- }
-
- @Override
- public JSTarget createTarget(IASProject project, ITargetSettings settings,
- ITargetProgressMonitor monitor)
- {
- return new FlexJSTarget(project, settings, monitor);
- }
-
- @Override
- public IPublisher createPublisher(IASProject project,
- List<ICompilerProblem> errors, Configuration config)
- {
- return new MXMLVF2JSPublisher(config, (FlexJSProject) project);
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java
deleted file mode 100644
index f9390fc..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *
- * 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.driver.mxml.vf2js;
-
-import java.io.FilterWriter;
-import java.util.List;
-
-import org.apache.flex.compiler.codegen.IDocEmitter;
-import org.apache.flex.compiler.codegen.as.IASEmitter;
-import org.apache.flex.compiler.codegen.js.IJSEmitter;
-import org.apache.flex.compiler.codegen.js.IJSWriter;
-import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
-import org.apache.flex.compiler.config.Configurator;
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSDocEmitter;
-import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
-import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
-import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
-import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSEmitter;
-import org.apache.flex.compiler.internal.driver.js.vf2js.JSVF2JSConfiguration;
-import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
-import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
-import org.apache.flex.compiler.internal.targets.JSTarget;
-import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
-import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
-import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.projects.IASProject;
-import org.apache.flex.compiler.targets.ITargetProgressMonitor;
-import org.apache.flex.compiler.targets.ITargetSettings;
-import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.apache.flex.compiler.units.ICompilationUnit;
-import org.apache.flex.compiler.visitor.IBlockVisitor;
-import org.apache.flex.compiler.visitor.IBlockWalker;
-import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
-
-/**
- * A concrete implementation of the {@link IBackend} API where the
- * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
- *
- * @author Erik de Bruin
- */
-public class MXMLVF2JSSWCBackend extends MXMLBackend
-{
-
- @Override
- public Configurator createConfigurator()
- {
- return new Configurator(JSVF2JSConfiguration.class);
- }
-
- @Override
- public IMXMLEmitter createMXMLEmitter(FilterWriter out)
- {
- return new MXMLVF2JSEmitter(out);
- }
-
- @Override
- public IMXMLBlockWalker createMXMLWalker(IASProject project,
- List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
- IASEmitter asEmitter, IBlockWalker asBlockWalker)
- {
- MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
- mxmlEmitter, asEmitter, asBlockWalker);
-
- ASNodeSwitch asStrategy = new ASNodeSwitch(
- (IBlockVisitor) asBlockWalker);
- walker.setASStrategy(asStrategy);
-
- MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
- walker.setMXMLStrategy(mxmlStrategy);
-
- return walker;
- }
-
- @Override
- public IDocEmitter createDocEmitter(IASEmitter emitter)
- {
- return new JSVF2JSDocEmitter((IJSEmitter) emitter);
- }
-
- @Override
- public IJSEmitter createEmitter(FilterWriter out)
- {
- IJSEmitter emitter = new JSVF2JSEmitter(out);
- emitter.setDocEmitter(createDocEmitter(emitter));
- return emitter;
- }
-
- @Override
- public IJSWriter createMXMLWriter(IASProject project,
- List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
- boolean enableDebug)
- {
- return new MXMLWriter(project, problems, compilationUnit, enableDebug);
- }
-
- @Override
- public JSTarget createTarget(IASProject project, ITargetSettings settings,
- ITargetProgressMonitor monitor)
- {
- return new FlexJSSWCTarget(project, settings, monitor);
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/VF2JSDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/VF2JSDepsWriter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/VF2JSDepsWriter.java
deleted file mode 100644
index 4d625d4..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/VF2JSDepsWriter.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- *
- * 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.graph;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Scanner;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.flex.compiler.clients.problems.ProblemQuery;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
-import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
-import org.apache.flex.compiler.problems.FileNotFoundProblem;
-
-import com.google.common.io.Files;
-
-public class VF2JSDepsWriter {
-
- public VF2JSDepsWriter(File outputFolder, String mainClassName, JSGoogConfiguration config)
- {
- this.outputFolderPath = outputFolder.getAbsolutePath();
- this.mainName = mainClassName;
- otherPaths = config.getSDKJSLib();
- }
-
- private ProblemQuery problems;
- private String outputFolderPath;
- private String mainName;
- private List<String> otherPaths;
- private boolean problemsFound = false;
-
- private HashMap<String,GoogDep> depMap = new HashMap<String,GoogDep>();
-
- public ArrayList<String> getListOfFiles() throws InterruptedException
- {
- buildDB();
- ArrayList<GoogDep> dps = sort(mainName);
- ArrayList<String> files = new ArrayList<String>();
- for (GoogDep gd : dps)
- {
- files.add(gd.filePath);
- }
- return files;
- }
-
- public boolean generateDeps(ProblemQuery problems, StringBuilder depsFileData)
- throws InterruptedException, FileNotFoundException
- {
- problemsFound = false;
- this.problems = problems;
- buildDB();
- ArrayList<GoogDep> dps = sort(mainName);
- String outString = "// generated by FalconJS" + "\n";
- int n = dps.size();
- for (int i = n - 1; i >= 0; i--)
- {
- GoogDep gd = dps.get(i);
- if (!isGoogClass(gd.className))
- {
- String s = "goog.addDependency('";
- s += relativePath(gd.filePath);
- s += "', ['";
- s += gd.className;
- s += "'], [";
- s += getDependencies(gd.deps);
- s += "]);\n";
- outString += s;
- }
- }
- depsFileData.append(outString);
- return !problemsFound;
- }
-
- private boolean isGoogClass(String className)
- {
- return className.startsWith("goog.");
- }
-
- private void buildDB()
- {
- addDeps(mainName);
- }
-
- public ArrayList<String> filePathsInOrder = new ArrayList<String>();
-
- public ArrayList<String> additionalHTML = new ArrayList<String>();
-
- private HashMap<String, GoogDep> visited = new HashMap<String, GoogDep>();
-
- private ArrayList<GoogDep> sort(String rootClassName)
- {
- ArrayList<GoogDep> arr = new ArrayList<GoogDep>();
- GoogDep current = depMap.get(rootClassName);
- sortFunction(current, arr);
- return arr;
- }
-
- private void sortFunction(GoogDep current, ArrayList<GoogDep> arr)
- {
- visited.put(current.className, current);
-
- filePathsInOrder.add(current.filePath);
- System.out.println("Dependencies calculated for '" + current.filePath + "'");
-
- ArrayList<String> deps = current.deps;
- for (String className : deps)
- {
- if (!visited.containsKey(className) && !isGoogClass(className))
- {
- GoogDep gd = depMap.get(className);
- sortFunction(gd, arr);
- }
- }
- arr.add(current);
- }
-
- private void addDeps(String className)
- {
- if (depMap.containsKey(className) || isGoogClass(className))
- return;
-
- // build goog dependency list
- GoogDep gd = new GoogDep();
- gd.className = className;
- gd.filePath = getFilePath(className);
- depMap.put(gd.className, gd);
- ArrayList<String> deps = getDirectDependencies(gd.filePath);
-
- gd.deps = new ArrayList<String>();
- ArrayList<String> circulars = new ArrayList<String>();
- for (String dep : deps)
- {
- if (depMap.containsKey(dep) && !isGoogClass(dep))
- {
- circulars.add(dep);
- continue;
- }
- gd.deps.add(dep);
- }
- for (String dep : deps)
- {
- addDeps(dep);
- }
- if (circulars.size() > 0)
- {
- // remove requires that would cause circularity
- try
- {
- List<String> fileLines = Files.readLines(new File(gd.filePath),
- Charset.defaultCharset());
- ArrayList<String> finalLines = new ArrayList<String>();
-
- //String inherits = getBaseClass(fileLines, className);
-
- for (String line : fileLines)
- {
- int c = line.indexOf("goog.require");
- if (c > -1)
- {
- int c2 = line.indexOf(")");
- String s = line.substring(c + 14, c2 - 1);
- if (circulars.contains(s) /* && !s.equals(inherits) */ )
- continue;
- }
- finalLines.add(line);
- }
- File file = new File(gd.filePath);
- PrintWriter out = new PrintWriter(new FileWriter(file));
- for (String s : finalLines)
- {
- out.println(s);
- }
- out.close();
-
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
-
- }
- }
-
- String getBaseClass(List<String> lines, String className)
- {
- int n = lines.size();
- for (int i = 0; i < n; i++)
- {
- String line = lines.get(i);
- int c2;
- int c = line.indexOf("goog.inherits");
- if (c > -1)
- {
- String inheritLine = "";
- while (true)
- {
- inheritLine += line;
- c2 = line.indexOf(")");
- if (c2 > -1)
- break;
- else
- {
- i++;
- line = lines.get(i);
- }
- }
- c = inheritLine.indexOf(",");
- c2 = inheritLine.indexOf(")");
- return inheritLine.substring(c + 1, c2).trim();
- }
- }
- return null;
- }
-
- String getFilePath(String className)
- {
- String fn;
- File destFile;
- File f;
-
- String classPath = className.replace(".", File.separator);
-
- fn = outputFolderPath + File.separator + classPath + ".js";
- f = new File(fn);
- if (f.exists())
- {
- return fn;
- }
-
- for (String otherPath : otherPaths)
- {
- fn = otherPath + File.separator + classPath + ".js";
- f = new File(fn);
- if (f.exists())
- {
- fn = outputFolderPath + File.separator + classPath + ".js";
- destFile = new File(fn);
- // copy source to output
- try {
- FileUtils.copyFile(f, destFile);
-
- // (erikdebruin) copy class assets files
- if (className.indexOf("org.apache.flex") > -1)
- {
- File assetsDir = new File(f.getParentFile(), "assets");
- if (assetsDir.exists())
- {
- String nameOfClass = className.substring(className.lastIndexOf('.') + 1);
-
- File[] assetsList = assetsDir.listFiles();
- for (int i = 0; i < assetsList.length; i++)
- {
- File assetFile = assetsList[i];
- String assetFileName = assetFile.getName();
-
- if (assetFile.isFile() && assetFileName.indexOf(nameOfClass) == 0)
- {
- String pathOfClass = "";
- pathOfClass = className.substring(0, className.lastIndexOf('.'));
- pathOfClass = pathOfClass.replace(".", File.separator);
-
- destFile = new File(outputFolderPath +
- File.separator + pathOfClass +
- File.separator + "assets" +
- File.separator + assetFileName);
- FileUtils.copyFile(assetFile, destFile);
-
- destFile = new File(outputFolderPath.replace("js-debug", "js-release") +
- File.separator + pathOfClass +
- File.separator + "assets" +
- File.separator + assetFileName);
- FileUtils.copyFile(assetFile, destFile);
-
- System.out.println("Copied assets of the '" + nameOfClass + "' class");
- }
- }
- }
- }
- } catch (IOException e) {
- System.out.println("Error copying file for class: " + className);
- }
- return fn;
- }
- }
-
- System.out.println("Could not find file for class: " + className);
- problems.add(new FileNotFoundProblem(className));
- problemsFound = true;
- return "";
- }
-
- private ArrayList<String> getDirectDependencies(String fn)
- {
- ArrayList<String> deps = new ArrayList<String>();
-
- FileInputStream fis;
- try {
- fis = new FileInputStream(fn);
- Scanner scanner = new Scanner(fis, "UTF-8");
- boolean inInjectHTML = false;
- while (scanner.hasNextLine())
- {
- String s = scanner.nextLine();
- if (s.indexOf("goog.inherits") > -1)
- break;
- if (inInjectHTML)
- {
- int c = s.indexOf("</inject_html>");
- if (c > -1)
- {
- inInjectHTML = false;
- continue;
- }
- }
- if (inInjectHTML)
- {
- additionalHTML.add(s);
- continue;
- }
- int c = s.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
- if (c > -1)
- {
- int c2 = s.indexOf(")");
- s = s.substring(c + 14, c2 - 1);
- deps.add(s);
- }
- c = s.indexOf("<inject_html>");
- if (c > -1)
- {
- inInjectHTML = true;
- }
- }
- scanner.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- return deps;
- }
-
- private String getDependencies(ArrayList<String> deps)
- {
- String s = "";
- for (String dep : deps)
- {
- if (s.length() > 0)
- {
- s += ", ";
- }
- s += "'" + dep + "'";
- }
- return s;
- }
-
- String relativePath(String path)
- {
- if (path.indexOf(outputFolderPath) == 0)
- {
- path = path.replace(outputFolderPath, "../../..");
- }
- else
- {
- for (String otherPath : otherPaths)
- {
- if (path.indexOf(otherPath) == 0)
- {
- path = path.replace(otherPath, "../../..");
-
- }
- }
- }
- // paths are actually URIs and always have forward slashes
- path = path.replace('\\', '/');
- return path;
- }
- private class GoogDep
- {
- public String filePath;
- public String className;
- public ArrayList<String> deps;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/utils/JSClosureCompilerWrapper.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/JSClosureCompilerWrapper.java b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/JSClosureCompilerWrapper.java
index fa372fd..b462568 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/JSClosureCompilerWrapper.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/JSClosureCompilerWrapper.java
@@ -23,6 +23,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
@@ -54,8 +55,7 @@ public class JSClosureCompilerWrapper
if (s.contains(" "))
{
String[] parts = s.split(" ");
- for (String part : parts)
- splitArgs.add(part);
+ Collections.addAll(splitArgs, parts);
}
else
splitArgs.add(s);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSClosureCompilerWrapper.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSClosureCompilerWrapper.java b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSClosureCompilerWrapper.java
deleted file mode 100644
index f1240e4..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSClosureCompilerWrapper.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *
- * 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.utils;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-
-import com.google.javascript.jscomp.CheckLevel;
-import com.google.javascript.jscomp.CommandLineRunner;
-import com.google.javascript.jscomp.CompilationLevel;
-import com.google.javascript.jscomp.Compiler;
-import com.google.javascript.jscomp.CompilerOptions;
-import com.google.javascript.jscomp.DiagnosticGroups;
-import com.google.javascript.jscomp.SourceFile;
-import com.google.javascript.jscomp.SourceMap;
-import com.google.javascript.jscomp.WarningLevel;
-import com.google.javascript.rhino.Node;
-import com.google.javascript.rhino.Token;
-
-public class VF2JSClosureCompilerWrapper
-{
-
- public VF2JSClosureCompilerWrapper()
- {
- Compiler.setLoggingLevel(Level.ALL);
-
- compiler_ = new Compiler();
-
- options_ = new CompilerOptions();
- initOptions();
-
- jsExternsFiles_ = new ArrayList<SourceFile>();
- initExterns();
-
- jsSourceFiles_ = new ArrayList<SourceFile>();
- }
-
- private Compiler compiler_;
- private CompilerOptions options_;
- private List<SourceFile> jsExternsFiles_;
- private List<SourceFile> jsSourceFiles_;
-
- public String targetFilePath;
-
- public void addJSExternsFile(String fileName)
- {
- addJSExternsFile(SourceFile.fromFile(fileName));
- }
-
- public void addJSExternsFile(SourceFile file)
- {
- jsExternsFiles_.add(file);
- }
-
- public void addJSSourceFile(String fileName)
- {
- jsSourceFiles_.add(SourceFile.fromFile(fileName));
- }
-
- public void compile()
- {
- compiler_.compile(jsExternsFiles_, jsSourceFiles_, options_);
-
- try
- {
- FileWriter targetFile = new FileWriter(targetFilePath);
- targetFile.write(compiler_.toSource());
- targetFile.close();
-
- FileWriter sourceMapFile = new FileWriter(options_.sourceMapOutputPath);
- compiler_.getSourceMap().appendTo(sourceMapFile, "");
- sourceMapFile.close();
- }
- catch (IOException error)
- {
- System.out.println(error);
- }
- }
-
- @SuppressWarnings( "deprecation" )
- private void initExterns()
- {
- try
- {
- List<SourceFile> defaultExterns = CommandLineRunner.getDefaultExterns();
- for (SourceFile defaultExtern : defaultExterns)
- {
- this.addJSExternsFile(defaultExtern);
- }
- }
- catch (IOException error)
- {
- System.out.println(error);
- }
- }
-
- private void initOptions()
- {
- CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(
- options_);
-
- WarningLevel.VERBOSE.setOptionsForWarningLevel(options_);
-
- String[] asdocTags = new String[] {"productversion",
- "playerversion", "langversion", "copy"};
- options_.setExtraAnnotationNames(Arrays.asList(asdocTags));
- }
-
- public void setOptions(String sourceMapPath, boolean useStrictPublishing)
- {
- if (useStrictPublishing)
- {
- // (erikdebruin) set compiler flags to 'strictest' to allow maximum
- // code optimization
-
- options_.getDefineReplacements().put(
- "goog.DEBUG", new Node(Token.TRUE));
-
- // ToDo (erikdebruin): re-evaluate this option on future GC release
- //options_.setLanguageIn(LanguageMode.ECMASCRIPT6_STRICT);
-
- options_.setPreferSingleQuotes(true);
-
- options_.setFoldConstants(true);
- options_.setDeadAssignmentElimination(true);
- options_.setInlineConstantVars(true);
- options_.setInlineFunctions(true);
- options_.setInlineLocalFunctions(true);
- options_.setCrossModuleCodeMotion(true);
- options_.setCoalesceVariableNames(true);
- options_.setCrossModuleMethodMotion(true);
- options_.setInlineGetters(true);
- options_.setInlineVariables(true);
- options_.setSmartNameRemoval(true);
- options_.setRemoveDeadCode(true);
- options_.setCheckMissingReturn(CheckLevel.WARNING);
- options_.setExtractPrototypeMemberDeclarations(true);
- options_.setRemoveUnusedPrototypeProperties(true);
- options_.setRemoveUnusedPrototypePropertiesInExterns(true);
- options_.setRemoveUnusedClassProperties(true);
- options_.setRemoveUnusedVars(true);
- options_.setRemoveUnusedLocalVars(true);
- options_.setCollapseVariableDeclarations(true);
- options_.setCollapseAnonymousFunctions(true);
- options_.setAliasAllStrings(true);
- options_.setConvertToDottedProperties(true);
- options_.setRewriteFunctionExpressions(true);
- options_.setOptimizeParameters(true);
- options_.setOptimizeReturns(true);
- options_.setOptimizeCalls(true);
- options_.setOptimizeArgumentsArray(true);
-
- // warnings already activated in previous incarnation
- options_.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CONST, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CONSTANT_PROPERTY, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.STRICT_MODULE_DEP_CHECK, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.VISIBILITY, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.DEPRECATED, CheckLevel.OFF); // OFF
-
- // the 'full' set of warnings
- options_.setWarningLevel(DiagnosticGroups.AMBIGUOUS_FUNCTION_DECL, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CHECK_EVENTFUL_OBJECT_DISPOSAL, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.MISSING_PROVIDE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CHECK_REGEXP, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CHECK_TYPES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CHECK_USELESS_CODE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.DEBUGGER_STATEMENT_PRESENT, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.DUPLICATE_MESSAGE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.DUPLICATE_VARS, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.ES3, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.ES5_STRICT, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.EXTERNS_VALIDATION, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.GLOBAL_THIS, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.FILEOVERVIEW_JSDOC, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.INTERNET_EXPLORER_CHECKS, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.INVALID_CASTS, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.OFF); // OFF
- options_.setWarningLevel(DiagnosticGroups.MISPLACED_TYPE_ANNOTATION, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.MISSING_PROPERTIES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.MISSING_PROVIDE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.MISSING_REQUIRE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.MISSING_RETURN, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.NEW_CHECK_TYPES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.NON_STANDARD_JSDOC, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.REPORT_UNKNOWN_TYPES, CheckLevel.OFF); // OFF
- options_.setWarningLevel(DiagnosticGroups.SUSPICIOUS_CODE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.TWEAKS, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.TYPE_INVALIDATION, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.UNDEFINED_NAMES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.UNDEFINED_VARIABLES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.UNKNOWN_DEFINES, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.UNNECESSARY_CASTS, CheckLevel.OFF); // OFF
- options_.setWarningLevel(DiagnosticGroups.USE_OF_GOOG_BASE, CheckLevel.WARNING);
- options_.setWarningLevel(DiagnosticGroups.VIOLATED_MODULE_DEP, CheckLevel.WARNING);
- }
-
- options_.sourceMapFormat = SourceMap.Format.V3;
- options_.sourceMapOutputPath = sourceMapPath + ".map";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSProjectUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSProjectUtils.java b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSProjectUtils.java
deleted file mode 100644
index 0542097..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/VF2JSProjectUtils.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- *
- * 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.utils;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-
-import com.google.common.io.Files;
-
-
-public class VF2JSProjectUtils
-{
-
- private static File tempDir;
-
- public static final String createTempProject(String projectFilePath,
- boolean isFlashBuilderProject)
- {
- tempDir = Files.createTempDir();
-
- String fileName = projectFilePath.substring(projectFilePath.lastIndexOf(File.separator) + 1, projectFilePath.length());
-
- String path = projectFilePath.substring(0, projectFilePath.lastIndexOf(File.separator));
-
- createTempProjectDir(new File(path).listFiles(), "");
-
- return tempDir.getAbsolutePath() + File.separator + fileName;
- }
-
- private static void createTempProjectDir(File[] files, String parentPath)
- {
- for (File file : files)
- {
- if (file.isDirectory())
- {
- String path = parentPath + File.separator + file.getName();
-
- new File(tempDir + File.separator + path).mkdirs();
-
- createTempProjectDir(file.listFiles(), path);
- }
- else
- {
- String fileName = file.getName();
-
- if (fileName.contains(".") && fileName.charAt(0) != '.')
- {
- String extension = fileName.substring(fileName.lastIndexOf("."), fileName.length());
-
- if (extension.equals(".mxml") || extension.equals(".as"))
- {
- File intermediateFile = file;
- String tempFileName = fileName.substring(0, fileName.indexOf("."));
- File targetDir = new File(tempDir + File.separator + parentPath);
-
- createTempFileWithVF2JSNamespace(intermediateFile,
- tempFileName, false, targetDir, extension);
- }
- }
- }
- }
- }
-
- private static File createTempFileWithVF2JSNamespace(File intermediateFile,
- String tempFileName, boolean createTempFile, File targetDir,
- String extension)
- {
- File tempFile = null;
-
- try
- {
- String content = FileUtils.readFileToString(intermediateFile, "UTF-8");
-
- // mx (MXML)
- content = content.replace(
- "xmlns:mx=\"library://ns.adobe.com/flex/mx\"",
- "xmlns:vf2js_mx=\"http://flex.apache.org/vf2js_mx/ns\"");
- content = content.replace("<mx:", "<vf2js_mx:");
- content = content.replace("</mx:", "</vf2js_mx:");
-
- // mx (AS)
- content = content.replace("mx.", "vf2js_mx.");
-
- // s (MXML)
- content = content.replace(
- "xmlns:s=\"library://ns.adobe.com/flex/spark\"",
- "xmlns:vf2js_s=\"http://flex.apache.org/vf2js_s/ns\"");
- content = content.replace("<s:", "<vf2js_s:");
- content = content.replace("</s:", "</vf2js_s:");
-
- // s (AS)
- content = content.replace("spark.", "vf2js_s.");
-
- if (createTempFile)
- {
- tempFile = File.createTempFile(tempFileName, extension,
- targetDir);
- tempFile.deleteOnExit();
- }
- else
- {
- tempFile = new File(targetDir.getAbsolutePath(),
- tempFileName + extension);
- }
- FileUtils.writeStringToFile(tempFile, content, "UTF-8");
- }
- catch (IOException e)
- {
- throw new RuntimeException("Generating file failed", e);
- }
-
- return tempFile;
- }
-}
[2/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
deleted file mode 100644
index b947740..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogClass;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
-import org.apache.flex.compiler.tree.as.IClassNode;
-import org.apache.flex.compiler.tree.as.IFileNode;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestVF2JSClass extends TestGoogClass
-{
-
- @Override
- @Test
- public void testSimple()
- {
- IClassNode node = getClassNode("public class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testSimpleInternal()
- {
- // (erikdebruin) the AS compiler will enforce 'internal' namespace,
- // in JS we ignore it
- IClassNode node = getClassNode("internal class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testSimpleFinal()
- {
- // (erikdebruin) the AS compiler will enforce the 'final' keyword,
- // in JS we ignore it
- IClassNode node = getClassNode("public final class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testSimpleDynamic()
- {
- // (erikdebruin) all JS objects are 'dynamic' by design
- IClassNode node = getClassNode("public dynamic class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testConstructor_super()
- {
- IClassNode node = getClassNode("public class A {public function A() { super(); }}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n ;\n};");
- }
-
- @Override
- @Test
- public void testSimpleExtends()
- {
- IClassNode node = getClassNode("public class A extends Button {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testSimpleImplements()
- {
- IClassNode node = getClassNode("public class A implements IEventDispatcher {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testSimpleImplementsMultiple()
- {
- IClassNode node = getClassNode("public class A implements IEventDispatcher, ILogger {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testSimpleExtendsImplements()
- {
- IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testSimpleExtendsImplementsMultiple()
- {
- IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testSimpleFinalExtendsImplementsMultiple()
- {
- IClassNode node = getClassNode("public final class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testQualifiedExtendsImplementsMultiple()
- {
- IClassNode node = getClassNode("public class A extends spark.components.Button implements flash.events.IEventDispatcher, mx.logging.ILogger {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testConstructor()
- {
- IClassNode node = getClassNode("public class A {public function A() { }}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};");
- }
-
- @Override
- @Test
- public void testExtendsConstructor_super()
- {
- IClassNode node = getClassNode("public class A extends spark.components.Button { public function A() { super('foo', 42);}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor', 'foo', 42);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testConstructor_withArguments()
- {
- IClassNode node = getClassNode("public class A {public function A(arg1:String, arg2:int) {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.flex.A = function(arg1, arg2) {};");
- }
-
- @Test
- public void testConstructor_withArgumentNameMatchingMemberName()
- {
- IClassNode node = getClassNode("public class B {public function B(arg1:String) {this.arg1 = arg1}; public var arg1:String;}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.flex.B = function(arg1) {\n this.arg1 = arg1;\n};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.arg1;";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_withImplicitSelfInReturnValue()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; public var button:Button = new Button(); public function foo():String {return button.label;};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n this.button = new spark.components.Button();\n};\n\n\n/**\n * @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button;\n\n\n/**\n * @export\n * @return {string}\n */\norg.apache.flex.B.prototype.foo = function() {\n return this.button.get_label();\n};";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_noArgsNoReturn()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; public function foo():void {};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n */\norg.apache.flex.B.prototype.foo = function() {\n};";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_override()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; override public function foo():void {};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @override\n */\norg.apache.flex.B.prototype.foo = function() {\n};";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_overrideWithFunctionBody()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; override public function foo(value:Object):void {baz = ''};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @param {Object} value\n * @override\n */\norg.apache.flex.B.prototype.foo = function(value) {\n baz = '';\n};";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_overrideSuperCall()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; override public function foo():void {super.foo();};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @override\n */\norg.apache.flex.B.prototype.foo = function() {\n org.apache.flex.B.base(this, 'foo');\n};";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_setterCall()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; public function set baz(value:Object):void {}; public function set foo(value:Object):void {baz = value;};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.B.prototype.set_baz = function(value) {\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.B.prototype.set_foo = function(value) {\n this.set_baz(value);\n};";
- assertOut(expected);
- }
-
- @Test
- public void testMethod_overrideSetterSuperCall()
- {
- IClassNode node = getClassNode("public class B {public function B() {}; override public function set foo(value:Object):void {super.foo = value;};}");
- asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @param {Object} value\n * @override\n */\norg.apache.flex.B.prototype.set_foo = function(value) {\n org.apache.flex.B.base(this, 'set_foo', value);\n};";
- assertOut(expected);
- }
-
- @Override
- @Test
- public void testExtendsConstructor_withArguments()
- {
- IClassNode node = getClassNode("public class A extends spark.components.Button {public function A(arg1:String, arg2:int) {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.flex.A = function(arg1, arg2) {\n org.apache.flex.A.base(this, 'constructor', arg1, arg2);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
- }
-
- @Override
- @Test
- public void testFields()
- {
- IClassNode node = getClassNode("public class A {public var a:Object;protected var b:String; "
- + "private var c:int; internal var d:uint; var e:Number}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};\n\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
- }
-
- @Test
- public void testFieldWithEmbed()
- {
- IClassNode node = getClassNode("public class A {[Embed(source=\"LuminosityMaskFilter.pbj\", mimeType=\"application/octet-stream\")]\nprivate static var ShaderClass:Class;}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};\n\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.ShaderClass;");
- }
-
- @Test
- public void testFieldWithObjectAssignment()
- {
- IClassNode node = getClassNode("public class A {private var controlBarGroupProperties:Object = { visible: true }; private var _visible:Boolean; public function get visible():Boolean { return _visible; }; public function set visible(value:Boolean):void { _visible = value; };}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};\n\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.prototype.controlBarGroupProperties = {visible:true};\n\n\n/**\n * @private\n * @type {boolean}\n */\norg.apache.flex.A.prototype._visible;\n\n\n/**\n * @export\n * @return {boolean}\n */\norg.apache.flex.A.prototype.get_visible = function() {\n return this._visible;\n};\n\n\n/**\n * @export\n * @param {boolean} value\n */\norg.apache.flex.A.prototype.set_visible = function(value) {\n this._visible = value;\n};");
- }
-
- @Override
- @Test
- public void testConstants()
- {
- IClassNode node = getClassNode("public class A {"
- + "public static const A:int = 42;"
- + "protected static const B:Number = 42;"
- + "private static const C:Number = 42;"
- + "foo_bar static const C:String = 'me' + 'you';");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.C = 'me' + 'you';\n};\n\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C;");
- }
-
- @Override
- @Test
- public void testAccessors()
- {
- IClassNode node = getClassNode("public class A {"
- + "public function get foo1():Object{return null;}"
- + "public function set foo1(value:Object):void{}"
- + "protected function get foo2():Object{return null;}"
- + "protected function set foo2(value:Object):void{}"
- + "private function get foo3():Object{return null;}"
- + "private function set foo3(value:Object):void{}"
- + "internal function get foo5():Object{return null;}"
- + "internal function set foo5(value:Object):void{}"
- + "foo_bar function get foo6():Object{return null;}"
- + "foo_bar function set foo6(value:Object):void{}" + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo1 = function() {\n return null;\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo1 = function(value) {\n};\n\n\n/**\n * @protected\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo2 = function() {\n return null;\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo3 = function() {\n return null;\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo3 = function(value) {\n};\n\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo5 = function() {\n return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo5 = function(value) {\
n};\n\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo6 = function() {\n return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo6 = function(value) {\n};");
- }
-
- @Override
- @Test
- public void testMethods()
- {
- IClassNode node = getClassNode("public class A {"
- + "public function foo1():Object{return null;}"
- + "public final function foo1a():Object{return null;}"
- + "override public function foo1b():Object{return super.foo1b();}"
- + "protected function foo2(value:Object):void{}"
- + "private function foo3(value:Object):void{}"
- + "internal function foo5(value:Object):void{}"
- + "foo_bar function foo6(value:Object):void{}"
- + "public static function foo7(value:Object):void{}"
- + "foo_bar static function foo7(value:Object):void{}" + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n return null;\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n return null;\n};\n\n\n/**\n * @export\n * @return {Object}\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n return org.apache.flex.A.base(this, 'foo1b');\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo3 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo5 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo6 = function(value) {\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};
\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};");
- }
-
- @Test
- public void testMethodsWithLocalFunctions()
- {
- IClassNode node = getClassNode("public class B {"
- + "public function foo1():Object{function bar1():Object {return null;}; return bar1()}"
- + "public function foo2():Object{function bar2(param1:Object):Object {return null;}; return bar2('foo');}"
- + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n function bar1() {\n return null;\n };\n return goog.bind(bar1, this)();\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n function bar2(param1) {\n return null;\n };\n return goog.bind(bar2, this)('foo');\n};");
- }
-
- @Test
- public void testMethodsWithLocalFunctions2()
- {
- IClassNode node = getClassNode("public class B {"
- + "public var baz1:String;"
- + "public function foo1():String{function bar1():String {return baz1;}; return bar1()}"
- + "public function foo2():String{function bar2(param1:String):String {return param1 + baz1;}; return bar2('foo');}"
- + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.baz1;\n\n\n/**\n * @export\n * @return {string}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n function bar1() {\n return this.baz1;\n };\n return goog.bind(bar1, this)();\n};\n\n\n/**\n * @export\n * @return {string}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n function bar2(param1) {\n return param1 + this.baz1;\n };\n return goog.bind(bar2, this)('foo');\n};");
- }
-
- @Test
- public void testClassWithoutConstructor()
- {
- /* AJH couldn't find a way to reproduce the code paths
- * in a simple test case. May require multiple compilation
- * units in the same package.
- */
-
- // (erikdebruin) what's wrong with this test case and/or the resulting code?
-
- // (erikdebruin) if you're looking for a way to test multiple cu's
- // (a project), look in 'TestGoogProject' for an example
-
- IClassNode node = getClassNode("public class B {"
- + "public function clone():B { return new B() }"
- + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {};\n\n\n/**\n * @export\n * @return {org.apache.flex.B}\n */\norg.apache.flex.B.prototype.clone = function() {\n return new org.apache.flex.B();\n};");
- }
-
- @Override
- protected void addLibraries(List<File> libraries)
- {
- libraries.addAll(testAdapter.getLibraries(true));
- }
-
- @Override
- protected IClassNode getClassNode(String code)
- {
- String source = "package org.apache.flex {import flash.events.IEventDispatcher;import mx.logging.ILogger;import spark.components.Button;"
- + code + "}";
- IFileNode node = compileAS(source);
- IClassNode child = (IClassNode) findFirstDescendantOfType(node,
- IClassNode.class);
- return child;
- }
-
-
- protected IBackend createBackend()
- {
- return new VF2JSBackend();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSExpressions.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSExpressions.java
deleted file mode 100644
index 3ba79e7..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSExpressions.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogExpressions;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
-import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
-import org.apache.flex.compiler.tree.as.IFunctionCallNode;
-import org.apache.flex.compiler.tree.as.IFunctionNode;
-import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
-import org.apache.flex.compiler.tree.as.IVariableNode;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestVF2JSExpressions extends TestGoogExpressions
-{
-
- @Ignore
- @Override
- @Test
- public void testVisitLanguageIdentifierNode_SuperMember()
- {
- // (erikdebruin) this test doesn't make sense in VF2JS context
- IMemberAccessExpressionNode node = (IMemberAccessExpressionNode) getNode(
- "if (a) super.foo;", IMemberAccessExpressionNode.class);
- asBlockWalker.visitMemberAccessExpression(node);
- assertOut("super.foo");
- }
-
- @Override
- @Test
- public void testVisitLanguageIdentifierNode_SuperMethod_1()
- {
- IFunctionNode node = getMethod("function foo(){if (a) super.foo();}");
- asBlockWalker.visitFunction(node);
- assertOut("FalconTest_A.prototype.foo = function() {\n if (a)\n FalconTest_A.base(this, 'foo');\n}");
- }
-
- @Override
- @Test
- public void testVisitLanguageIdentifierNode_SuperMethod_2()
- {
- IFunctionNode node = getMethod("function foo(){if (a) super.foo(a, b, c);}");
- asBlockWalker.visitFunction(node);
- assertOut("FalconTest_A.prototype.foo = function() {\n if (a)\n FalconTest_A.base(this, 'foo', a, b, c);\n}");
- }
-
- @Override
- @Test
- public void testAnonymousFunctionWithParamsReturn()
- {
- IVariableNode node = (IVariableNode) getNode(
- "var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Object} */ a = function(foo, bar) {\n bar = typeof bar !== 'undefined' ? bar : 'goo';\n return -1;\n}");
- }
-
- @Override
- @Test
- public void testAnonymousFunctionAsArgument()
- {
- IFunctionCallNode node = (IFunctionCallNode) getNode(
- "addListener('foo', function(event:Object):void{doit();})",
- IFunctionCallNode.class);
- asBlockWalker.visitFunctionCall(node);
- assertOut("addListener('foo', function(event) {\n doit();\n})");
- }
-
- @Override
- @Test
- public void testVisitAs()
- {
- IBinaryOperatorNode node = getBinaryNode("a as b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("org.apache.flex.utils.Language.as(a, b)");
- }
-
- @Test
- public void testVisitAs2()
- {
- IFunctionNode node = (IFunctionNode) getNode(
- "public class B {public function b(o:Object):int { var a:B; a = o as B; }}",
- IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @export\n * @param {Object} o\n * @return {number}\n */\nfoo.bar.B.prototype.b = function(o) {\n var /** @type {foo.bar.B} */ a;\n a = org.apache.flex.utils.Language.as(o, foo.bar.B);\n}");
- }
-
- @Override
- @Test
- public void testVisitBinaryOperator_Is()
- {
- IBinaryOperatorNode node = getBinaryNode("a is b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("org.apache.flex.utils.Language.is(a, b)");
- }
-
- protected IBackend createBackend()
- {
- return new VF2JSBackend();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
deleted file mode 100644
index eaa79d3..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
-import org.apache.flex.compiler.internal.test.VF2JSTestBase;
-import org.apache.flex.compiler.tree.as.IFileNode;
-import org.apache.flex.utils.ITestAdapter;
-import org.apache.flex.utils.TestAdapterFactory;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * This class tests the production of valid 'goog' JS code from an external
- * file.
- *
- * @author Erik de Bruin
- */
-public class TestVF2JSFile extends VF2JSTestBase
-{
- private static ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
-
- @Ignore
- @Test
- public void testSimple()
- {
- String fileName = "SimpleAS";
-
- IFileNode node = compileAS(fileName, true,
- new File(testAdapter.getUnitTestBaseDir(), "vf2js/files").getPath(),
- false);
-
- asBlockWalker.visitFile(node);
-
- //writeResultToFile(writer.toString(), fileName);
-
- assertOut(getCodeFromFile(fileName + "_result", true,
- "vf2js" + File.separator + "files"));
- }
-
- @Test
- public void testVersion()
- {
- String fileName = "Version";
-
- IFileNode node = compileAS(fileName, true,
- new File(testAdapter.getUnitTestBaseDir(), "vf2js/files").getPath(),
- false);
-
- asBlockWalker.visitFile(node);
-
- //writeResultToFile(writer.toString(), fileName);
-
- assertOut(getCodeFromFile(fileName + "_result", true,
- "vf2js" + File.separator + "files"));
- }
-
- @Override
- protected void addSourcePaths(List<File> sourcePaths)
- {
- sourcePaths.add(new File(testAdapter.getUnitTestBaseDir(), "vf2js/files"));
-
- super.addSourcePaths(sourcePaths);
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new VF2JSBackend();
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
deleted file mode 100644
index fad2b93..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogProject;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.utils.FilenameNormalization;
-import org.apache.flex.utils.TestAdapterFactory;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * This class tests the production of valid 'vf2js' JS code from an external
- * project.
- *
- * @author Erik de Bruin
- */
-public class TestVF2JSProject extends TestGoogProject
-{
-
- private static String projectDirPath = "vf2js/projects";
-
- @Override
- public void setUp()
- {
- project = new FlexJSProject(workspace);
-
- super.setUp();
- }
-
- @Ignore
- @Test
- public void test_imports()
- {
- // crude bypass to allow for successful inheritance
- }
-
- @Test
- public void test_Test()
- {
- String testDirPath = projectDirPath + "/interfaces";
-
- String fileName = "Test";
-
- List<String> compiledFileNames = compileProject(fileName, testDirPath);
-
- assertProjectOut(compiledFileNames, testDirPath);
- }
-
- @Test
- @Ignore
- public void test_SDKTricks()
- {
- String testDirPath = projectDirPath + "/sdk";
-
- String fileName = "SomeSDKClass";
-
- List<String> compiledFileNames = compileProject(fileName, testDirPath);
-
- assertProjectOut(compiledFileNames, testDirPath);
- }
-
- @Test
- public void test_Super()
- {
- String testDirPath = projectDirPath + "/super";
-
- String fileName = "Base";
-
- List<String> compiledFileNames = compileProject(fileName, testDirPath);
-
- assertProjectOut(compiledFileNames, testDirPath);
- }
-
- @Override
- protected void addSourcePaths(List<File> sourcePaths)
- {
- sourcePaths.add(new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- projectDirPath + "/interfaces"));
-
- sourcePaths.add(new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- projectDirPath + "/sdk"));
-
- sourcePaths.add(new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- projectDirPath + "/super"));
-
- super.addSourcePaths(sourcePaths);
- }
-
- @Override
- protected void addLibraries(List<File> libraries)
- {
- libraries.add(new File(FilenameNormalization.normalize(env.FPSDK
- + "/" + env.FPVER + "/playerglobal.swc")));
- libraries.add(new File(FilenameNormalization.normalize(env.SDK
- + "/frameworks/libs/framework.swc")));
- libraries.add(new File(FilenameNormalization.normalize(env.SDK
- + "/frameworks/libs/spark.swc")));
-
- super.addLibraries(libraries);
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new VF2JSBackend();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
deleted file mode 100644
index 2d59b6a..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogStatements;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
-import org.apache.flex.compiler.tree.as.IFileNode;
-import org.apache.flex.compiler.tree.as.IForLoopNode;
-import org.apache.flex.compiler.tree.as.IIfNode;
-import org.apache.flex.compiler.tree.as.ISwitchNode;
-import org.apache.flex.compiler.tree.as.ITryNode;
-import org.apache.flex.compiler.tree.as.IVariableNode;
-import org.apache.flex.compiler.tree.as.IWhileLoopNode;
-import org.apache.flex.compiler.tree.as.IWithNode;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestVF2JSStatements extends TestGoogStatements
-{
- @Override
- public void setUp()
- {
- project = new FlexJSProject(workspace);
- super.setUp();
- }
-
- @Test
- public void testVarDeclaration_withReservedWord()
- {
- IVariableNode node = (IVariableNode) getNode("var max:int = int.MAX_VALUE;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ max = INT.MAX_VALUE");
- }
-
- @Test
- public void testVarDeclaration_withTypeAssignedStringWithNewLine()
- {
- IVariableNode node = (IVariableNode) getNode("var a:String = \"\\n\"",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = \"\\n\"");
- }
-
- @Test
- public void testVarDeclaration_withXMLList()
- {
- IVariableNode node = (IVariableNode) getNode(
- "var childDesc:XMLList = typeDescription.accessor."
- + "(@name == childName) + typeDescription.method."
- + "(@name == childName);",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {XMLList} */ childDesc = 'E4XFilter' + 'E4XFilter'");
- }
-
- @Test
- public void testVarDeclaration_withEmbed()
- {
- IVariableNode node = (IVariableNode) getNode(
- "[Embed(source=\"LuminosityMaskFilter.pbj\", mimeType=\"application/octet-stream\")]\nprivate static var ShaderClass:Class;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Object} */ falconTest_a.ShaderClass");
- }
-
- //----------------------------------
- // const declaration
- //----------------------------------
-
- @Override
- @Test
- public void testConstDeclaration()
- {
- IVariableNode node = (IVariableNode) getNode("const a = 42;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {*} */ a = 42");
- // ToDo (erikdebruin): assertOut("const /** @type {*} */ a = 42");
- }
-
- @Override
- @Test
- public void testConstDeclaration_withType()
- {
- IVariableNode node = (IVariableNode) getNode("const a:int = 42;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = 42");
- // ToDo (erikdebruin): assertOut("const /** @type {number} */ a = 42");
- }
-
- @Override
- @Test
- public void testConstDeclaration_withList()
- {
- IVariableNode node = (IVariableNode) getNode(
- "const a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = 4, /** @type {number} */ b = 11, /** @type {number} */ c = 42");
- // ToDo (erikdebruin): assertOut("const /** @type {number} */ a = 4, /** @type {number} */ b = 11, /** @type {number} */ c = 42");
- }
-
- //----------------------------------
- // for () { }
- //----------------------------------
-
- @Override
- @Test
- public void testVisitFor_1a()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int = 0; i < len; i++) { break; }",
- IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i = 0; i < len; i++) {\n break;\n}");
- }
-
- @Override
- @Test
- public void testVisitFor_1b()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int = 0; i < len; i++) break;", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i = 0; i < len; i++)\n break;");
- }
-
- @Test
- public void testVisitFor_1c()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int = 0, j:int = 3; i < j; i++) break;", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i = 0, /** @type {number} */ j = 3; i < j; i++)\n break;");
- }
-
- @Override
- @Test
- public void testVisitForIn_1()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int in obj) { break; }", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i in obj) {\n break;\n}");
- }
-
- @Override
- @Test
- public void testVisitForIn_1a()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int in obj) break; ", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i in obj)\n break;");
- }
-
- @Override
- @Test
- public void testVisitForEach_1()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for each(var i:int in obj) { break; }", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n{\n break;\n}}\n");
- }
-
- @Override
- @Test
- public void testVisitForEach_1a()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for each(var i:int in obj) break; ", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n break;}\n");
- }
-
- @Test
- public void testVisitForEach_HoistedVar()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "var i:int; for each(i in obj) break; ", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var foreachiter0 in obj) \n{\ni = obj[foreachiter0];\n\n break;}\n");
- }
-
- //----------------------------------
- // try {} catch () {} finally {}
- //----------------------------------
-
- @Override
- @Test
- public void testVisitTry_Catch()
- {
- ITryNode node = (ITryNode) getNode("try { a; } catch (e:Error) { b; }",
- ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n a;\n} catch (e) {\n b;\n}");
- }
-
- @Override
- @Test
- public void testVisitTry_Catch_Finally()
- {
- ITryNode node = (ITryNode) getNode(
- "try { a; } catch (e:Error) { b; } finally { c; }",
- ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n a;\n} catch (e) {\n b;\n} finally {\n c;\n}");
- }
-
- @Override
- @Test
- public void testVisitTry_Catch_Catch_Finally()
- {
- // TODO (erikdebruin) handle multiple 'catch' statements (FW in Wiki)
- ITryNode node = (ITryNode) getNode(
- "try { a; } catch (e:Error) { b; } catch (f:Error) { c; } finally { d; }",
- ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n a;\n} catch (e) {\n b;\n} catch (f) {\n c;\n} finally {\n d;\n}");
- }
-
- @Override
- @Test
- public void testVisitTry_CatchEmpty_FinallyEmpty_()
- {
- ITryNode node = (ITryNode) getNode(
- "try { a; } catch (e:Error) { } finally { }", ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n a;\n} catch (e) {\n} finally {\n}");
- }
-
- //----------------------------------
- // switch {}
- //----------------------------------
-
- @Override
- @Test
- public void testVisitSwitch_1()
- {
- ISwitchNode node = (ISwitchNode) getNode("switch(i){case 1: break;}",
- ISwitchNode.class);
- asBlockWalker.visitSwitch(node);
- assertOut("switch (i) {\n case 1:\n break;\n}");
- }
-
- @Override
- @Test
- public void testVisitSwitch_1a()
- {
- ISwitchNode node = (ISwitchNode) getNode(
- "switch(i){case 1: { break; }}", ISwitchNode.class);
- asBlockWalker.visitSwitch(node);
- // (erikdebruin) the code is valid without the extra braces,
- // i.e. we're good, we "don't care"
- assertOut("switch (i) {\n case 1:\n break;\n}");
- }
-
- @Override
- @Test
- public void testVisitSwitch_2()
- {
- ISwitchNode node = (ISwitchNode) getNode(
- "switch(i){case 1: break; default: return;}", ISwitchNode.class);
- asBlockWalker.visitSwitch(node);
- assertOut("switch (i) {\n case 1:\n break;\n default:\n return;\n}");
- }
-
- @Override
- @Test
- public void testVisitSwitch_3()
- {
- ISwitchNode node = (ISwitchNode) getNode(
- "switch(i){case 1: { var x:int = 42; break; }; case 2: { var y:int = 66; break; }}", ISwitchNode.class);
- asBlockWalker.visitSwitch(node);
- assertOut("switch (i) {\n case 1:\n var /** @type {number} */ x = 42;\n break;\n case 2:\n var /** @type {number} */ y = 66;\n break;\n}");
- }
-
- @Test
- public void testVisitSwitch_EscapedQuotes()
- {
- ISwitchNode node = (ISwitchNode) getNode(
- "switch (type) { case \"string\": { return \"\\\"\" + value.toString() + \"\\\"\"; } }", ISwitchNode.class);
- asBlockWalker.visitSwitch(node);
- assertOut("switch (type) {\n case \"string\":\n return \"\\\"\" + value.toString() + \"\\\"\";\n}");
- }
-
- //----------------------------------
- // if ()
- //----------------------------------
-
- @Override
- @Test
- public void testVisitIf_1()
- {
- IIfNode node = (IIfNode) getNode("if (a) b++;", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a)\n b++;");
- }
-
- @Override
- @Test
- public void testVisitIf_2()
- {
- IIfNode node = (IIfNode) getNode("if (a) b++; else c++;", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a)\n b++;\nelse\n c++;");
- }
-
- @Override
- @Test
- public void testVisitIf_4()
- {
- IIfNode node = (IIfNode) getNode(
- "if (a) b++; else if (c) d++; else if(e) --f;", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a)\n b++;\nelse if (c)\n d++;\nelse if (e)\n --f;");
- }
-
- @Test
- public void testVisitIf_E4X()
- {
- IIfNode node = (IIfNode) getNode(
- "if (numChildren == 0) { if (!typeDescription.@dynamic) { trace(\"warning: no describeType entry for '\" + childName + \"' on non-dynamic type '\" + typeDescription.@name + \"'\"); } }", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (numChildren == 0) {\n if (!this.typeDescription['E4XOperator']) {\n org.apache.flex.utils.Language.trace(\"warning: no describeType entry for '\" + childName + \"' on non-dynamic type '\" + this.typeDescription['E4XOperator'] + \"'\");\n }\n}");
- }
-
- @Test
- public void testVisitIf_E4X_Again()
- {
- IIfNode node = (IIfNode) getNode(
- "if (options.includeReadOnly) { properties = classInfo..accessor.(@access != \"writeonly\") + classInfo..variable; }", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (options.includeReadOnly) {\n properties = 'E4XFilter' + this.classInfo['E4XSelector'];\n}");
- }
-
- @Test
- public void testVisitIf_UnescapedBackSlash()
- {
- IIfNode node = (IIfNode) getNode(
- "if (rootURL && !(url.indexOf(\":\") > -1 || url.indexOf(\"/\") == 0 || url.indexOf(\"\\\\\") == 0)) { var index:int; }", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (rootURL && !(url.indexOf(\":\") > -1 || url.indexOf(\"/\") == 0 || url.indexOf(\"\\\\\") == 0)) {\n var /** @type {number} */ index;\n}");
- }
-
- //----------------------------------
- // if () { }
- //----------------------------------
-
- @Override
- @Test
- public void testVisitIf_1a()
- {
- IIfNode node = (IIfNode) getNode("if (a) { b++; }", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a) {\n b++;\n}");
- }
-
- @Override
- @Test
- public void testVisitIf_1b()
- {
- IIfNode node = (IIfNode) getNode("if (a) { b++; } else { c++; }",
- IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a) {\n b++;\n} else {\n c++;\n}");
- }
-
- @Override
- @Test
- public void testVisitIf_1c()
- {
- IIfNode node = (IIfNode) getNode(
- "if (a) { b++; } else if (b) { c++; } else { d++; }",
- IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a) {\n b++;\n} else if (b) {\n c++;\n} else {\n d++;\n}");
- }
-
- @Override
- @Test
- public void testVisitIf_3()
- {
- IIfNode node = (IIfNode) getNode(
- "if (a) b++; else if (c) d++; else --e;", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a)\n b++;\nelse if (c)\n d++;\nelse\n --e;");
- }
-
- //----------------------------------
- // label : for () {}
- //----------------------------------
-
- @Override
- @Test
- public void testVisitFor_2()
- {
- IForLoopNode node = (IForLoopNode) getNode("for (;;) { break; }",
- IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (;;) {\n break;\n}");
- }
-
- //----------------------------------
- // while () { }
- //----------------------------------
-
- @Override
- @Test
- public void testVisitWhileLoop_1()
- {
- IWhileLoopNode node = (IWhileLoopNode) getNode(
- "while(a > b){a++;--b;}", IWhileLoopNode.class);
- asBlockWalker.visitWhileLoop(node);
- assertOut("while (a > b) {\n a++;\n --b;\n}");
- }
-
- @Override
- @Test
- public void testVisitWhileLoop_1a()
- {
- IWhileLoopNode node = (IWhileLoopNode) getNode("while(a > b) a++;",
- IWhileLoopNode.class);
- asBlockWalker.visitWhileLoop(node);
- assertOut("while (a > b)\n a++;");
- }
-
- //----------------------------------
- // do {} while ()
- //----------------------------------
-
- @Override
- @Test
- public void testVisitWhileLoop_Do_1()
- {
- IWhileLoopNode node = (IWhileLoopNode) getNode(
- "do {a++;--b;} while(a > b);", IWhileLoopNode.class);
- asBlockWalker.visitWhileLoop(node);
- assertOut("do {\n a++;\n --b;\n} while (a > b);");
- }
-
- @Override
- @Test
- public void testVisitWhileLoop_Do_1a()
- {
- IWhileLoopNode node = (IWhileLoopNode) getNode("do a++; while(a > b);",
- IWhileLoopNode.class);
- asBlockWalker.visitWhileLoop(node);
- assertOut("do\n a++;\nwhile (a > b);");
- }
-
- //----------------------------------
- // label : for () {}
- //----------------------------------
-
- @Override
- @Test
- public void testVisitLabel_1()
- {
- LabeledStatementNode node = (LabeledStatementNode) getNode(
- "foo: for each(var i:int in obj) { break foo; }",
- LabeledStatementNode.class);
- asBlockWalker.visitLabeledStatement(node);
- assertOut("foo : for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n{\n break foo;\n}}\n");
- }
-
- @Override
- @Test
- public void testVisitLabel_1a()
- {
- // TODO (mschmalle) LabelStatement messes up in finally{} block, something is wrong there
- LabeledStatementNode node = (LabeledStatementNode) getNode(
- "foo: for each(var i:int in obj) break foo;",
- LabeledStatementNode.class);
- asBlockWalker.visitLabeledStatement(node);
- assertOut("foo : for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n break foo;}\n");
- }
-
- //----------------------------------
- // with () {}
- //----------------------------------
-
- @Test
- public void testVisitWith()
- {
- IWithNode node = (IWithNode) getNode("with (a) { b; }", IWithNode.class);
- asBlockWalker.visitWith(node);
- assertOut("with (a) {\n b;\n}");
- }
-
- @Test
- public void testVisitWith_1a()
- {
- IWithNode node = (IWithNode) getNode("with (a) b;", IWithNode.class);
- asBlockWalker.visitWith(node);
- assertOut("with (a)\n b;");
- }
-
- @Override
- @Test
- public void testVisit()
- {
- IFileNode node = (IFileNode) getNode(
- "try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally { }"
- + "if (d) for (var i:int = 0; i < len; i++) break;"
- + "if (a) { with (ab) { c(); } "
- + "do {a++;do a++; while(a > b);} while(c > d); }"
- + "if (b) { try { a; throw new Error('foo'); } catch (e:Error) { "
- + " switch(i){case 1: break; default: return;}"
- + " } finally { "
- + " d; var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};"
- + " eee.dd; eee.dd; eee.dd; eee.dd;} }"
- + "foo: for each(var i:int in obj) break foo;",
- IFileNode.class);
- asBlockWalker.visitFile(node);
- assertOutWithMetadata("/**\n * FalconTest_A\n *\n * @fileoverview\n *\n * @suppress {checkTypes}\n */\n\ngoog.provide('FalconTest_A');\n\n\n\n/**\n * @constructor\n */\nFalconTest_A = function() {};\n\n\nFalconTest_A.prototype.falconTest_a = function() {\n try {\n a;\n } catch (e) {\n if (a) {\n if (b) {\n if (c)\n b;\n else if (f)\n a;\n else\n e;\n }\n }\n } finally {\n }\n if (d)\n for (var /** @type {number} */ i = 0; i < len; i++)\n break;\n if (a) {\n with (ab) {\n c();\n }\n do {\n a++;\n do\n a++;\n while (a > b);\n } while (c > d);\n }\n if (b) {\n try {\n a;\n throw new Error('foo');\n } catch (e) {\n switch (i) {\n case 1:\n break;\n default:\n return;\n }\n } finally {\n d;\n var /** @type {Object} */ a = function(foo, bar) {\n bar = typeof bar !== 'undefined' ? bar
: 'goo';\n return -1;\n };\n eee.dd;\n eee.dd;\n eee.dd;\n eee.dd;\n }\n }\n foo : for (var foreachiter0 in obj) \n {\n var i = obj[foreachiter0];\n \n break foo;}\n ;\n};\n\n\n/**\n * Metadata\n *\n * @type {Object.<string, Array.<Object>>}\n */\nFalconTest_A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'FalconTest_A', qName: 'FalconTest_A'}] };\n");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new VF2JSBackend();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
deleted file mode 100644
index 93f2a6b..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *
- * 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.mxml.vf2js;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.flex.compiler.internal.test.VF2JSMXMLTestBase;
-import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.apache.flex.utils.ITestAdapter;
-import org.apache.flex.utils.TestAdapterFactory;
-import org.junit.Test;
-
-public class TestVF2JSMXMLApplication extends VF2JSMXMLTestBase
-{
- private static ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
-
- @Override
- protected void addSourcePaths(List<File> sourcePaths)
- {
- sourcePaths.add(new File(testAdapter.getUnitTestBaseDir(), "vf2js/files"));
- sourcePaths.add(new File(testAdapter.getUnitTestBaseDir(), "vf2js/projects/simpleMXML/src"));
-
- super.addSourcePaths(sourcePaths);
- }
-
- @Test
- public void testSimple()
- {
- String fileName = "SimpleMXML";
-
- IMXMLFileNode node = compileMXML(fileName, true,
- new File(testAdapter.getUnitTestBaseDir(), "vf2js/files").getPath(), false);
-
- mxmlBlockWalker.visitFile(node);
-
- //writeResultToFile(writer.toxString(), fileName);
-
- assertOutWithMetadata(getCodeFromFile(fileName + "_result", true, "vf2js/files"));
- }
-
-
- @Test
- public void testSimpleMXMLProject()
- {
- String testDirPath = "vf2js/projects/simpleMXML/src";
-
- String fileName = "SimpleMXML_Project";
-
- List<String> compiledFileNames = compileProject(fileName, testDirPath);
-
- // ToDo (erikdebruin): MXML property initialized with a FunctionCall
- // are not included in the output (the assignment
- // should be handled in the constructor, like in AS
- assertProjectOut(compiledFileNames, testDirPath);
- }
-
- protected void assertProjectOut(List<String> compiledFileNames,
- String testDirPath)
- {
- for (String compiledFileName : compiledFileNames)
- {
- String compiledFilePath = tempDir.getAbsolutePath()
- + File.separator + testDirPath + File.separator
- + compiledFileName + "_output" + "."
- + backend.getOutputExtension();
- String compiledResult = readCodeFile(new File(compiledFilePath));
-
- //System.out.println(compiledResult);
-
- String expectedFilePath = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- testDirPath + "/" + compiledFileName + "_result" + "." + backend.getOutputExtension()).getPath();
- String expectedResult = readCodeFile(new File(expectedFilePath));
-
- assertThat(compiledResult, is(expectedResult));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
deleted file mode 100644
index a421d5e..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- *
- * 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.test;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.flex.compiler.config.Configurator;
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
-import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.targets.JSTarget;
-import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLNode;
-import org.apache.flex.compiler.units.ICompilationUnit;
-import org.apache.flex.utils.FilenameNormalization;
-import org.apache.flex.utils.TestAdapterFactory;
-import org.junit.Ignore;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-@Ignore
-public class VF2JSMXMLTestBase extends MXMLTestBase
-{
-
- @Override
- public void setUp()
- {
- project = new FlexJSProject(workspace);
-
- super.setUp();
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new MXMLVF2JSBackend();
- }
-
-
- @Override
- protected List<String> compileProject(String inputFileName,
- String inputDirName)
- {
- List<String> compiledFileNames = new ArrayList<String>();
-
- String mainFileName = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- inputDirName + "/" + inputFileName + inputFileExtension).getPath();
-
- addDependencies();
-
- String normalizedFileName = FilenameNormalization.normalize(
- mainFileName);
- Collection<ICompilationUnit> compilationUnits =
- workspace.getCompilationUnits(normalizedFileName, project);
- ICompilationUnit mainCU = Iterables.getOnlyElement(
- compilationUnits);
-
- if (project instanceof FlexJSProject)
- ((FlexJSProject) project).mainCU = mainCU;
-
- Configurator projectConfigurator = backend.createConfigurator();
-
- JSTarget target = (JSTarget) backend.createTarget(project,
- projectConfigurator.getTargetSettings(null), null);
-
- target.build(mainCU, new ArrayList<ICompilerProblem>());
-
- List<ICompilationUnit> reachableCompilationUnits = project
- .getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
- for (final ICompilationUnit cu : reachableCompilationUnits)
- {
- ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
-
- if (cuType == ICompilationUnit.UnitType.AS_UNIT
- || cuType == ICompilationUnit.UnitType.MXML_UNIT)
- {
- File outputRootDir = new File(
- FilenameNormalization.normalize(tempDir
- + File.separator + inputDirName));
-
- String qname = "";
- try
- {
- qname = cu.getQualifiedNames().get(0);
- }
- catch (InterruptedException error)
- {
- System.out.println(error);
- }
-
- compiledFileNames.add(qname.replace(".", "/"));
-
- final File outputClassFile = getOutputClassFile(qname
- + "_output", outputRootDir);
-
- ASFilterWriter outputWriter = backend.createWriterBuffer(project);
-
- if (cuType == ICompilationUnit.UnitType.AS_UNIT)
- {
- asEmitter = backend.createEmitter(outputWriter);
- asBlockWalker = backend.createWalker(project, errors, asEmitter);
-
- asBlockWalker.visitCompilationUnit(cu);
- }
- else
- {
- mxmlEmitter = backend.createMXMLEmitter(outputWriter);
-
- mxmlBlockWalker = backend.createMXMLWalker(project, errors,
- mxmlEmitter, asEmitter, asBlockWalker);
-
- mxmlBlockWalker.visitCompilationUnit(cu);
- }
-
- //System.out.println(outputWriter.toString());
-
- try
- {
- BufferedOutputStream out = new BufferedOutputStream(
- new FileOutputStream(outputClassFile));
-
- out.write(outputWriter.toString().getBytes());
- out.flush();
- out.close();
- }
- catch (Exception error)
- {
- System.out.println(error);
- }
-
- outputWriter = null;
- }
- }
-
- return compiledFileNames;
- }
-
- //--------------------------------------------------------------------------
- // Node "factory"
- //--------------------------------------------------------------------------
-
- public static final int WRAP_LEVEL_DOCUMENT = 1;
- public static final int WRAP_LEVEL_NODE = 2;
-
- protected IMXMLNode getNode(String code, Class<? extends IMXMLNode> type,
- int wrapLevel)
- {
- if (wrapLevel >= WRAP_LEVEL_NODE)
- code = "<s:Button " + code + "></s:Button>";
-
- if (wrapLevel >= WRAP_LEVEL_DOCUMENT)
- code = ""
- + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
- + " xmlns:s=\"library://ns.adobe.com/flex/spark\""
- + " xmlns:mx=\"library://ns.adobe.com/flex/mx\">\n"
- + code + "\n"
- + "</s:Application>";
-
- IMXMLFileNode node = compileMXML(code);
-
- if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
- {
- IMXMLNode pnode = findFirstDescendantOfType(node, type);
-
- IMXMLNode cnode = findFirstDescendantOfType(pnode, type);
-
- return cnode;
- }
- else
- {
- return findFirstDescendantOfType(node, type);
- }
- }
-
- protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
- Class<? extends IMXMLNode> nodeType)
- {
-
- int n = node.getChildCount();
- for (int i = 0; i < n; i++)
- {
- IMXMLNode child = (IMXMLNode) node.getChild(i);
- if (nodeType.isInstance(child))
- return child;
-
- IMXMLNode found = findFirstDescendantOfType(child,
- nodeType);
- if (found != null)
- return found;
- }
-
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
deleted file mode 100644
index f6cbf58..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *
- * 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.test;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.flex.compiler.config.Configurator;
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
-import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.targets.JSTarget;
-import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLNode;
-import org.apache.flex.compiler.units.ICompilationUnit;
-import org.apache.flex.utils.FilenameNormalization;
-import org.apache.flex.utils.ITestAdapter;
-import org.apache.flex.utils.TestAdapterFactory;
-import org.junit.Ignore;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-@Ignore
-public class VF2JSTestBase extends MXMLTestBase
-{
- private static ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
-
- @Override
- public void setUp()
- {
- project = new FlexJSProject(workspace);
-
- super.setUp();
- }
-
- @Override
- public void tearDown()
- {
- asEmitter = null;
- asBlockWalker = null;
- mxmlEmitter = null;
- mxmlBlockWalker = null;
-
- super.tearDown();
- }
-
- @Override
- protected void addSourcePaths(List<File> sourcePaths)
- {
- //sourcePaths.add(new File(FilenameNormalization.normalize("")));
-
- super.addSourcePaths(sourcePaths);
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new VF2JSBackend();
- }
-
- @Override
- protected List<String> compileProject(String inputFileName,
- String inputDirName)
- {
- List<String> compiledFileNames = new ArrayList<String>();
-
- String mainFileName = new File(testAdapter.getUnitTestBaseDir(),
- inputDirName + "/" + inputFileName + inputFileExtension).getPath();
-
- addDependencies();
-
- String normalizedFileName = FilenameNormalization.normalize(
- mainFileName);
- Collection<ICompilationUnit> compilationUnits =
- workspace.getCompilationUnits(normalizedFileName, project);
- ICompilationUnit mainCU = Iterables.getOnlyElement(
- compilationUnits);
-
- if (project instanceof FlexJSProject)
- ((FlexJSProject) project).mainCU = mainCU;
-
- Configurator projectConfigurator = backend.createConfigurator();
-
- JSTarget target = (JSTarget) backend.createTarget(project,
- projectConfigurator.getTargetSettings(null), null);
-
- target.build(mainCU, new ArrayList<ICompilerProblem>());
-
- List<ICompilationUnit> reachableCompilationUnits = project
- .getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
- for (final ICompilationUnit cu : reachableCompilationUnits)
- {
- ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
-
- if (cuType == ICompilationUnit.UnitType.AS_UNIT
- || cuType == ICompilationUnit.UnitType.MXML_UNIT)
- {
- File outputRootDir = new File(
- FilenameNormalization.normalize(tempDir
- + File.separator + inputDirName));
-
- String qname = "";
- try
- {
- qname = cu.getQualifiedNames().get(0);
- }
- catch (InterruptedException error)
- {
- System.out.println(error);
- }
-
- compiledFileNames.add(qname.replace(".", "/"));
-
- final File outputClassFile = getOutputClassFile(qname
- + "_output", outputRootDir);
-
- ASFilterWriter outputWriter = backend.createWriterBuffer(project);
-
- //asEmitter = backend.createEmitter(outputWriter);
- //asBlockWalker = backend.createWalker(project, errors, asEmitter);
-
- if (cuType == ICompilationUnit.UnitType.AS_UNIT)
- {
- asBlockWalker.visitCompilationUnit(cu);
- }
- else
- {
- //mxmlEmitter = backend.createMXMLEmitter(outputWriter);
-
- //mxmlBlockWalker = backend.createMXMLWalker(project, errors,
- // mxmlEmitter, asEmitter, asBlockWalker);
-
- mxmlBlockWalker.visitCompilationUnit(cu);
- }
-
- System.out.println(outputWriter.toString());
-
- try
- {
- BufferedOutputStream out = new BufferedOutputStream(
- new FileOutputStream(outputClassFile));
-
- out.write(outputWriter.toString().getBytes());
- out.flush();
- out.close();
- }
- catch (Exception error)
- {
- System.out.println(error);
- }
-
- outputWriter = null;
- }
- }
-
- return compiledFileNames;
- }
-
- //--------------------------------------------------------------------------
- // Node "factory"
- //--------------------------------------------------------------------------
-
- public static final int WRAP_LEVEL_DOCUMENT = 1;
- public static final int WRAP_LEVEL_NODE = 2;
-
- protected IMXMLNode getNode(String code, Class<? extends IMXMLNode> type,
- int wrapLevel)
- {
- if (wrapLevel >= WRAP_LEVEL_NODE)
- code = "<s:Button " + code + "></s:Button>";
-
- if (wrapLevel >= WRAP_LEVEL_DOCUMENT)
- code = ""
- + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
- + " xmlns:s=\"library://ns.adobe.com/flex/spark\""
- + " xmlns:mx=\"library://ns.adobe.com/flex/mx\">\n"
- + code + "\n"
- + "</s:Application>";
-
- IMXMLFileNode node = compileMXML(code);
-
- if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
- {
- IMXMLNode pnode = findFirstDescendantOfType(node, type);
-
- IMXMLNode cnode = findFirstDescendantOfType(pnode, type);
-
- return cnode;
- }
- else
- {
- return findFirstDescendantOfType(node, type);
- }
- }
-
- protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
- Class<? extends IMXMLNode> nodeType)
- {
-
- int n = node.getChildCount();
- for (int i = 0; i < n; i++)
- {
- IMXMLNode child = (IMXMLNode) node.getChild(i);
- if (nodeType.isInstance(child))
- return child;
-
- IMXMLNode found = findFirstDescendantOfType(child,
- nodeType);
- if (found != null)
- return found;
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/files/SimpleAS.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/files/SimpleAS.as b/compiler-jx/src/test/resources/vf2js/files/SimpleAS.as
deleted file mode 100644
index c4bd427..0000000
--- a/compiler-jx/src/test/resources/vf2js/files/SimpleAS.as
+++ /dev/null
@@ -1,43 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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
-{
-
-import flash.events.IEventDispatcher;
-
-import mx.components.Button;
-
-import spark.components.Button;
-
-public dynamic class A extends spark.components.Button implements IEventDispatcher
-{
- public static const MY_CLASS_CONST:String = "myClassConst";
-
- public function A()
- {
- trace(typeof "a");
- }
-
- private var _a:ArgumentError = new ArgumentError();
-
- private var _mxButton:mx.components.Button = new mx.components.Button();
-
- public const MY_INSTANCE_CONST:String = "myInstanceConst";
-}
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/files/SimpleAS_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/files/SimpleAS_result.js b/compiler-jx/src/test/resources/vf2js/files/SimpleAS_result.js
deleted file mode 100644
index a063d87..0000000
--- a/compiler-jx/src/test/resources/vf2js/files/SimpleAS_result.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * org.apache.flex.A
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('org.apache.flex.A');
-
-
-
-/**
- * @constructor
- * @extends {vf2js_s.components.Button}
- * @implements {flash.events.IEventDispatcher}
- */
-org.apache.flex.A = function() {
- org.apache.flex.A.base(this, 'constructor');
- org.apache.flex.utils.Language.trace(typeof("a"));
-};
-goog.inherits(org.apache.flex.A, vf2js_s.components.Button);
-
-
-/**
- * @const
- * @type {string}
- */
-org.apache.flex.A.MY_CLASS_CONST = "myClassConst";
-
-
-/**
- * @private
- * @type {ArgumentError}
- */
-org.apache.flex.A.prototype._a = new ArgumentError();
-
-
-/**
- * @private
- * @type {vf2js_mx.components.Button}
- */
-org.apache.flex.A.prototype._mxButton = new vf2js_mx.components.Button();
-
-
-/**
- * @const
- * @type {string}
- */
-org.apache.flex.A.prototype.MY_INSTANCE_CONST = "myInstanceConst";
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-org.apache.flex.A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'A', qName: 'org.apache.flex.A'}], interfaces: [flash.events.IEventDispatcher] };
-
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/files/SimpleMXML.mxml
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/files/SimpleMXML.mxml b/compiler-jx/src/test/resources/vf2js/files/SimpleMXML.mxml
deleted file mode 100644
index a403052..0000000
--- a/compiler-jx/src/test/resources/vf2js/files/SimpleMXML.mxml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
-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.
-
--->
-<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx">
-
- <s:Button label="hello" x="100" />
-
- <s:Button label="bye" x="200" />
-
-</vf2js_s:Application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/test/resources/vf2js/files/SimpleMXML_result.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/vf2js/files/SimpleMXML_result.js b/compiler-jx/src/test/resources/vf2js/files/SimpleMXML_result.js
deleted file mode 100644
index 0beed58..0000000
--- a/compiler-jx/src/test/resources/vf2js/files/SimpleMXML_result.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed 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.
- */
-/**
- * SimpleMXML
- *
- * @fileoverview
- *
- * @suppress {checkTypes}
- */
-
-goog.provide('SimpleMXML');
-
-goog.require('spark.components.Application');
-goog.require('spark.components.Button');
-
-
-
-
-/**
- * @constructor
- * @extends {spark.components.Application}
- */
-SimpleMXML = function() {
- SimpleMXML.base(this, 'constructor');
-
- /**
- * @private
- * @type {spark.components.Button}
- */
- this.$ID0;
-
- /**
- * @private
- * @type {spark.components.Button}
- */
- this.$ID1;
-};
-goog.inherits(SimpleMXML, spark.components.Application);
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-SimpleMXML.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'SimpleMXML', qName: 'SimpleMXML' }] };
-
-
-/**
- * start
- *
- * @export
- */
-SimpleMXML.prototype.start = function () {
-};
-
[6/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
deleted file mode 100644
index 4f9d5f2..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSEmitter.java
+++ /dev/null
@@ -1,1950 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import java.io.FilterWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
-import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
-import org.apache.flex.compiler.codegen.js.vf2js.IJSVF2JSEmitter;
-import org.apache.flex.compiler.common.ASModifier;
-import org.apache.flex.compiler.common.ModifiersSet;
-import org.apache.flex.compiler.constants.IASLanguageConstants;
-import org.apache.flex.compiler.definitions.IClassDefinition;
-import org.apache.flex.compiler.definitions.IDefinition;
-import org.apache.flex.compiler.definitions.IFunctionDefinition;
-import org.apache.flex.compiler.definitions.IFunctionDefinition.FunctionClassification;
-import org.apache.flex.compiler.definitions.INamespaceDefinition;
-import org.apache.flex.compiler.definitions.IPackageDefinition;
-import org.apache.flex.compiler.definitions.IParameterDefinition;
-import org.apache.flex.compiler.definitions.ITypeDefinition;
-import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
-import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
-import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
-import org.apache.flex.compiler.internal.definitions.ClassDefinition;
-import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
-import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
-import org.apache.flex.compiler.internal.definitions.ParameterDefinition;
-import org.apache.flex.compiler.internal.definitions.VariableDefinition;
-import org.apache.flex.compiler.internal.projects.CompilerProject;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.scopes.ASProjectScope;
-import org.apache.flex.compiler.internal.scopes.PackageScope;
-import org.apache.flex.compiler.internal.scopes.TypeScope;
-import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAssignmentNode;
-import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
-import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
-import org.apache.flex.compiler.internal.tree.as.FunctionNode;
-import org.apache.flex.compiler.internal.tree.as.NonResolvingIdentifierNode;
-import org.apache.flex.compiler.internal.tree.as.ParameterNode;
-import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
-import org.apache.flex.compiler.internal.tree.as.UnaryOperatorAtNode;
-import org.apache.flex.compiler.projects.ICompilerProject;
-import org.apache.flex.compiler.scopes.IASScope;
-import org.apache.flex.compiler.tree.ASTNodeID;
-import org.apache.flex.compiler.tree.as.IASNode;
-import org.apache.flex.compiler.tree.as.IAccessorNode;
-import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
-import org.apache.flex.compiler.tree.as.IClassNode;
-import org.apache.flex.compiler.tree.as.IContainerNode;
-import org.apache.flex.compiler.tree.as.IDefinitionNode;
-import org.apache.flex.compiler.tree.as.IEmbedNode;
-import org.apache.flex.compiler.tree.as.IExpressionNode;
-import org.apache.flex.compiler.tree.as.IForLoopNode;
-import org.apache.flex.compiler.tree.as.IFunctionCallNode;
-import org.apache.flex.compiler.tree.as.IFunctionNode;
-import org.apache.flex.compiler.tree.as.IGetterNode;
-import org.apache.flex.compiler.tree.as.IIdentifierNode;
-import org.apache.flex.compiler.tree.as.IInterfaceNode;
-import org.apache.flex.compiler.tree.as.IKeywordNode;
-import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
-import org.apache.flex.compiler.tree.as.ILiteralNode;
-import org.apache.flex.compiler.tree.as.ILiteralNode.LiteralType;
-import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
-import org.apache.flex.compiler.tree.as.IParameterNode;
-import org.apache.flex.compiler.tree.as.ISetterNode;
-import org.apache.flex.compiler.tree.as.ITypeNode;
-import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
-import org.apache.flex.compiler.tree.as.IVariableExpressionNode;
-import org.apache.flex.compiler.tree.as.IVariableNode;
-import org.apache.flex.compiler.units.ICompilationUnit;
-import org.apache.flex.compiler.utils.ASNodeUtils;
-import org.apache.flex.compiler.utils.NativeUtils;
-
-/**
- * Concrete implementation of the 'vf2js' JavaScript production.
- *
- * @author Erik de Bruin
- */
-public class JSVF2JSEmitter extends JSGoogEmitter implements IJSVF2JSEmitter
-{
-
- public JSVF2JSEmitter(FilterWriter out)
- {
- super(out);
- }
-
- @Override
- protected String getIndent(int numIndent)
- {
- final StringBuilder sb = new StringBuilder();
- for (int i = 0; i < numIndent; i++)
- sb.append(JSFlexJSEmitterTokens.INDENT.getToken());
- return sb.toString();
- }
-
- @Override
- protected void emitMemberName(IDefinitionNode node)
- {
- write(node.getName());
- }
-
- @Override
- public void emitClass(IClassNode node)
- {
- IClassDefinition definition = node.getDefinition();
- getModel().setCurrentClass(definition);
-
- project = getWalker().getProject();
-
- IFunctionDefinition ctorDefinition = definition.getConstructor();
-
- // Static-only (Singleton) classes may not have a constructor
- if (ctorDefinition != null)
- {
- IFunctionNode ctorNode = (IFunctionNode) ctorDefinition.getNode();
- if (ctorNode != null)
- {
- // constructor
- emitMethod(ctorNode);
- write(ASEmitterTokens.SEMICOLON);
- }
- else
- {
- String qname = parseQualifiedName(definition);
- if (qname != null && !qname.equals(""))
- {
- write(qname);
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.FUNCTION);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.PAREN_CLOSE);
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.BLOCK_OPEN);
- writeNewline();
- write(ASEmitterTokens.BLOCK_CLOSE);
- write(ASEmitterTokens.SEMICOLON);
- }
- }
- }
-
- IDefinitionNode[] dnodes = node.getAllMemberNodes();
- for (IDefinitionNode dnode : dnodes)
- {
- if (dnode.getNodeID() == ASTNodeID.VariableID)
- {
- writeNewline();
- writeNewline();
- writeNewline();
- emitField((IVariableNode) dnode);
- write(ASEmitterTokens.SEMICOLON);
- }
- else if (dnode.getNodeID() == ASTNodeID.FunctionID)
- {
- if (!((IFunctionNode) dnode).isConstructor())
- {
- writeNewline();
- writeNewline();
- writeNewline();
- emitMethod((IFunctionNode) dnode);
- write(ASEmitterTokens.SEMICOLON);
- }
- }
- else if (dnode.getNodeID() == ASTNodeID.GetterID
- || dnode.getNodeID() == ASTNodeID.SetterID)
- {
- writeNewline();
- writeNewline();
- writeNewline();
- emitAccessors((IAccessorNode) dnode);
- write(ASEmitterTokens.SEMICOLON);
- }
- }
- }
-
- @Override
- public void emitInterface(IInterfaceNode node)
- {
- ICompilerProject project = getWalker().getProject();
-
- getDocEmitter().emitInterfaceDoc(node, project);
-
- String qname = parseQualifiedName(node);
- if (qname != null && !qname.equals(""))
- {
- write(qname);
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.FUNCTION);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.PAREN_CLOSE);
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.BLOCK_OPEN);
- writeNewline();
- write(ASEmitterTokens.BLOCK_CLOSE);
- write(ASEmitterTokens.SEMICOLON);
- }
-
- final IDefinitionNode[] members = node.getAllMemberDefinitionNodes();
- for (IDefinitionNode mnode : members)
- {
- boolean isAccessor = mnode.getNodeID() == ASTNodeID.GetterID
- || mnode.getNodeID() == ASTNodeID.SetterID;
-
- writeNewline();
- writeNewline();
- writeNewline();
-
- getDocEmitter().emitInterfaceMemberDoc(mnode, project);
-
- write(qname);
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSEmitterTokens.PROTOTYPE);
- write(ASEmitterTokens.MEMBER_ACCESS);
- if (isAccessor)
- {
- writeGetSetPrefix(mnode.getNodeID() == ASTNodeID.GetterID);
- }
- write(parseQualifiedName(mnode));
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.FUNCTION);
- emitParameters(((IFunctionNode) mnode).getParametersContainerNode());
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.BLOCK_OPEN);
- write(ASEmitterTokens.BLOCK_CLOSE);
- write(ASEmitterTokens.SEMICOLON);
- }
- }
-
- @Override
- public void emitFunctionBlockHeader(IFunctionNode node)
- {
- IDefinition def = node.getDefinition();
- boolean isStatic = false;
- if (def != null && def.isStatic())
- isStatic = true;
- boolean isLocal = false;
- if (node.getFunctionClassification() == IFunctionDefinition.FunctionClassification.LOCAL)
- isLocal = true;
- if (EmitterUtils.hasBody(node) && !isStatic && !isLocal)
- emitSelfReference(node);
-
- emitRestParameterCodeBlock(node);
-
- emitDefaultParameterCodeBlock(node);
-
- if (node.isConstructor())
- {
- emitVarNonLiteralAssignments();
- }
-
- if (node.isConstructor() && hasSuperClass(node)
- && !EmitterUtils.hasSuperCall(node.getScopedNode()))
- emitSuperCall(node, JSSessionModel.CONSTRUCTOR_FULL);
- }
-
- private void emitVarNonLiteralAssignments()
- {
- // (erikdebruin): If the initial value of a variable is set using
- // a method, JS needs this initialization to be done
- // in the constructor
- IClassNode cdnode = (IClassNode) getModel().getCurrentClass().getNode();
- IDefinitionNode[] dnodes = cdnode.getAllMemberNodes();
- for (IDefinitionNode dnode : dnodes)
- {
- if (dnode.getNodeID() == ASTNodeID.VariableID)
- {
- IVariableNode vnode = (IVariableNode) dnode;
- IExpressionNode avnode = vnode.getAssignedValueNode();
- if (avnode != null && !(avnode instanceof ILiteralNode)
- && !(avnode instanceof IEmbedNode))
- {
- writeNewline("", true);
- if (vnode.hasModifier(ASModifier.STATIC))
- {
- write(parseQualifiedName(cdnode));
- }
- else
- {
- write(ASEmitterTokens.THIS);
- }
- write(ASEmitterTokens.MEMBER_ACCESS);
- writeToken(vnode.getName());
- writeToken(ASEmitterTokens.EQUAL);
- getWalker().walk(avnode);
- indentPop();
- writeNewline(ASEmitterTokens.SEMICOLON);
- }
- }
- }
- }
-
- @Override
- public void emitVarDeclaration(IVariableNode node)
- {
- if (!(node instanceof ChainedVariableNode))
- {
- // (erikdebruin): check for 'var i:int = 0, j:int = 0' containers
- IASNode pnode = node.getParent();
- if (!(pnode instanceof IVariableExpressionNode)
- || node.getChild(0) instanceof IKeywordNode)
- {
- emitMemberKeyword(node);
- }
- }
-
- IExpressionNode avnode = node.getAssignedValueNode();
- if (avnode != null)
- {
- IDefinition def = avnode.resolveType(getWalker().getProject());
-
- String opcode = avnode.getNodeID().getParaphrase();
- if (opcode != "AnonymousFunction")
- getDocEmitter().emitVarDoc(node, def, getWalker().getProject());
- }
- else
- {
- getDocEmitter().emitVarDoc(node, null, getWalker().getProject());
- }
-
- emitDeclarationName(node);
- if (avnode != null && !(avnode instanceof IEmbedNode))
- {
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.EQUAL);
- emitAssignedValue(avnode);
- }
-
- if (!(node instanceof ChainedVariableNode))
- {
- // check for chained variables
- int len = node.getChildCount();
- for (int i = 0; i < len; i++)
- {
- IASNode child = node.getChild(i);
- if (child instanceof ChainedVariableNode)
- {
- writeToken(ASEmitterTokens.COMMA);
- emitVarDeclaration((IVariableNode) child);
- }
- }
- }
- }
-
- @Override
- public void emitMemberKeyword(IDefinitionNode node)
- {
- if (node instanceof IFunctionNode)
- {
- writeToken(ASEmitterTokens.FUNCTION);
- }
- else if (node instanceof IVariableNode)
- {
- writeToken(ASEmitterTokens.VAR);
- }
- }
-
- @Override
- public void emitField(IVariableNode node)
- {
- IDefinition definition = EmitterUtils.getClassDefinition(node);
-
- IDefinition def = null;
- IExpressionNode enode = node.getVariableTypeNode();//getAssignedValueNode();
- if (enode != null)
- {
- if (project == null)
- project = getWalker().getProject();
-
- def = enode.resolveType(project);
- }
-
- getDocEmitter().emitFieldDoc(node, def, project);
-
- IDefinition ndef = node.getDefinition();
-
- ModifiersSet modifierSet = ndef.getModifiers();
- String root = "";
- if (modifierSet != null && !modifierSet.hasModifier(ASModifier.STATIC))
- {
- root = JSEmitterTokens.PROTOTYPE.getToken();
- root += ASEmitterTokens.MEMBER_ACCESS.getToken();
- }
-
- if (definition == null)
- definition = ndef.getContainingScope().getDefinition();
-
- write(parseQualifiedName(definition)
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + root
- + node.getName());
-
- IExpressionNode vnode = node.getAssignedValueNode();
- if (vnode != null && vnode instanceof ILiteralNode)
- {
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.EQUAL);
- getWalker().walk(vnode);
- }
-
- if (!(node instanceof ChainedVariableNode))
- {
- int len = node.getChildCount();
- for (int i = 0; i < len; i++)
- {
- IASNode child = node.getChild(i);
- if (child instanceof ChainedVariableNode)
- {
- writeNewline(ASEmitterTokens.SEMICOLON);
- writeNewline();
- emitField((IVariableNode) child);
- }
- }
- }
- if (node.getNodeID() == ASTNodeID.BindableVariableID)
- {
- // [Bindable]
- writeNewline(ASEmitterTokens.SEMICOLON.getToken());
- writeNewline();
- writeNewline("/**");
- writeNewline("@export");
- writeNewline(" */");
- writeNewline(parseQualifiedName(definition)
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + root + "get_"
- + node.getName() + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.EQUAL.getToken()
- + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.FUNCTION.getToken()
- + ASEmitterTokens.PAREN_OPEN.getToken()
- + ASEmitterTokens.PAREN_CLOSE.getToken()
- + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.BLOCK_OPEN.getToken());
- writeNewline(ASEmitterTokens.RETURN.getToken()
- + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.THIS.getToken()
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + node.getName()
- + ASEmitterTokens.SEMICOLON.getToken());
- writeNewline(ASEmitterTokens.BLOCK_CLOSE.getToken()
- + ASEmitterTokens.SEMICOLON.getToken());
- writeNewline();
- writeNewline("/**");
- writeNewline("@export");
- writeNewline(" */");
- writeNewline(parseQualifiedName(definition)
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + root + "set_"
- + node.getName() + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.EQUAL.getToken()
- + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.FUNCTION.getToken()
- + ASEmitterTokens.PAREN_OPEN.getToken() + "value"
- + ASEmitterTokens.PAREN_CLOSE.getToken()
- + ASEmitterTokens.SPACE.getToken()
- + ASEmitterTokens.BLOCK_OPEN.getToken());
- writeNewline("if (value != " + ASEmitterTokens.THIS.getToken()
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + node.getName()
- + ") {");
- writeNewline(" var oldValue = "
- + ASEmitterTokens.THIS.getToken()
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + node.getName()
- + ASEmitterTokens.SEMICOLON.getToken());
- writeNewline(" " + ASEmitterTokens.THIS.getToken()
- + ASEmitterTokens.MEMBER_ACCESS.getToken() + node.getName()
- + " = value;");
- writeNewline(" this.dispatchEvent(org.apache.flex.events.ValueChangeEvent.createUpdateEvent(");
- writeNewline(" this, \"" + node.getName()
- + "\", oldValue, value));");
- writeNewline("}");
- write(ASEmitterTokens.BLOCK_CLOSE.getToken());
-
- }
- }
-
- @Override
- public void emitAccessors(IAccessorNode node)
- {
- if (node.getNodeID() == ASTNodeID.GetterID)
- {
- emitGetAccessor((IGetterNode) node);
- }
- else if (node.getNodeID() == ASTNodeID.SetterID)
- {
- emitSetAccessor((ISetterNode) node);
- }
- }
-
- @Override
- public void emitMethod(IFunctionNode node)
- {
- FunctionNode fn = (FunctionNode) node;
- fn.parseFunctionBody(getProblems());
-
- ICompilerProject project = getWalker().getProject();
-
- getDocEmitter().emitMethodDoc(node, project);
-
- boolean isConstructor = node.isConstructor();
-
- String qname = parseQualifiedName(getTypeDefinition(node));
- if (qname != null && !qname.equals(""))
- {
- write(qname);
- if (!isConstructor)
- {
- write(ASEmitterTokens.MEMBER_ACCESS);
- if (!fn.hasModifier(ASModifier.STATIC))
- {
- write(JSEmitterTokens.PROTOTYPE);
- write(ASEmitterTokens.MEMBER_ACCESS);
- }
- }
- }
-
- if (!isConstructor)
- emitMemberName(node);
-
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.FUNCTION);
-
- emitParameters(node.getParametersContainerNode());
-
- boolean hasSuperClass = hasSuperClass(node);
-
- if (isConstructor && node.getScopedNode().getChildCount() == 0)
- {
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.BLOCK_OPEN);
- emitVarNonLiteralAssignments();
- if (hasSuperClass)
- {
- emitSuperCall(node, JSSessionModel.CONSTRUCTOR_EMPTY);
- writeNewline();
- }
- write(ASEmitterTokens.BLOCK_CLOSE);
- }
-
- if (!isConstructor || node.getScopedNode().getChildCount() > 0)
- emitMethodScope(node.getScopedNode());
-
- if (isConstructor && hasSuperClass)
- {
- writeNewline(ASEmitterTokens.SEMICOLON);
- write(JSGoogEmitterTokens.GOOG_INHERITS);
- write(ASEmitterTokens.PAREN_OPEN);
- write(qname);
- writeToken(ASEmitterTokens.COMMA);
- String sname = parseQualifiedName(getSuperClassDefinition(node,
- project));
- if (sname.equals(IASLanguageConstants.Object))
- sname = IASLanguageConstants.Class;
- write(sname);
- write(ASEmitterTokens.PAREN_CLOSE);
- }
- }
-
- protected boolean hasSuperClass(IDefinitionNode node)
- {
- ICompilerProject project = getWalker().getProject();
- IClassDefinition superClassDefinition = getSuperClassDefinition(node,
- project);
-
- if (superClassDefinition == null)
- return false;
-
- String qname = parseQualifiedName(superClassDefinition);
-
- // ToDo (erikdebruin): need this to get the JS version of the SDK in
- // shape?
- boolean useClassAsSuperClass = !qname
- .equals(IASLanguageConstants.Object);
- if (!useClassAsSuperClass)
- {
- if (parseQualifiedName(node).equals("mx.core.EmbeddedFontRegistry")
- || parseQualifiedName(node).equals(
- "mx.managers.HistoryManagerImpl")
- || parseQualifiedName(node).equals(
- "mx.core.TextFieldFactory"))
- {
- useClassAsSuperClass = true;
- }
- }
-
- return superClassDefinition != null && useClassAsSuperClass;
- }
-
- @Override
- public void emitFunctionCall(IFunctionCallNode node)
- {
- IASNode cnode = node.getChild(0);
-
- if (cnode.getNodeID() == ASTNodeID.MemberAccessExpressionID)
- cnode = cnode.getChild(0);
-
- ASTNodeID id = cnode.getNodeID();
- if (id != ASTNodeID.SuperID)
- {
- ICompilerProject project = null;
- IDefinition def = null;
-
- boolean isClassCast = false;
-
- if (node.isNewExpression())
- {
- writeToken(ASEmitterTokens.NEW);
- }
- else
- {
- if (project == null)
- project = getWalker().getProject();
-
- def = node.getNameNode().resolve(project);
-
- isClassCast = (def instanceof ClassDefinition || def instanceof InterfaceDefinition)
- && !(NativeUtils.isJSNative(def.getBaseName()));
- }
-
- if (node.isNewExpression())
- {
- if (project == null)
- project = getWalker().getProject();
-
- def = node.resolveCalledExpression(project);
- // all new calls to a class should be fully qualified names
- if (def instanceof ClassDefinition)
- write(parseQualifiedName(def));
- else
- // I think we still need this for "new someVarOfTypeClass"
- getWalker().walk(node.getNameNode());
- emitArguments(node.getArgumentsNode());
- }
- else if (!isClassCast)
- {
- if (def != null)
- {
- boolean isInt = def.getBaseName().equals(
- IASGlobalFunctionConstants._int);
- if (isInt
- || def.getBaseName().equals(
- IASGlobalFunctionConstants.trace)
- || def.getBaseName().equals(
- IASGlobalFunctionConstants.uint))
- {
- write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
- write(ASEmitterTokens.MEMBER_ACCESS);
- if (isInt)
- write(JSFlexJSEmitterTokens.UNDERSCORE);
- }
- }
- getWalker().walk(node.getNameNode());
- emitArguments(node.getArgumentsNode());
- }
- else
- {
- emitIsAs(node.getArgumentNodes()[0], node.getNameNode(),
- ASTNodeID.Op_AsID, true);
- }
- }
- else
- {
- emitSuperCall(node, JSSessionModel.SUPER_FUNCTION_CALL);
- }
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- protected void emitSelfReference(IFunctionNode node)
- {
- // we don't want 'var self = this;' in FlexJS
- }
-
- private boolean writeThis(IIdentifierNode node)
- {
- if (node instanceof NonResolvingIdentifierNode)
- return false;
-
- IClassNode classNode = (IClassNode) node
- .getAncestorOfType(IClassNode.class);
-
- IDefinition nodeDef = node.resolve(project);
-
- IASNode parentNode = node.getParent();
- ASTNodeID parentNodeId = parentNode.getNodeID();
-
- IASNode firstChild = parentNode.getChild(0);
- IClassDefinition thisClass = getModel().getCurrentClass();
-
- boolean identifierIsMemberAccess = parentNodeId == ASTNodeID.MemberAccessExpressionID;
-
- if (classNode == null) // script in MXML and AS interface definitions
- {
- if (nodeDef instanceof ParameterDefinition)
- return false;
-
- if (nodeDef instanceof VariableDefinition)
- {
- IDefinition pdef = ((VariableDefinition) nodeDef).getParent();
-
- if (thisClass == null || !isSameClass(pdef, thisClass, project))
- return false;
-
- if (identifierIsMemberAccess)
- return node == firstChild;
-
- return parentNodeId == ASTNodeID.ContainerID
- || !(parentNode instanceof ParameterNode);
- }
- else if (nodeDef instanceof AccessorDefinition)
- {
- IDefinition pdef = ((AccessorDefinition) nodeDef).getParent();
-
- if (thisClass == null || !isSameClass(pdef, thisClass, project))
- return false;
-
- if (identifierIsMemberAccess)
- return node == firstChild;
-
- return true;
- }
- else if (parentNodeId == ASTNodeID.ContainerID
- && nodeDef instanceof FunctionDefinition)
- {
- return ((FunctionDefinition) nodeDef)
- .getFunctionClassification() == FunctionClassification.CLASS_MEMBER; // for 'goog.bind'
- }
- else
- {
- return parentNodeId == ASTNodeID.FunctionCallID
- && !(nodeDef instanceof AccessorDefinition)
- && !identifierIsMemberAccess;
- }
- }
- else
- {
- if (nodeDef != null && !nodeDef.isInternal()
- && isClassMember(nodeDef, classNode))
- {
- if (identifierIsMemberAccess)
- {
- if (parentNode.getNodeID() == ASTNodeID.MemberAccessExpressionID
- && parentNode.getChild(0).getNodeID() == ASTNodeID.SuperID
- && !isSuperCallForOverride(node))
- {
- return true;
- }
-
- return node == firstChild;
- }
- else
- {
- boolean identifierIsLocalFunction = nodeDef instanceof FunctionDefinition
- && !(nodeDef instanceof AccessorDefinition)
- && ((FunctionDefinition) nodeDef)
- .getFunctionClassification() == IFunctionDefinition.FunctionClassification.LOCAL;
-
- if (nodeDef instanceof IParameterDefinition)
- return false;
-
- return !identifierIsLocalFunction;
- }
- }
- }
-
- return false;
- }
-
- private boolean isClassMember(IDefinition nodeDef, IClassNode classNode)
- {
- TypeScope cscope = (TypeScope) classNode.getDefinition()
- .getContainedScope();
-
- Set<INamespaceDefinition> nsSet = cscope.getNamespaceSet(project);
- Collection<IDefinition> defs = new HashSet<IDefinition>();
-
- cscope.getAllPropertiesForMemberAccess((CompilerProject) project, defs,
- nsSet);
-
- Iterator<IDefinition> visiblePropertiesIterator = defs.iterator();
- while (visiblePropertiesIterator.hasNext())
- {
- if (parseQualifiedName(nodeDef).equals(
- parseQualifiedName(visiblePropertiesIterator.next())))
- return true;
- }
-
- return false;
- }
-
- private boolean isSameClass(IDefinition pdef, IDefinition thisClass,
- ICompilerProject project)
- {
- if (pdef == thisClass)
- return true;
-
- IDefinition cdef = ((ClassDefinition) thisClass)
- .resolveBaseClass(project);
- while (cdef != null)
- {
- // needs to be a loop
- if (cdef == pdef)
- return true;
- cdef = ((ClassDefinition) cdef).resolveBaseClass(project);
- }
- return false;
- }
-
- @Override
- public void emitIdentifier(IIdentifierNode node)
- {
- if (project == null)
- project = getWalker().getProject();
-
- IDefinition nodeDef = node.resolve(project);
-
- IASNode parentNode = node.getParent();
- ASTNodeID parentNodeId = parentNode.getNodeID();
-
- boolean identifierIsAccessorFunction = nodeDef instanceof AccessorDefinition;
- boolean identifierIsPlainFunction = nodeDef instanceof FunctionDefinition
- && !identifierIsAccessorFunction;
-
- boolean emitName = true;
-
- if (nodeDef != null && nodeDef.isStatic()
- && nodeDef.getParent() != null)
- {
- String sname = parseQualifiedName(nodeDef.getParent());
- if (sname.length() > 0)
- {
- write(sname);
- write(ASEmitterTokens.MEMBER_ACCESS);
- }
- }
- else if (!NativeUtils.isNative(node.getName()))
- {
- // an instance method as a parameter or
- // a local function
- boolean useGoogBind = (parentNodeId == ASTNodeID.ContainerID
- && identifierIsPlainFunction && ((FunctionDefinition) nodeDef)
- .getFunctionClassification() == FunctionClassification.CLASS_MEMBER)
- || (identifierIsPlainFunction && ((FunctionDefinition) nodeDef)
- .getFunctionClassification() == FunctionClassification.LOCAL);
-
- if (useGoogBind)
- {
- write(JSGoogEmitterTokens.GOOG_BIND);
- write(ASEmitterTokens.PAREN_OPEN);
- }
-
- if (writeThis(node))
- {
- write(ASEmitterTokens.THIS);
-
- write(ASEmitterTokens.MEMBER_ACCESS);
- }
-
- if (useGoogBind)
- {
- write(node.getName());
-
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.PAREN_CLOSE);
-
- emitName = false;
- }
- }
-
- IDefinition parentDef = (nodeDef != null) ? nodeDef.getParent() : null;
- boolean isNative = (parentDef != null)
- && NativeUtils.isNative(parentDef.getBaseName());
- if ((identifierIsAccessorFunction && !isNative)
- || (nodeDef instanceof VariableDefinition && ((VariableDefinition) nodeDef)
- .isBindable()))
- {
- IASNode anode = node
- .getAncestorOfType(BinaryOperatorAssignmentNode.class);
-
- boolean isAssignment = false;
- if (anode != null)
- {
- IASNode leftNode = anode.getChild(0);
- if (anode == parentNode)
- {
- if (node == leftNode)
- isAssignment = true;
- }
- else
- {
- IASNode pnode = parentNode;
- IASNode thisNode = node;
- while (anode != pnode)
- {
- if (pnode instanceof IMemberAccessExpressionNode)
- {
- if (thisNode != pnode.getChild(1))
- {
- // can't be an assignment because
- // we're on the left side of a memberaccessexpression
- break;
- }
- }
- if (pnode == leftNode)
- {
- isAssignment = true;
- }
- thisNode = pnode;
- pnode = pnode.getParent();
- }
- }
- String op = ((IBinaryOperatorNode) anode).getOperator()
- .getOperatorText();
- if (op.contains("==") || !op.contains("="))
- isAssignment = false;
- }
-
- if (parentNode.getNodeID() == ASTNodeID.MemberAccessExpressionID
- && parentNode.getChild(0).getNodeID() == ASTNodeID.SuperID
- && isSuperCallForOverride(node))
- {
- IClassNode cnode = (IClassNode) node
- .getAncestorOfType(IClassNode.class);
-
- // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
- if (cnode == null)
- return;
-
- write(parseQualifiedName(cnode));
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSGoogEmitterTokens.GOOG_BASE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.THIS);
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.SINGLE_QUOTE);
- writeGetSetPrefix(!isAssignment);
- write(parseQualifiedName(nodeDef));
- write(ASEmitterTokens.SINGLE_QUOTE);
- if (isAssignment)
- {
- writeToken(ASEmitterTokens.COMMA);
- }
- }
- else if (node instanceof NonResolvingIdentifierNode)
- {
- write(node.getName());
- }
- else
- {
- writeGetSetPrefix(!isAssignment);
- write(node.getName());
- write(ASEmitterTokens.PAREN_OPEN);
- }
-
- if (anode != null && isAssignment)
- {
- getWalker().walk(
- ((BinaryOperatorAssignmentNode) anode)
- .getRightOperandNode());
- }
-
- if (!(node instanceof NonResolvingIdentifierNode))
- write(ASEmitterTokens.PAREN_CLOSE);
- }
- else if (emitName)
- {
- if (nodeDef != null)
- write(parseQualifiedName(nodeDef));
- else
- write(node.getName());
- }
- }
-
- private boolean isSuperCallForOverride(IIdentifierNode node)
- {
- IFunctionNode pfnode = (IFunctionNode) node
- .getAncestorOfType(FunctionNode.class);
-
- if (pfnode == null)
- return false;
-
- return pfnode.getName().equals(node.getName());
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- protected void emitSuperCall(IASNode node, String type)
- {
- IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
- : null;
- IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
- : null;
-
- if (type == JSSessionModel.CONSTRUCTOR_EMPTY)
- {
- indentPush();
- writeNewline();
- indentPop();
- }
- else if (type == JSSessionModel.SUPER_FUNCTION_CALL)
- {
- if (fnode == null)
- fnode = (IFunctionNode) fcnode
- .getAncestorOfType(IFunctionNode.class);
- }
-
- if (fnode != null && fnode.isConstructor() && !hasSuperClass(fnode))
- return;
-
- IClassNode cnode = (IClassNode) node
- .getAncestorOfType(IClassNode.class);
-
- if (cnode == null)
- return;
-
- // (erikdebruin): Catch when a 'super' call does NOT match the enclosing
- // function call. The GCC only allows '.base()' calls
- // to matching super methods, so we need to use
- // 'goog.base' for these ...
- boolean isCallToOtherSuperMethod = false;
- try
- {
- IExpressionNode d = fcnode.getNameNode();
- if (d != null && d instanceof IMemberAccessExpressionNode)
- {
- IIdentifierNode b = (IIdentifierNode) ((IMemberAccessExpressionNode) d)
- .getRightOperandNode();
-
- isCallToOtherSuperMethod = b != null
- && !b.getName().equals(fnode.getName());
- }
- }
- catch (Exception e)
- { /* Eat it! */
- }
-
- if (isCallToOtherSuperMethod)
- {
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSGoogEmitterTokens.SUPERCLASS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- }
- else
- {
- write(parseQualifiedName(cnode));
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSGoogEmitterTokens.GOOG_BASE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.THIS);
- }
-
- if (fnode != null && fnode.isConstructor())
- {
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(JSGoogEmitterTokens.GOOG_CONSTRUCTOR);
- write(ASEmitterTokens.SINGLE_QUOTE);
- }
-
- if (fnode != null && !fnode.isConstructor())
- {
- if (!isCallToOtherSuperMethod)
- {
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.SINGLE_QUOTE);
- }
-
- if (fnode.getNodeID() == ASTNodeID.GetterID
- || fnode.getNodeID() == ASTNodeID.SetterID)
- writeGetSetPrefix(fnode.getNodeID() == ASTNodeID.GetterID);
-
- // (erikdebruin): write(fnode.getName());
- IMemberAccessExpressionNode aenode = (IMemberAccessExpressionNode) fcnode
- .getNameNode();
- write(((IIdentifierNode) aenode.getRightOperandNode()).getName());
-
- if (!isCallToOtherSuperMethod)
- {
- write(ASEmitterTokens.SINGLE_QUOTE);
- }
- else
- {
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSGoogEmitterTokens.GOOG_CALL);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.THIS);
- }
- }
-
- IASNode[] anodes = null;
- boolean writeArguments = false;
- if (fcnode != null)
- {
- anodes = fcnode.getArgumentNodes();
-
- writeArguments = anodes.length > 0;
- }
- else if (fnode != null && fnode.isConstructor())
- {
- anodes = fnode.getParameterNodes();
-
- writeArguments = (anodes != null && anodes.length > 0);
- }
- else if (fnode == null && node instanceof BinaryOperatorAssignmentNode)
- {
- BinaryOperatorAssignmentNode bnode = (BinaryOperatorAssignmentNode) node;
-
- IFunctionNode pnode = (IFunctionNode) bnode
- .getAncestorOfType(IFunctionNode.class);
-
- if (pnode.getNodeID() == ASTNodeID.SetterID)
- {
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.SINGLE_QUOTE);
- writeGetSetPrefix(false);
- getWalker().walk(bnode.getLeftOperandNode());
- write(ASEmitterTokens.SINGLE_QUOTE);
- writeToken(ASEmitterTokens.COMMA);
- getWalker().walk(bnode.getRightOperandNode());
- }
- }
-
- if (writeArguments)
- {
- int len = anodes.length;
- for (int i = 0; i < len; i++)
- {
- writeToken(ASEmitterTokens.COMMA);
-
- getWalker().walk(anodes[i]);
- }
- }
-
- write(ASEmitterTokens.PAREN_CLOSE);
-
- if (type == JSSessionModel.CONSTRUCTOR_FULL)
- {
- write(ASEmitterTokens.SEMICOLON);
- writeNewline();
- }
- else if (type == JSSessionModel.CONSTRUCTOR_EMPTY)
- {
- write(ASEmitterTokens.SEMICOLON);
- }
- }
-
- @Override
- protected void emitDefaultParameterCodeBlock(IFunctionNode node)
- {
- IParameterNode[] pnodes = node.getParameterNodes();
- if (pnodes.length == 0)
- return;
-
- Map<Integer, IParameterNode> defaults = EmitterUtils
- .getDefaults(pnodes);
-
- if (defaults != null)
- {
- final StringBuilder code = new StringBuilder();
-
- if (!EmitterUtils.hasBody(node))
- {
- indentPush();
- write(JSFlexJSEmitterTokens.INDENT);
- }
-
- List<IParameterNode> parameters = new ArrayList<IParameterNode>(
- defaults.values());
-
- for (int i = 0, n = parameters.size(); i < n; i++)
- {
- IParameterNode pnode = parameters.get(i);
-
- if (pnode != null)
- {
- code.setLength(0);
-
- /* x = typeof y !== 'undefined' ? y : z;\n */
- code.append(pnode.getName());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(ASEmitterTokens.EQUAL.getToken());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(ASEmitterTokens.TYPEOF.getToken());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(pnode.getName());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(ASEmitterTokens.STRICT_NOT_EQUAL.getToken());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
- code.append(ASEmitterTokens.UNDEFINED.getToken());
- code.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(ASEmitterTokens.TERNARY.getToken());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(pnode.getName());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(ASEmitterTokens.COLON.getToken());
- code.append(ASEmitterTokens.SPACE.getToken());
- code.append(pnode.getDefaultValue());
- code.append(ASEmitterTokens.SEMICOLON.getToken());
-
- write(code.toString());
-
- if (i == n - 1 && !EmitterUtils.hasBody(node))
- indentPop();
-
- writeNewline();
- }
- }
- }
- }
-
- @Override
- public void emitBinaryOperator(IBinaryOperatorNode node)
- {
- ASTNodeID id = node.getNodeID();
- if (id == ASTNodeID.Op_InID || id == ASTNodeID.Op_LogicalAndAssignID
- || id == ASTNodeID.Op_LogicalOrAssignID)
- {
- super.emitBinaryOperator(node);
- }
- else if (id == ASTNodeID.Op_IsID || id == ASTNodeID.Op_AsID)
- {
- emitIsAs(node.getLeftOperandNode(), node.getRightOperandNode(), id,
- false);
- }
- else if (id == ASTNodeID.Op_InstanceOfID)
- {
- getWalker().walk(node.getLeftOperandNode());
-
- write(ASEmitterTokens.SPACE);
- writeToken(ASEmitterTokens.INSTANCEOF);
-
- IDefinition dnode = (node.getRightOperandNode()).resolve(project);
- if (dnode != null)
- write(parseQualifiedName(dnode));
- else
- getWalker().walk(node.getRightOperandNode());
- }
- else
- {
- IExpressionNode leftSide = node.getLeftOperandNode();
-
- IExpressionNode property = null;
- int leftSideChildCount = leftSide.getChildCount();
- if (leftSideChildCount > 0)
- {
- IASNode childNode = leftSide.getChild(leftSideChildCount - 1);
- if (childNode instanceof IExpressionNode)
- property = (IExpressionNode) childNode;
- else
- property = leftSide;
- }
- else
- property = leftSide;
-
- IDefinition def = null;
- if (property instanceof IIdentifierNode)
- def = ((IIdentifierNode) property).resolve(getWalker()
- .getProject());
-
- boolean isSuper = false;
- if (leftSide.getNodeID() == ASTNodeID.MemberAccessExpressionID)
- {
- IASNode cnode = leftSide.getChild(0);
- ASTNodeID cId = cnode.getNodeID();
-
- isSuper = cId == ASTNodeID.SuperID;
- }
-
- String op = node.getOperator().getOperatorText();
- boolean isAssignment = !(op.contains("==") || !op.contains("="));
-
- if (def instanceof AccessorDefinition && isAssignment)
- {
- getWalker().walk(leftSide);
- }
- else if (isSuper)
- {
- emitSuperCall(node, "");
- }
- else
- {
- if (ASNodeUtils.hasParenOpen(node))
- write(ASEmitterTokens.PAREN_OPEN);
-
- getWalker().walk(leftSide);
-
- if (node.getNodeID() != ASTNodeID.Op_CommaID)
- write(ASEmitterTokens.SPACE);
-
- writeToken(node.getOperator().getOperatorText());
-
- getWalker().walk(node.getRightOperandNode());
-
- if (ASNodeUtils.hasParenClose(node))
- write(ASEmitterTokens.PAREN_CLOSE);
- }
- }
- }
-
- private void emitIsAs(IExpressionNode left, IExpressionNode right,
- ASTNodeID id, boolean coercion)
- {
- write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
- write(ASEmitterTokens.MEMBER_ACCESS);
- if (id == ASTNodeID.Op_IsID)
- write(ASEmitterTokens.IS);
- else
- write(ASEmitterTokens.AS);
- write(ASEmitterTokens.PAREN_OPEN);
- getWalker().walk(left);
- writeToken(ASEmitterTokens.COMMA);
-
- IDefinition dnode = (right).resolve(project);
- if (dnode != null)
- write(parseQualifiedName(dnode));
- else
- getWalker().walk(right);
-
- if (coercion)
- {
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.TRUE);
- }
-
- write(ASEmitterTokens.PAREN_CLOSE);
- }
-
- @Override
- public void emitMemberAccessExpression(IMemberAccessExpressionNode node)
- {
- IASNode leftNode = node.getLeftOperandNode();
- IASNode rightNode = node.getRightOperandNode();
-
- if (project == null)
- project = getWalker().getProject();
-
- IDefinition def = node.resolve(project);
- boolean isStatic = false;
- if (def != null && def.isStatic())
- isStatic = true;
-
- boolean continueWalk = true;
- if (!isStatic)
- {
- if (!(leftNode instanceof ILanguageIdentifierNode && ((ILanguageIdentifierNode) leftNode)
- .getKind() == ILanguageIdentifierNode.LanguageIdentifierKind.THIS))
- {
- if (rightNode instanceof UnaryOperatorAtNode)
- {
- // ToDo (erikdebruin): properly handle E4X
-
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- getWalker().walk(node.getLeftOperandNode());
- write(ASEmitterTokens.SQUARE_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write("E4XOperator");
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.SQUARE_CLOSE);
- continueWalk = false;
- }
- else if (node.getNodeID() == ASTNodeID.Op_DescendantsID)
- {
- // ToDo (erikdebruin): properly handle E4X
-
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- getWalker().walk(node.getLeftOperandNode());
- write(ASEmitterTokens.SQUARE_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write("E4XSelector");
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.SQUARE_CLOSE);
- continueWalk = false;
- }
- else if (leftNode.getNodeID() != ASTNodeID.SuperID)
- {
- getWalker().walk(node.getLeftOperandNode());
- write(node.getOperator().getOperatorText());
- }
- }
- else
- {
- write(ASEmitterTokens.THIS);
- write(node.getOperator().getOperatorText());
- }
-
- }
-
- if (continueWalk)
- getWalker().walk(node.getRightOperandNode());
- }
-
- private static ITypeDefinition getTypeDefinition(IDefinitionNode node)
- {
- ITypeNode tnode = (ITypeNode) node.getAncestorOfType(ITypeNode.class);
- return (ITypeDefinition) tnode.getDefinition();
- }
-
- private static IClassDefinition getSuperClassDefinition(
- IDefinitionNode node, ICompilerProject project)
- {
- IClassDefinition parent = (IClassDefinition) node.getDefinition()
- .getParent();
- IClassDefinition superClass = parent.resolveBaseClass(project);
- return superClass;
- }
-
- @Override
- protected void emitObjectDefineProperty(IAccessorNode node)
- {
- FunctionNode fn = (FunctionNode) node;
- fn.parseFunctionBody(getProblems());
-
- IFunctionDefinition definition = node.getDefinition();
- ITypeDefinition type = (ITypeDefinition) definition.getParent();
-
- // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
- if (type == null)
- return;
-
- if (project == null)
- project = getWalker().getProject();
-
- getDocEmitter().emitMethodDoc(fn, project);
- write(parseQualifiedName(type));
- if (!node.hasModifier(ASModifier.STATIC))
- {
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSEmitterTokens.PROTOTYPE);
- }
-
- write(ASEmitterTokens.MEMBER_ACCESS);
- writeGetSetPrefix(node instanceof IGetterNode);
- writeToken(node.getName());
- writeToken(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.FUNCTION);
- emitParameters(node.getParametersContainerNode());
- //writeNewline();
- emitMethodScope(node.getScopedNode());
- }
-
- private void writeGetSetPrefix(boolean isGet)
- {
- if (isGet)
- write(ASEmitterTokens.GET);
- else
- write(ASEmitterTokens.SET);
- write("_");
- }
-
- @Override
- public IJSGoogDocEmitter getDocEmitter()
- {
- return new JSVF2JSDocEmitter(this);
- }
-
- @Override
- public void emitPackageHeader(IPackageDefinition definition)
- {
- IASScope containedScope = definition.getContainedScope();
- ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
- if (type == null)
- return;
-
- writeNewline("/**");
- writeNewline(" * " + parseQualifiedName(type));
- writeNewline(" *");
- writeNewline(" * @fileoverview");
- writeNewline(" *");
- writeNewline(" * @suppress {checkTypes}");
- writeNewline(" */");
- writeNewline();
-
- /* goog.provide('x');\n\n */
- write(JSGoogEmitterTokens.GOOG_PROVIDE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(parseQualifiedName(type));
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- writeNewline();
- }
-
- @Override
- public void emitPackageHeaderContents(IPackageDefinition definition)
- {
- PackageScope containedScope = (PackageScope) definition
- .getContainedScope();
-
- ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
- if (type == null)
- return;
-
- if (project == null)
- project = getWalker().getProject();
-
- FlexJSProject flexProject = (FlexJSProject) project;
- ASProjectScope projectScope = flexProject.getScope();
- ICompilationUnit cu = projectScope
- .getCompilationUnitForDefinition(type);
- ArrayList<String> requiresList = flexProject.getRequires(cu);
- ArrayList<String> interfacesList = flexProject.getInterfaces(cu);
-
- String cname = parseQualifiedName(type);
- ArrayList<String> writtenInstances = new ArrayList<String>();
- writtenInstances.add(cname); // make sure we don't add ourselves
-
- boolean emitsRequires = false;
- if (requiresList != null)
- {
- Collections.sort(requiresList);
- for (String imp : requiresList)
- {
- if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
- continue;
-
- if (imp.equals(cname))
- continue;
-
- if (NativeUtils.isNative(imp))
- continue;
-
- if (writtenInstances.indexOf(imp) == -1)
- {
-
- /* goog.require('x');\n */
- write(JSGoogEmitterTokens.GOOG_REQUIRE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(imp);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
-
- writtenInstances.add(imp);
-
- emitsRequires = true;
- }
- }
- }
-
- boolean emitsInterfaces = false;
- if (interfacesList != null)
- {
- Collections.sort(interfacesList);
- for (String imp : interfacesList)
- {
- write(JSGoogEmitterTokens.GOOG_REQUIRE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(imp);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
-
- emitsInterfaces = true;
- }
- }
-
- // erikdebruin: Add missing language feature support, with e.g. 'is' and
- // 'as' operators. We don't need to worry about requiring
- // this in every project: ADVANCED_OPTIMISATIONS will NOT
- // include any of the code if it is not used in the project.
- boolean isMainCU = flexProject.mainCU != null
- && cu.getName().equals(flexProject.mainCU.getName());
- if (isMainCU)
- {
- write(JSGoogEmitterTokens.GOOG_REQUIRE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- }
-
- if (emitsRequires || emitsInterfaces || isMainCU)
- {
- writeNewline();
- }
-
- writeNewline();
- writeNewline();
- }
-
- @Override
- public void emitPackageFooter(IPackageDefinition definition)
- {
- IASScope containedScope = definition.getContainedScope();
- ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
- if (type == null)
- return;
-
- ITypeNode tnode = findTypeNode(definition.getNode());
- if (tnode != null)
- {
- /*
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
- writeNewline();
- writeNewline();
- writeNewline();
- getDocEmitter().begin();
- writeNewline(" * Metadata");
- writeNewline(" *");
- writeNewline(" * @type {Object.<string, Array.<Object>>}");
- getDocEmitter().end();
-
- // a.B.prototype.AFJS_CLASS_INFO = { };
- write(parseQualifiedName(type));
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSEmitterTokens.PROTOTYPE);
- write(ASEmitterTokens.MEMBER_ACCESS);
- writeToken(JSFlexJSEmitterTokens.FLEXJS_CLASS_INFO);
- writeToken(ASEmitterTokens.EQUAL);
- writeToken(ASEmitterTokens.BLOCK_OPEN);
-
- // names: [{ name: '', qName: '' }]
- write(JSFlexJSEmitterTokens.NAMES);
- writeToken(ASEmitterTokens.COLON);
- write(ASEmitterTokens.SQUARE_OPEN);
- writeToken(ASEmitterTokens.BLOCK_OPEN);
- write(JSFlexJSEmitterTokens.NAME);
- writeToken(ASEmitterTokens.COLON);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(tnode.getName());
- write(ASEmitterTokens.SINGLE_QUOTE);
- writeToken(ASEmitterTokens.COMMA);
- write(JSFlexJSEmitterTokens.QNAME);
- writeToken(ASEmitterTokens.COLON);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(parseQualifiedName(tnode));
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.BLOCK_CLOSE);
- write(ASEmitterTokens.SQUARE_CLOSE);
-
- IExpressionNode[] enodes;
- if (tnode instanceof IClassNode)
- enodes = ((IClassNode) tnode).getImplementedInterfaceNodes();
- else
- enodes = ((IInterfaceNode) tnode).getExtendedInterfaceNodes();
-
- if (enodes.length > 0)
- {
- writeToken(ASEmitterTokens.COMMA);
-
- // interfaces: [a.IC, a.ID]
- write(JSFlexJSEmitterTokens.INTERFACES);
- writeToken(ASEmitterTokens.COLON);
- write(ASEmitterTokens.SQUARE_OPEN);
- int i = 0;
- for (IExpressionNode enode : enodes)
- {
- write(parseQualifiedName(enode.resolve(project)));
- if (i < enodes.length - 1)
- writeToken(ASEmitterTokens.COMMA);
- i++;
- }
- write(ASEmitterTokens.SQUARE_CLOSE);
- }
-
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.BLOCK_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- }
- }
-
- private int foreachLoopCounter = 0;
-
- @Override
- public void emitForEachLoop(IForLoopNode node)
- {
- IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
- .getConditionalsContainerNode().getChild(0);
- IASNode childNode = bnode.getChild(0);
-
- String iterName = "foreachiter"
- + new Integer(foreachLoopCounter).toString();
- foreachLoopCounter++;
-
- write(ASEmitterTokens.FOR);
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.VAR);
- write(ASEmitterTokens.SPACE);
- write(iterName);
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.IN);
- write(ASEmitterTokens.SPACE);
- getWalker().walk(bnode.getChild(1));
- writeToken(ASEmitterTokens.PAREN_CLOSE);
- writeNewline();
- write(ASEmitterTokens.BLOCK_OPEN);
- writeNewline();
- if (childNode instanceof IVariableExpressionNode)
- {
- write(ASEmitterTokens.VAR);
- write(ASEmitterTokens.SPACE);
- write(((IVariableNode) childNode.getChild(0)).getName());
- }
- else
- write(((IIdentifierNode) childNode).getName());
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.SPACE);
- getWalker().walk(bnode.getChild(1));
- write(ASEmitterTokens.SQUARE_OPEN);
- write(iterName);
- write(ASEmitterTokens.SQUARE_CLOSE);
- write(ASEmitterTokens.SEMICOLON);
- writeNewline();
- getWalker().walk(node.getStatementContentsNode());
- write(ASEmitterTokens.BLOCK_CLOSE);
- writeNewline();
-
- }
-
- /*
- @Override
- public void emitForEachLoop(IForLoopNode node)
- {
- IContainerNode xnode = (IContainerNode) node.getChild(1);
- IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
- .getConditionalsContainerNode().getChild(0);
- IASNode childNode = bnode.getChild(0);
-
- write(ASEmitterTokens.TRY);
- write(ASEmitterTokens.BLOCK_OPEN);
- writeNewline();
-
- write(JSGoogEmitterTokens.GOOG_ARRAY_FOREACH);
- write(ASEmitterTokens.PAREN_OPEN);
- getWalker().walk(bnode.getChild(1));
- writeToken(ASEmitterTokens.COMMA);
- writeToken(ASEmitterTokens.FUNCTION);
- write(ASEmitterTokens.PAREN_OPEN);
- if (childNode instanceof IVariableExpressionNode)
- write(((IVariableNode) childNode.getChild(0)).getName());
- else
- write(((IIdentifierNode) childNode).getName());
- writeToken(ASEmitterTokens.PAREN_CLOSE);
- if (isImplicit(xnode))
- write(ASEmitterTokens.BLOCK_OPEN);
- getWalker().walk(node.getStatementContentsNode());
- if (isImplicit(xnode))
- {
- writeNewline();
- write(ASEmitterTokens.BLOCK_CLOSE);
- }
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline();
- write(ASEmitterTokens.BLOCK_CLOSE);
- writeNewline();
- write(ASEmitterTokens.CATCH);
- write(ASEmitterTokens.PAREN_OPEN);
- write("foreachbreakerror");
- write(ASEmitterTokens.PAREN_CLOSE);
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.BLOCK_OPEN);
- write(ASEmitterTokens.BLOCK_CLOSE);
- writeNewline();
-
- }
-
- @Override
- public void emitIterationFlow(IIterationFlowNode node)
- {
- // look for break in foreach and throw error instead
- if (node.getKind() == IIterationFlowNode.IterationFlowKind.BREAK)
- {
- IASNode pNode = node.getParent();
- while (pNode != null)
- {
- ASTNodeID id = pNode.getNodeID();
- if (id == ASTNodeID.ForEachLoopID)
- {
- write(ASEmitterTokens.THROW);
- write(ASEmitterTokens.SPACE);
- write(ASEmitterTokens.NEW);
- write(ASEmitterTokens.SPACE);
- write(JSGoogEmitterTokens.ERROR);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.PAREN_CLOSE);
- write(ASEmitterTokens.SEMICOLON);
- return;
- }
- else if (id == ASTNodeID.ForLoopID ||
- id == ASTNodeID.DoWhileLoopID ||
- id == ASTNodeID.WhileLoopID)
- break;
- pNode = pNode.getParent();
- }
- }
- write(node.getKind().toString().toLowerCase());
- IIdentifierNode lnode = node.getLabelNode();
- if (lnode != null)
- {
- write(ASEmitterTokens.SPACE);
- getWalker().walk(lnode);
- }
- }
- */
-
- @Override
- public void emitTypedExpression(ITypedExpressionNode node)
- {
- write(JSGoogEmitterTokens.ARRAY);
- }
-
- @Override
- public void emitLiteral(ILiteralNode node)
- {
- boolean isWritten = false;
-
- String s = node.getValue(true);
- if (!(node instanceof RegExpLiteralNode))
- {
- if (node.getLiteralType() == LiteralType.XML)
- {
- // ToDo (erikdebruin): VF2JS -> handle XML output properly...
-
- write("'" + s + "'");
-
- isWritten = true;
- }
- s = s.replaceAll("\n", "__NEWLINE_PLACEHOLDER__");
- s = s.replaceAll("\r", "__CR_PLACEHOLDER__");
- s = s.replaceAll("\t", "__TAB_PLACEHOLDER__");
- s = s.replaceAll("\f", "__FORMFEED_PLACEHOLDER__");
- s = s.replaceAll("\b", "__BACKSPACE_PLACEHOLDER__");
- s = s.replaceAll("\\\\\"", "__QUOTE_PLACEHOLDER__");
- s = s.replaceAll("\\\\", "__ESCAPE_PLACEHOLDER__");
- //s = "\'" + s.replaceAll("\'", "\\\\\'") + "\'";
- s = s.replaceAll("__ESCAPE_PLACEHOLDER__", "\\\\\\\\");
- s = s.replaceAll("__QUOTE_PLACEHOLDER__", "\\\\\"");
- s = s.replaceAll("__BACKSPACE_PLACEHOLDER__", "\\\\b");
- s = s.replaceAll("__FORMFEED_PLACEHOLDER__", "\\\\f");
- s = s.replaceAll("__TAB_PLACEHOLDER__", "\\\\t");
- s = s.replaceAll("__CR_PLACEHOLDER__", "\\\\r");
- s = s.replaceAll("__NEWLINE_PLACEHOLDER__", "\\\\n");
-
- Character c = s.charAt(0);
- if (c.equals('"'))
- {
- s = s.substring(1, s.length() - 1);
- s = s.replaceAll("\"", "\\\\\"");
- s = "\"" + s + "\"";
- }
- if (s.length() == 3)
- {
- c = s.charAt(1);
- if (c.equals('\\'))
- {
- s = "\"\\\\\"";
- }
- }
- }
-
- if (!isWritten)
- {
- write(s);
- }
- }
-
- @Override
- public void emitE4XFilter(IMemberAccessExpressionNode node)
- {
- // ToDo (erikdebruin): implement E4X replacement !?!
- write(ASEmitterTokens.SINGLE_QUOTE);
- write("E4XFilter");
- write(ASEmitterTokens.SINGLE_QUOTE);
- }
-
- @Override
- public void emitContainer(IContainerNode node)
- {
- int nodeCount = node.getChildCount();
- for (int i = 0; i < nodeCount; i++)
- {
- getWalker().walk(node.getChild(i));
-
- if (i < nodeCount - 1)
- writeToken(ASEmitterTokens.COMMA);
- }
- }
-
- private String parseQualifiedName(IDefinitionNode def)
- {
- return parseQualifiedNameString(def.getQualifiedName());
- }
-
- private String parseQualifiedName(IDefinition def)
- {
- return parseQualifiedNameString(def.getQualifiedName());
- }
-
- private String parseQualifiedNameString(String qNameString)
- {
- // ToDo (erikdebruin): Ugly hacks for VF2JS ...
- if (qNameString.equals(IASLanguageConstants._int))
- {
- qNameString = qNameString.toUpperCase();
- }
-
- if (qNameString.equals("byte"))
- {
- qNameString = "$" + qNameString;
- }
-
- return qNameString;
- }
-
-}
[5/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index 491bdb1..d71543b 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -80,10 +80,9 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
public MXMLFlexJSPublisher(Configuration config, FlexJSProject project)
{
super(config);
-
- this.isMarmotinniRun = ((JSGoogConfiguration) configuration).getMarmotinni() != null;
+ this.isMarmotinniRun = googConfiguration.getMarmotinni() != null;
this.outputPathParameter = configuration.getOutput();
- this.useStrictPublishing = ((JSGoogConfiguration) configuration).getStrictPublish();
+ this.useStrictPublishing = googConfiguration.getStrictPublish();
this.project = project;
}
@@ -102,9 +101,10 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
// the output redirected to the directory it specifies.
// - If there is an -output switch, use that path as the
// output parent folder.
+ // FIXME: What is marmotinni?
if (isMarmotinniRun)
{
- outputParentFolder = new File(((JSGoogConfiguration) configuration).getMarmotinni());
+ outputParentFolder = new File(googConfiguration.getMarmotinni());
}
else if (outputPathParameter != null)
{
@@ -124,8 +124,9 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
// (erikdebruin) Marmotinni handles file management, so we
// bypass the setup.
- if (!isMarmotinniRun && !((JSGoogConfiguration)configuration).getSkipTranspile())
+ if (!isMarmotinniRun && !googConfiguration.getSkipTranspile()) {
setupOutputFolder();
+ }
return outputFolder;
}
@@ -133,30 +134,25 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
@Override
public boolean publish(ProblemQuery problems) throws IOException
{
- @SuppressWarnings("unused")
- boolean ok;
- // boolean subsetGoog = true;
-
- final String intermediateDirPath = outputFolder.getPath();
- final File intermediateDir = new File(intermediateDirPath);
- File srcDir = new File(configuration.getTargetFile());
- srcDir = srcDir.getAbsoluteFile();
- srcDir = srcDir.getParentFile();
+ final File intermediateDir = outputFolder;
+ File mainSourceFile = new File(configuration.getTargetFile());
+ File srcDir = mainSourceFile.getAbsoluteFile().getParentFile();
final String projectName = FilenameUtils.getBaseName(configuration.getTargetFile());
final String outputFileName = projectName + "." + JSSharedData.OUTPUT_EXTENSION;
File releaseDir = new File(outputParentFolder, FLEXJS_RELEASE_DIR_NAME);
- final String releaseDirPath = releaseDir.getPath();
+ //final String releaseDirPath = releaseDir.getPath();
+ // Ensure the release-dir is available and clean.
if (!isMarmotinniRun)
{
if (releaseDir.exists())
{
- org.apache.commons.io.FileUtils.deleteQuietly(releaseDir);
+ FileUtils.deleteQuietly(releaseDir);
}
- if (!configuration.debug())
+ if (configuration.release())
{
if (!releaseDir.mkdirs())
{
@@ -165,37 +161,22 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
}
}
- JSClosureCompilerWrapper compilerWrapper = new JSClosureCompilerWrapper(((JSGoogConfiguration) configuration).getJSCompilerOptions());
+ JSClosureCompilerWrapper compilerWrapper = new JSClosureCompilerWrapper(googConfiguration.getJSCompilerOptions());
- // If the closure-lib parameter is empty we'll try to find the resources
- // in the classpath, dump its content to the output directory and use
- // this
- // as closure-lib parameter.
- if (((JSGoogConfiguration) configuration).isClosureLibSet())
+ // If the closure lib dir is explicitly set, use that directory. If it
+ // is not set, check if its content is available in the classpath. If
+ // it is found in the classpath, dump it's content to the filesystem and
+ // pass the files in to the compiler directly.
+ if (googConfiguration.isClosureLibSet())
{
- closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+ closureLibDirPath = googConfiguration.getClosureLib();
}
else
{
// Check if the "goog/deps.js" is available in the classpath.
- URL resource = Thread.currentThread().getContextClassLoader().getResource("goog/deps.js");
- if (resource != null)
+ File closureLibraryJar = getJarThatContainsClasspathResources("goog/deps.js");
+ if (closureLibraryJar != null)
{
- // Strip the url of the parts we don't need.
- // Unless we are not using some insanely complex setup
- // the resource will always be on the same machine.
- String resourceJarPath = resource.getFile();
- resourceJarPath = URLDecoder.decode(resourceJarPath, "UTF-8");
- if (resourceJarPath.contains(":"))
- {
- resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
- }
- if (resourceJarPath.contains("!"))
- {
- resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
- }
- File resourceJar = new File(resourceJarPath);
-
// We don't want to add all files to the classpath, so we only output the
// resources contained in 'closure-whitelist.properites' to the output.
Properties whiteList = new Properties();
@@ -203,73 +184,38 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
"flexjs/closure-whitelist.properites"));
// Add the closure files from classpath.
- for(SourceFile sourceFile : addClasspathResources(resourceJar, whiteList)) {
+ for(SourceFile sourceFile : getClasspathResources(closureLibraryJar, whiteList)) {
compilerWrapper.addJSSourceFile(sourceFile);
// And dump a copy to the output directory (we will need them to execute the application)
- FileUtils.write(new File(new File(intermediateDirPath, "library/closure"),
+ FileUtils.write(new File(new File(intermediateDir, "library/closure"),
sourceFile.getName()), sourceFile.getCode());
}
+
+ // We won't be using the closure-lib dir in this case.
+ closureLibDirPath = new File(intermediateDir, "library").getCanonicalPath();
}
// Fallback to the default.
else
{
- closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
+ closureLibDirPath = googConfiguration.getClosureLib();
}
}
-
- @SuppressWarnings("unused")
- String flexJsLibDirPath;
- // Check if the "FlexJS/src/createjs_externals.js" is available in the
- // classpath.
- URL resource = Thread.currentThread().getContextClassLoader().getResource("FlexJS/src/createjs_externals.js");
-
- // If it exists, dump FlexJS to the target directory.
- if (resource != null)
- {
- File flexJsLibDir = new File(intermediateDir.getParent(), "flexjs");
-
- // Only create and dump the content, if the directory does not
- // exists.
- if (!flexJsLibDir.exists())
- {
- if (!flexJsLibDir.mkdirs())
- {
- throw new IOException("Unable to create directory for flexjs-lib at "
- + flexJsLibDir.getAbsolutePath());
- }
-
- // Strip the url of the parts we don't need.
- // Unless we are not using some insanely complex setup
- // the resource will always be on the same machine.
- String resourceJarPath = resource.getFile();
- if (resourceJarPath.contains(":"))
- {
- resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
- }
- if (resourceJarPath.contains("!"))
- {
- resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
- }
- File resourceJar = new File(resourceJarPath);
- // Dump the closure lib from classpath.
- dumpJar(resourceJar, flexJsLibDir);
- }
- }
+ final File closureGoogSrcLibDir = new File(closureLibDirPath, "closure/goog/");
- final String projectIntermediateJSFilePath = intermediateDirPath + File.separator + outputFileName;
- final String projectReleaseJSFilePath = releaseDirPath + File.separator + outputFileName;
+ final File projectIntermediateJSFile = new File(intermediateDir, outputFileName);
+ final File projectReleaseJSFile = new File(releaseDir, outputFileName);
- if (!((JSGoogConfiguration)configuration).getSkipTranspile())
+ if (!googConfiguration.getSkipTranspile())
{
- appendExportSymbol(projectIntermediateJSFilePath, projectName);
- appendEncodedCSS(projectIntermediateJSFilePath, projectName);
+ appendEncodedCSS(projectIntermediateJSFile, projectName);
// if (!subsetGoog)
// {
// (erikdebruin) We need to leave the 'goog' files and dependencies well
// enough alone. We copy the entire library over so the
// 'goog' dependencies will resolve without our help.
+// TODO: Check if this is needed.
// FileUtils.copyDirectory(new File(closureGoogSrcLibDirPath), new File(closureGoogTgtLibDirPath));
// }
}
@@ -290,15 +236,15 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
InputStream is = fileEntry.createInputStream();
String code = IOUtils.toString(is, "UTF-8");
is.close();
- JarSourceFile sexternFile = new JarSourceFile(key, code,true);
+ JarSourceFile externFile = new JarSourceFile(key, code,true);
System.out.println("using extern: " + key);
- compilerWrapper.addJSExternsFile(sexternFile);
+ compilerWrapper.addJSExternsFile(externFile);
}
}
}
}
- GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, (JSGoogConfiguration) configuration, swcs);
+ GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, googConfiguration, swcs);
// Add all the js-files generated by the compiler to to config.
ArrayList<String> fileList = gdw.getListOfFiles(problems);
@@ -311,7 +257,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
project.needCSS = gdw.needCSS;
- // Copy static resources to the intermediate directory.
+ // Copy static resources to the intermediate (and release) directory.
IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
FileFilterUtils.suffixFileFilter(".png"));
IOFileFilter gifSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
@@ -324,73 +270,66 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
jsonSuffixFilter);
IOFileFilter subdirs = FileFilterUtils.or(DirectoryFileFilter.DIRECTORY, assetFiles);
FileUtils.copyDirectory(srcDir, intermediateDir, subdirs);
- if (!configuration.debug()) {
+ if (configuration.release()) {
FileUtils.copyDirectory(srcDir, releaseDir, subdirs);
}
File template = ((JSGoogConfiguration)configuration).getHtmlTemplate();
if (!((JSGoogConfiguration)configuration).getSkipTranspile())
{
- if (template != null)
- writeTemplate(template, "intermediate", projectName, intermediateDirPath, depsFileData.toString(), gdw.additionalHTML);
- else
- writeHTML("intermediate", projectName, intermediateDirPath, depsFileData.toString(), gdw.additionalHTML);
+ if (template != null) {
+ writeTemplate(template, "intermediate", projectName, intermediateDir, depsFileData, gdw.additionalHTML);
+ } else {
+ writeHTML("intermediate", projectName, intermediateDir, depsFileData, gdw.additionalHTML);
+ }
}
- if (!configuration.debug())
+ if (configuration.release())
{
- if (template != null)
- writeTemplate(template, "release", projectName, releaseDirPath, depsFileData.toString(), gdw.additionalHTML);
- else
- writeHTML("release", projectName, releaseDirPath, null, gdw.additionalHTML);
+ if (template != null) {
+ writeTemplate(template, "release", projectName, releaseDir, depsFileData, gdw.additionalHTML);
+ } else {
+ writeHTML("release", projectName, releaseDir, null, gdw.additionalHTML);
+ }
}
if (project.needCSS || ((JSGoogConfiguration)configuration).getSkipTranspile())
{
- if (!((JSGoogConfiguration)configuration).getSkipTranspile())
- writeCSS(projectName, intermediateDirPath);
- if (!configuration.debug())
- FileUtils.copyFile(new File(intermediateDirPath + File.separator + projectName + ".css"),
- new File(releaseDirPath + File.separator + projectName + ".css"));
+ if (!((JSGoogConfiguration)configuration).getSkipTranspile()) {
+ writeCSS(projectName, intermediateDir);
+ }
+ if (configuration.release()) {
+ FileUtils.copyFile(new File(intermediateDir, projectName + ".css"),
+ new File(releaseDir, projectName + ".css"));
+ }
}
- if (!configuration.debug())
+ if (configuration.release())
{
-// sourceFiles.addAll(addDirectoryResources(new File(closureGoogSrcLibDirPath)));
+ List<SourceFile> sourceFiles = getDirectoryResources(closureGoogSrcLibDir);
// Add all SourceFiles to the compiler.
-/* for(SourceFile sourceFile : sourceFiles) {
+ for(SourceFile sourceFile : sourceFiles) {
compilerWrapper.addJSSourceFile(sourceFile);
}
-*/
- compilerWrapper.setOptions(projectReleaseJSFilePath, useStrictPublishing, projectName);
+ compilerWrapper.setOptions(projectReleaseJSFile.getCanonicalPath(), useStrictPublishing, projectName);
/*
* // (erikdebruin) Include the 'goog' deps to allow the compiler to
* resolve // dependencies. compilerWrapper.addJSSourceFile(
* closureGoogSrcLibDirPath + File.separator + "deps.js");
*/
- List<String> externs = ((JSGoogConfiguration) configuration).getExternalJSLib();
+ List<String> externs = googConfiguration.getExternalJSLib();
for (String extern : externs)
{
compilerWrapper.addJSExternsFile(extern);
}
- compilerWrapper.targetFilePath = projectReleaseJSFilePath;
+ compilerWrapper.targetFilePath = projectReleaseJSFile.getCanonicalPath();
compilerWrapper.compile();
- appendSourceMapLocation(projectReleaseJSFilePath, projectName);
+ appendSourceMapLocation(projectReleaseJSFile, projectName);
}
- /*
- * if (!isMarmotinniRun) { String allDeps = ""; if (!subsetGoog) {
- * allDeps += FileUtils.readFileToString(srcDeps); } allDeps +=
- * FileUtils.readFileToString(new File(depsTgtFilePath));
- *
- * FileUtils.writeStringToFile(srcDeps, allDeps);
- *
- * org.apache.commons.io.FileUtils.deleteQuietly(new
- * File(depsTgtFilePath)); }
- */
// if (ok)
System.out.println("The project '" + projectName + "' has been successfully compiled and optimized.");
@@ -398,26 +337,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
return true;
}
- /*
- * private void addDeps(ArrayList<DependencyRecord> subsetdeps,
- * HashMap<String, String> gotgoog, HashMap<String, DependencyRecord>
- * defmap, String deps) { if (deps.length() == 0) { return; }
- *
- * String[] deplist = deps.split(","); for (String dep : deplist) { dep =
- * dep.trim(); DependencyRecord deprec = defmap.get(dep); if
- * (!gotgoog.containsKey(deprec.path)) { gotgoog.put(deprec.path, null); //
- * put addDependencyLine in subset file subsetdeps.add(deprec);
- * addDeps(subsetdeps, gotgoog, defmap, deprec.deps); } } }
- */
-
- private void appendExportSymbol(String path, String projectName) throws IOException
- {
- //every file should already have exportsymbol
- //writeFile(path, "\n\n// Ensures the symbol will be visible after compiler renaming.\n" + "goog.exportSymbol('"
- // + projectName + "', " + projectName + ");\n", true);
- }
-
- private void appendEncodedCSS(String path, String projectName) throws IOException
+ private void appendEncodedCSS(File targetFile, String projectName) throws IOException
{
StringBuilder appendString = new StringBuilder();
appendString.append("\n\n");
@@ -432,17 +352,17 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
{
String reqs = s.substring(reqidx);
s = s.substring(0, reqidx - 1);
- String fileData = readCode(new File(path));
+ String fileData = readCode(targetFile);
reqidx = fileData.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
String after = fileData.substring(reqidx);
String before = fileData.substring(0, reqidx - 1);
s = before + reqs + after + appendString.toString() + s;
- writeFile(path, s, false);
+ writeFile(targetFile, s, false);
}
else
{
appendString.append(s);
- writeFile(path, appendString.toString(), true);
+ writeFile(targetFile, appendString.toString(), true);
}
}
}
@@ -473,7 +393,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
return code;
}
- protected void writeTemplate(File template, String type, String projectName, String dirPath, String deps, List<String> additionalHTML)
+ protected void writeTemplate(File template, String type, String projectName, File targetDir, String deps, List<String> additionalHTML)
throws IOException
{
// Check if the template exists.
@@ -517,7 +437,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
String templateBody = getTemplateBody(projectName);
result = result.replaceAll("\\$\\{body\\}", templateBody);
- writeFile(dirPath + File.separator + ((JSGoogConfiguration) configuration).getHtmlOutputFileName(), result, false);
+ writeFile(new File(targetDir, googConfiguration.getHtmlOutputFileName()), result, false);
}
protected String getTemplateAdditionalHTML(List<String> additionalHTML)
@@ -564,7 +484,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
return bodyHTML.toString();
}
- protected void writeHTML(String type, String projectName, String dirPath, String deps, List<String> additionalHTML)
+ protected void writeHTML(String type, String projectName, File targetDir, String deps, List<String> additionalHTML)
throws IOException
{
StringBuilder htmlFile = new StringBuilder();
@@ -586,17 +506,17 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
htmlFile.append("</body>\n");
htmlFile.append("</html>");
- writeFile(dirPath + File.separator + ((JSGoogConfiguration) configuration).getHtmlOutputFileName(), htmlFile.toString(), false);
+ writeFile(new File(targetDir, googConfiguration.getHtmlOutputFileName()), htmlFile.toString(), false);
}
- private void writeCSS(String projectName, String dirPath) throws IOException
+ private void writeCSS(String projectName, File targetDir) throws IOException
{
JSCSSCompilationSession cssSession = (JSCSSCompilationSession) project.getCSSCompilationSession();
- writeFile(dirPath + File.separator + projectName + ".css", cssSession.emitCSS(), false);
+ writeFile(new File(targetDir, projectName + ".css"), cssSession.emitCSS(), false);
for (CSSFontFace fontFace : cssSession.fontFaces)
{
// check frameworks/fonts folder
- String configdir = ((JSGoogConfiguration) configuration).getLoadConfig();
+ String configdir = configuration.getLoadConfig();
File dir = new File(configdir);
dir = dir.getParentFile();
for (ICSSPropertyValue prop : fontFace.getSources())
@@ -614,8 +534,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
int c = fontPath.indexOf("?");
if (c != -1)
fontPath = fontPath.substring(0, c);
- File fontFile = new File(dir.getAbsolutePath() + File.separator + fontPath);
- File destFile = new File(dirPath + File.separator + fontPath);
+ File fontFile = new File(dir, fontPath);
+ File destFile = new File(targetDir, fontPath);
if (fontFile.exists())
{
if (!destFile.exists())
@@ -636,8 +556,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
int c = fontPath.indexOf("?");
if (c != -1)
fontPath = fontPath.substring(0, c);
- File fontFile = new File(dir.getAbsolutePath() + File.separator + fontPath);
- File destFile = new File(dirPath + File.separator + fontPath);
+ File fontFile = new File(dir, fontPath);
+ File destFile = new File(targetDir, fontPath);
if (fontFile.exists())
{
if (!destFile.exists())
@@ -648,4 +568,28 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
}
}
}
+
+ protected File getJarThatContainsClasspathResources(String resourcePath) {
+ URL resource = Thread.currentThread().getContextClassLoader().getResource(resourcePath);
+ if (resource != null) {
+ // Strip the url of the parts we don't need.
+ // Unless we are not using some insanely complex setup
+ // the resource will always be on the same machine.
+ String resourceJarPath = resource.getFile();
+ try {
+ resourceJarPath = URLDecoder.decode(resourceJarPath, "UTF-8");
+ if (resourceJarPath.contains(":")) {
+ resourceJarPath = resourceJarPath.substring(resourceJarPath.lastIndexOf(":") + 1);
+ }
+ if (resourceJarPath.contains("!")) {
+ resourceJarPath = resourceJarPath.substring(0, resourceJarPath.indexOf("!"));
+ }
+ return new File(resourceJarPath);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
deleted file mode 100644
index 8fef083..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSDescriptorSpecifier.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- *
- * 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.mxml.vf2js;
-
-import java.util.ArrayList;
-
-import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLEventSpecifier;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLNodeSpecifier;
-
-/**
- * @author Erik de Bruin
- */
-public class MXMLVF2JSDescriptorSpecifier extends MXMLNodeSpecifier
-{
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- public MXMLVF2JSDescriptorSpecifier()
- {
- super();
-
- eventSpecifiers = new ArrayList<MXMLEventSpecifier>();
- propertySpecifiers = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
-
- valueNeedsQuotes = false;
- }
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //---------------------------------
- // children
- //---------------------------------
-
- public MXMLVF2JSDescriptorSpecifier childrenSpecifier;
-
- //---------------------------------
- // properties
- //---------------------------------
-
- public ArrayList<MXMLVF2JSDescriptorSpecifier> propertySpecifiers;
-
- //---------------------------------
- // events
- //---------------------------------
-
- public ArrayList<MXMLEventSpecifier> eventSpecifiers;
-
- //---------------------------------
- // hasArray
- //---------------------------------
-
- public boolean hasArray;
-
- //---------------------------------
- // id
- //---------------------------------
-
- public String id;
-
- //---------------------------------
- // isTopNode
- //---------------------------------
-
- public boolean isTopNode;
-
- //---------------------------------
- // isProperty
- //---------------------------------
-
- public boolean isProperty;
-
- //---------------------------------
- // parent
- //---------------------------------
-
- public MXMLVF2JSDescriptorSpecifier parent;
-
- //--------------------------------------------------------------------------
- //
- // Methods
- //
- //--------------------------------------------------------------------------
-
- //---------------------------------
- // outputEventSpecifier
- //---------------------------------
-
- @SuppressWarnings("unused")
- private void outputEventSpecifier(boolean writeNewline)
- {
- // number of events
- int count = 0;
- for (MXMLEventSpecifier me : eventSpecifiers)
- {
- if (me.name != null)
- count++;
- }
- write(count + "");
-
- for (MXMLEventSpecifier me : eventSpecifiers)
- {
- writeDelimiter(writeNewline);
- write(me.output(writeNewline));
- }
- }
-
- //---------------------------------
- // outputPropertySpecifier
- //---------------------------------
-
- private String outputPropertySpecifier(boolean writeNewline)
- {
- /*
- write((isProperty) ? ASEmitterTokens.SINGLE_QUOTE.getToken() : "");
- write(name);
- write((isProperty) ? ASEmitterTokens.SINGLE_QUOTE.getToken() : "");
- */
- //writeDelimiter(writeNewline);
-
- if (isProperty)
- {
- if (value != null)
- {
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(parent.id);
- write(ASEmitterTokens.MEMBER_ACCESS);
- writeToken(name);
- writeToken(ASEmitterTokens.EQUAL);
- write(value);
- write(ASEmitterTokens.SEMICOLON);
- }
- else
- {
- //write((hasArray) ? ASEmitterTokens.NULL : ASEmitterTokens.FALSE);
- //writeDelimiter(writeNewline && !hasArray);
-
- //write(ASEmitterTokens.SQUARE_OPEN);
- output(false);
- //write(ASEmitterTokens.SQUARE_CLOSE);
- }
-
- if (parent != null)
- {
- //writeDelimiter(writeNewline);
- }
-
- writeNewline("");
- }
- else
- {
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- writeToken(id);
- writeToken(ASEmitterTokens.EQUAL);
- writeToken(ASEmitterTokens.NEW);
- write(name);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.PAREN_CLOSE);
- write(ASEmitterTokens.SEMICOLON);
-
- for (MXMLVF2JSDescriptorSpecifier md : propertySpecifiers)
- {
- if (md.name != null && md.name.equals("mxmlContent"))
- {
- childrenSpecifier = md;
- propertySpecifiers.remove(md);
- break;
- }
- }
-
- /*
- if (id != null)
- {
- write(propertySpecifiers.size() + 1 + "");
- writeDelimiter(writeNewline);
- String idPropName = (id
- .startsWith(MXMLFlexJSEmitterTokens.ID_PREFIX.getToken())) ? "_id"
- : "id";
- writeSimpleDescriptor(idPropName, ASEmitterTokens.TRUE.getToken(),
- ASEmitterTokens.SINGLE_QUOTE.getToken()
- + id + ASEmitterTokens.SINGLE_QUOTE.getToken(),
- writeNewline);
-
- writeDelimiter(writeNewline);
- }
- else
- {
- write(propertySpecifiers.size() + "");
- writeDelimiter(writeNewline);
- }
- */
- writeNewline("");
-
- output(writeNewline);
-
- writeNewline("this." + id + ".render();");
- }
-
- return sb.toString();
- }
-
- //---------------------------------
- // outputStyleSpecifier
- //---------------------------------
-
- @SuppressWarnings("unused")
- private void outputStyleSpecifier(boolean writeNewline)
- {
- // TODO (erikdebruin) not yet implemented in FlexJS
-
- write("0");
- writeDelimiter(writeNewline);
- }
-
- //---------------------------------
- // output
- //---------------------------------
-
- @Override
- public String output(boolean writeNewline)
- {
- for (MXMLVF2JSDescriptorSpecifier md : propertySpecifiers)
- {
- write(md.outputPropertySpecifier(writeNewline));
- }
-
- /*
- if (isTopNode)
- {
- int count = 0;
- for (MXMLVF2JSDescriptorSpecifier md : propertySpecifiers)
- {
- if (md.name != null)
- count++;
- }
-
- write(count + "");
- writeNewline(ASEmitterTokens.COMMA);
- }
-
- MXMLVF2JSDescriptorSpecifier model = null; // model goes first
- MXMLVF2JSDescriptorSpecifier beads = null; // beads go last
-
- for (MXMLVF2JSDescriptorSpecifier md : propertySpecifiers)
- {
- if (md.name != null && md.name.equals("model"))
- {
- model = md;
-
- break;
- }
- }
-
- if (model != null)
- write(model.outputPropertySpecifier(true));
-
- for (MXMLVF2JSDescriptorSpecifier md : propertySpecifiers)
- {
- if (md.name != null)
- {
- if (!md.name.equals("model") && !md.name.equals("beads"))
- write(md.outputPropertySpecifier(writeNewline));
- else if (md.name.equals("beads"))
- beads = md;
- }
- }
-
- if (beads != null)
- write(beads.outputPropertySpecifier(writeNewline));
-
- if (!isProperty)
- {
- outputStyleSpecifier(writeNewline);
-
- // TODO (erikdebruin) not yet implemented in FlexJS
- //outputEffectSpecifier(writeNewline);
-
- outputEventSpecifier(writeNewline);
-
- if (!isTopNode)
- {
- writeDelimiter(writeNewline);
-
- if (childrenSpecifier == null)
- write(ASEmitterTokens.NULL);
- else
- outputChildren(childrenSpecifier, writeNewline);
- }
-
- boolean isLastChild = parent != null
- && parent.propertySpecifiers.indexOf(this) == parent.propertySpecifiers
- .size() - 1;
-
- if (!isLastChild && !isTopNode)
- writeDelimiter(writeNewline);
- }
- //*/
-
- return sb.toString();
- }
-
- @SuppressWarnings("unused")
- private void outputChildren(MXMLVF2JSDescriptorSpecifier children, boolean writeNewline)
- {
- write(ASEmitterTokens.SQUARE_OPEN.getToken());
- write(children.output(false));
- write(ASEmitterTokens.SQUARE_CLOSE.getToken());
- }
-
-}
[7/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Posted by cd...@apache.org.
- Greatly worked on cleaning up the compiler code
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/3724c2ff
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/3724c2ff
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/3724c2ff
Branch: refs/heads/feature-autobuild/closure-classpath-sources
Commit: 3724c2ff9dfb33b2e343b0b82ee9486dbe5ea042
Parents: d5d4560
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Mon Oct 31 14:59:42 2016 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Mon Oct 31 14:59:42 2016 +0100
----------------------------------------------------------------------
.../apache/flex/compiler/clients/ASDOCJSC.java | 5 -
.../apache/flex/compiler/clients/COMPJSC.java | 5 -
.../apache/flex/compiler/clients/MXMLJSC.java | 51 +-
.../codegen/js/vf2js/IJSVF2JSEmitter.java | 30 -
.../internal/codegen/js/JSPublisher.java | 15 +-
.../codegen/js/goog/JSGoogPublisher.java | 125 +-
.../internal/codegen/js/goog/JarSourceFile.java | 6 +-
.../internal/codegen/js/jsc/JSCPublisher.java | 4 +-
.../codegen/js/jx/SuperCallEmitter.java | 97 +-
.../internal/codegen/js/node/NodePublisher.java | 4 +-
.../codegen/js/vf2js/JSVF2JSDocEmitter.java | 270 ---
.../codegen/js/vf2js/JSVF2JSEmitter.java | 1950 ------------------
.../mxml/flexjs/MXMLFlexJSPublisher.java | 262 +--
.../vf2js/MXMLVF2JSDescriptorSpecifier.java | 337 ---
.../codegen/mxml/vf2js/MXMLVF2JSEmitter.java | 1589 --------------
.../codegen/mxml/vf2js/MXMLVF2JSPublisher.java | 600 ------
.../driver/js/vf2js/JSVF2JSConfiguration.java | 86 -
.../internal/driver/js/vf2js/VF2JSBackend.java | 55 -
.../driver/mxml/vf2js/MXMLVF2JSBackend.java | 132 --
.../driver/mxml/vf2js/MXMLVF2JSSWCBackend.java | 121 --
.../internal/graph/VF2JSDepsWriter.java | 406 ----
.../utils/JSClosureCompilerWrapper.java | 4 +-
.../utils/VF2JSClosureCompilerWrapper.java | 224 --
.../flex/compiler/utils/VF2JSProjectUtils.java | 132 --
.../codegen/js/vf2js/TestVF2JSClass.java | 401 ----
.../codegen/js/vf2js/TestVF2JSExpressions.java | 124 --
.../codegen/js/vf2js/TestVF2JSFile.java | 92 -
.../codegen/js/vf2js/TestVF2JSProject.java | 131 --
.../codegen/js/vf2js/TestVF2JSStatements.java | 549 -----
.../mxml/vf2js/TestVF2JSMXMLApplication.java | 97 -
.../internal/test/VF2JSMXMLTestBase.java | 219 --
.../compiler/internal/test/VF2JSTestBase.java | 238 ---
.../src/test/resources/vf2js/files/SimpleAS.as | 43 -
.../resources/vf2js/files/SimpleAS_result.js | 72 -
.../test/resources/vf2js/files/SimpleMXML.mxml | 28 -
.../resources/vf2js/files/SimpleMXML_result.js | 67 -
.../src/test/resources/vf2js/files/Version.as | 25 -
.../resources/vf2js/projects/interfaces/Test.as | 46 -
.../vf2js/projects/interfaces/Test_result.js | 64 -
.../vf2js/projects/interfaces/classes/A.as | 32 -
.../projects/interfaces/classes/A_result.js | 51 -
.../vf2js/projects/interfaces/classes/B.as | 25 -
.../projects/interfaces/classes/B_result.js | 37 -
.../vf2js/projects/interfaces/classes/C.as | 25 -
.../projects/interfaces/classes/C_result.js | 37 -
.../vf2js/projects/interfaces/interfaces/IA.as | 22 -
.../projects/interfaces/interfaces/IA_result.js | 41 -
.../vf2js/projects/interfaces/interfaces/IB.as | 22 -
.../projects/interfaces/interfaces/IB_result.js | 38 -
.../vf2js/projects/interfaces/interfaces/IC.as | 22 -
.../projects/interfaces/interfaces/IC_result.js | 41 -
.../vf2js/projects/interfaces/interfaces/ID.as | 22 -
.../projects/interfaces/interfaces/ID_result.js | 38 -
.../vf2js/projects/interfaces/interfaces/IE.as | 26 -
.../projects/interfaces/interfaces/IE_result.js | 53 -
.../vf2js/projects/sdk/SomeSDKClass.as | 68 -
.../vf2js/projects/sdk/SomeSDKClass_result.js | 114 -
.../vf2js/projects/sdk/bases/HelperBaseClass.as | 33 -
.../sdk/bases/HelperBaseClass_result.js | 46 -
.../simpleMXML/src/SimpleMXML_Project.mxml | 37 -
.../simpleMXML/src/SimpleMXML_Project_result.js | 68 -
.../simpleMXML/src/example/Component.as | 31 -
.../simpleMXML/src/example/Component_result.js | 45 -
.../test/resources/vf2js/projects/super/Base.as | 65 -
.../vf2js/projects/super/Base_result.js | 120 --
.../resources/vf2js/projects/super/Super.as | 54 -
.../vf2js/projects/super/Super_result.js | 89 -
.../clients/problems/ProblemContext.java | 42 +
.../flex/compiler/config/Configuration.java | 5 +
.../src/main/java/flex2/tools/MxmlJSC.java | 4 -
70 files changed, 273 insertions(+), 9786 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
index 8aa0552..abc9118 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
@@ -44,7 +44,6 @@ import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSASDocBackend;
import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSASDocDITABackend;
import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSSWCBackend;
-import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSSWCBackend;
import org.apache.flex.compiler.internal.projects.CompilerProject;
import org.apache.flex.compiler.internal.projects.FlexJSASDocProject;
import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
@@ -144,10 +143,6 @@ public class ASDOCJSC extends MXMLJSC
backend = new GoogBackend();
break;
- case VF2JS:
- backend = new MXMLVF2JSSWCBackend();
- break;
-
default:
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
index 97ba7c2..594ff45 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
@@ -49,7 +49,6 @@ import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSSWCBackend;
import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSSWCBackend;
-import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSSWCBackend;
import org.apache.flex.compiler.internal.projects.CompilerProject;
import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
import org.apache.flex.compiler.internal.targets.JSTarget;
@@ -146,10 +145,6 @@ public class COMPJSC extends MXMLJSC
backend = new GoogBackend();
break;
- case VF2JS:
- backend = new MXMLVF2JSSWCBackend();
- break;
-
default:
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
index 875439a..ac40089 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -57,7 +57,6 @@ import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
import org.apache.flex.compiler.internal.driver.js.node.NodeBackend;
import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
-import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
import org.apache.flex.compiler.internal.projects.CompilerProject;
import org.apache.flex.compiler.internal.projects.FlexJSProject;
@@ -105,7 +104,6 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
AMD("amd"),
FLEXJS("flexjs"),
GOOG("goog"),
- VF2JS("vf2js"),
FLEXJS_DUAL("flexjs_dual"),
FLEXJS_DITA("flexjs_dita"),
JSC("jsc"),
@@ -227,9 +225,6 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
case GOOG:
backend = new GoogBackend();
break;
- case VF2JS:
- backend = new MXMLVF2JSBackend();
- break;
// if you add a new js-output-type here, don't forget to also add it
// to flex2.tools.MxmlJSC in flex-compiler-oem for IDE support
}
@@ -312,36 +307,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
ExitCode exitCode = ExitCode.SUCCESS;
try
{
- String[] adjustedArgs = args;
-
- if (jsOutputType != null)
- {
- switch (jsOutputType)
- {
- case VF2JS:
- boolean isFlashBuilderProject = useFlashBuilderProjectFiles(args);
-
- if (isFlashBuilderProject)
- {
- adjustedArgs = FlashBuilderConfigurator.computeFlashBuilderArgs(
- adjustedArgs, getTargetType().getExtension());
- }
-
- //String projectFilePath = adjustedArgs[adjustedArgs.length - 1];
- //
- //String newProjectFilePath = VF2JSProjectUtils
- // .createTempProject(projectFilePath,
- // isFlashBuilderProject);
- //
- //adjustedArgs[adjustedArgs.length - 1] = newProjectFilePath;
-
- break;
- default:
- break;
- }
- }
-
- final boolean continueCompilation = configure(adjustedArgs);
+ final boolean continueCompilation = configure(args);
// ToDo (erikdebruin): use JSSharedData for globals ...
keepASDoc = ((JSGoogConfiguration) config).getKeepASDoc();
@@ -407,20 +373,22 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
*/
protected boolean compile()
{
+ JSGoogConfiguration googConfiguration = (JSGoogConfiguration) config;
boolean compilationSuccess = false;
try
{
project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
- if (!((JSGoogConfiguration) config).getSkipTranspile())
+ if (!googConfiguration.getSkipTranspile())
{
- if (!setupTargetFile())
- return false;
+ if (!setupTargetFile()) {
+ return false;
+ }
buildArtifact();
}
- if (jsTarget != null || ((JSGoogConfiguration) config).getSkipTranspile())
+ if (jsTarget != null || googConfiguration.getSkipTranspile())
{
List<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
List<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
@@ -437,7 +405,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
File outputFolder = jsPublisher.getOutputFolder();
- if (!((JSGoogConfiguration) config).getSkipTranspile())
+ if (!googConfiguration.getSkipTranspile())
{
ArrayList<ICompilationUnit> roots = new ArrayList<ICompilationUnit>();
roots.add(mainCU);
@@ -739,8 +707,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
try
{
- if (useFlashBuilderProjectFiles(args)
- && !jsOutputType.equals(JSOutputType.VF2JS))
+ if (useFlashBuilderProjectFiles(args))
{
projectConfigurator.setConfiguration(
FlashBuilderConfigurator.computeFlashBuilderArgs(args,
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java
deleted file mode 100644
index cd4cacd..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/codegen/js/vf2js/IJSVF2JSEmitter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * 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.codegen.js.vf2js;
-
-import org.apache.flex.compiler.codegen.js.goog.IJSGoogEmitter;
-
-/**
- * @author Erik de Bruin
- */
-public interface IJSVF2JSEmitter extends IJSGoogEmitter
-{
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
index cc49504..eaa8fe8 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
@@ -22,6 +22,7 @@ package org.apache.flex.compiler.internal.codegen.js;
import java.io.File;
import java.io.IOException;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.flex.compiler.clients.problems.ProblemQuery;
import org.apache.flex.compiler.codegen.js.IJSPublisher;
@@ -44,8 +45,9 @@ public class JSPublisher implements IJSPublisher
public File getOutputFolder()
{
outputFolder = new File(getOutputFilePath());
- if (!outputFolder.isDirectory())
+ if (!outputFolder.isDirectory()) {
outputFolder = outputFolder.getParentFile();
+ }
outputParentFolder = outputFolder;
@@ -56,11 +58,13 @@ public class JSPublisher implements IJSPublisher
protected void setupOutputFolder()
{
- if (outputParentFolder.exists())
- org.apache.commons.io.FileUtils.deleteQuietly(outputParentFolder);
+ if (outputParentFolder.exists()) {
+ FileUtils.deleteQuietly(outputParentFolder);
+ }
- if (!outputFolder.exists())
+ if (!outputFolder.exists()) {
outputFolder.mkdirs();
+ }
}
private String getOutputFilePath()
@@ -71,8 +75,9 @@ public class JSPublisher implements IJSPublisher
return FilenameUtils.removeExtension(configuration.getTargetFile())
.concat(extension);
}
- else
+ else {
return configuration.getOutput();
+ }
}
public boolean publish(ProblemQuery problems) throws IOException
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
index 85abdef..6dbe8d7 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
@@ -32,7 +32,6 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.RegexFileFilter;
-import org.apache.flex.compiler.clients.JSConfiguration;
import org.apache.flex.compiler.clients.MXMLJSC.JSOutputType;
import org.apache.flex.compiler.clients.problems.ProblemQuery;
import org.apache.flex.compiler.codegen.js.IJSPublisher;
@@ -56,17 +55,19 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
public static final String GOOG_INTERMEDIATE_DIR_NAME = "js-intermediate";
public static final String GOOG_RELEASE_DIR_NAME = "js-release";
+ protected JSGoogConfiguration googConfiguration;
+
public JSGoogPublisher(Configuration config)
{
super(config);
+ googConfiguration = (JSGoogConfiguration) config;
}
@Override
public File getOutputFolder()
{
outputParentFolder = new File(configuration.getTargetFileDirectory()).getParentFile();
- outputFolder = new File(outputParentFolder,
- JSGoogPublisher.GOOG_INTERMEDIATE_DIR_NAME);
+ outputFolder = new File(outputParentFolder, JSGoogPublisher.GOOG_INTERMEDIATE_DIR_NAME);
setupOutputFolder();
@@ -86,37 +87,32 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
new File(intermediateDirPath).getParentFile(),
GOOG_RELEASE_DIR_NAME);
final String releaseDirPath = releaseDir.getPath();
- if (releaseDir.exists())
- org.apache.commons.io.FileUtils.deleteQuietly(releaseDir);
+ if (releaseDir.exists()) {
+ FileUtils.deleteQuietly(releaseDir);
+ }
releaseDir.mkdir();
- final String closureLibDirPath = ((JSGoogConfiguration) configuration).getClosureLib();
- final String closureGoogSrcLibDirPath = closureLibDirPath
- + "/closure/goog/";
- final String closureGoogTgtLibDirPath = intermediateDirPath
- + "/library/closure/goog";
- final String closureTPSrcLibDirPath = closureLibDirPath
- + "/third_party/closure/goog/";
- final String closureTPTgtLibDirPath = intermediateDirPath
- + "/library/third_party/closure/goog";
- final List<String> vanillaSDKSrcLibDirPath = ((JSGoogConfiguration) configuration).getSDKJSLib();
- final String vanillaSDKTgtLibDirPath = intermediateDirPath
- + "/VanillaSDK";
-
- final String depsSrcFilePath = intermediateDirPath
- + "/library/closure/goog/deps.js";
- final String depsTgtFilePath = intermediateDirPath + "/deps.js";
- final String projectIntermediateJSFilePath = intermediateDirPath
- + File.separator + outputFileName;
- final String projectReleaseJSFilePath = releaseDirPath + File.separator
- + outputFileName;
-
- appendExportSymbol(projectIntermediateJSFilePath, projectName);
-
- copyFile(vanillaSDKSrcLibDirPath.get(0), vanillaSDKTgtLibDirPath);
+ final File closureLibDir = new File(googConfiguration.getClosureLib());
+ final File closureGoogSrcLibDir = new File(closureLibDir, "/closure/goog/");
+ final File closureGoogTgtLibDir = new File(intermediateDirPath, "/library/closure/goog");
+ final File closureTPSrcLibDir = new File(closureLibDir, "/third_party/closure/goog/");
+ final File closureTPTgtLibDir = new File(intermediateDirPath, "/library/third_party/closure/goog");
+ // FIXME: What's the VanillaSDK?
+ final List<String> vanillaSDKSrcLibDirPath = googConfiguration.getSDKJSLib();
+ final File vanillaSDKTgtLibDir = new File(intermediateDirPath, "/VanillaSDK");
+
+ final File depsSrcFile = new File(intermediateDirPath, "/library/closure/goog/deps.js");
+ final File depsTgtFile = new File(intermediateDirPath, "/deps.js");
+ final File projectIntermediateJSFile = new File(intermediateDirPath, outputFileName);
+ final File projectReleaseJSFile = new File(releaseDirPath, outputFileName);
+
+ appendExportSymbol(projectIntermediateJSFile, projectName);
+
+ // FIXME: What's the VanillaSDK?
+ copyFile(new File(vanillaSDKSrcLibDirPath.get(0)), vanillaSDKTgtLibDir);
List<SourceFile> inputs = new ArrayList<SourceFile>();
- Collection<File> files = org.apache.commons.io.FileUtils.listFiles(
+ Collection<File> files = FileUtils.listFiles(
new File(intermediateDirPath),
new RegexFileFilter("^.*(\\.js)"),
DirectoryFileFilter.DIRECTORY);
@@ -125,28 +121,26 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
inputs.add(SourceFile.fromFile(file));
}
- copyFile(closureGoogSrcLibDirPath, closureGoogTgtLibDirPath);
- copyFile(closureTPSrcLibDirPath, closureTPTgtLibDirPath);
+ copyFile(closureGoogSrcLibDir, closureGoogTgtLibDir);
+ copyFile(closureTPSrcLibDir, closureTPTgtLibDir);
- File srcDeps = new File(depsSrcFilePath);
+ File srcDeps = depsSrcFile;
final List<SourceFile> deps = new ArrayList<SourceFile>();
deps.add(SourceFile.fromFile(srcDeps));
ErrorManager errorManager = new JSGoogErrorManager();
DepsGenerator depsGenerator = new DepsGenerator(deps, inputs,
- InclusionStrategy.ALWAYS, closureGoogTgtLibDirPath,
+ InclusionStrategy.ALWAYS, closureGoogTgtLibDir.getCanonicalPath(),
errorManager);
- writeFile(depsTgtFilePath, depsGenerator.computeDependencyCalls(),
- false);
+ writeFile(depsTgtFile, depsGenerator.computeDependencyCalls(),false);
- org.apache.commons.io.FileUtils.deleteQuietly(srcDeps);
- org.apache.commons.io.FileUtils.moveFile(new File(depsTgtFilePath),
- srcDeps);
+ FileUtils.deleteQuietly(srcDeps);
+ FileUtils.moveFile(depsTgtFile, srcDeps);
// XXX (mschmalle) until we figure out what is going on with this configuration, just skip
// HTML generation for JSC output type
- String outputType = ((JSConfiguration) configuration).getJSOutputType();
+ String outputType = googConfiguration.getJSOutputType();
if (!outputType.equals(JSOutputType.JSC.getText()))
{
writeHTML("intermediate", projectName, intermediateDirPath);
@@ -155,7 +149,7 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
ArrayList<String> optionList = new ArrayList<String>();
- files = org.apache.commons.io.FileUtils.listFiles(new File(
+ files = FileUtils.listFiles(new File(
intermediateDirPath), new RegexFileFilter("^.*(\\.js)"),
DirectoryFileFilter.DIRECTORY);
for (File file : files)
@@ -166,10 +160,10 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
optionList.add("--closure_entry_point=" + projectName);
optionList.add("--only_closure_dependencies");
optionList.add("--compilation_level=ADVANCED_OPTIMIZATIONS");
- optionList.add("--js_output_file=" + projectReleaseJSFilePath);
+ optionList.add("--js_output_file=" + projectReleaseJSFile);
optionList.add("--output_manifest=" + releaseDirPath + File.separator
+ "manifest.txt");
- optionList.add("--create_source_map=" + projectReleaseJSFilePath
+ optionList.add("--create_source_map=" + projectReleaseJSFile
+ ".map");
optionList.add("--source_map_format=" + SourceMap.Format.V3);
@@ -177,7 +171,7 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
JSClosureCompilerUtil.run(options);
- appendSourceMapLocation(projectReleaseJSFilePath, projectName);
+ appendSourceMapLocation(projectReleaseJSFile, projectName);
System.out.println("The project '" + projectName
+ "' has been successfully compiled and optimized.");
@@ -185,7 +179,7 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
return true;
}
- private void appendExportSymbol(String path, String projectName)
+ private void appendExportSymbol(File targetFile, String projectName)
throws IOException
{
StringBuilder appendString = new StringBuilder();
@@ -195,10 +189,10 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
appendString.append("', ");
appendString.append(projectName);
appendString.append(");\n");
- writeFile(path, appendString.toString(), true);
+ writeFile(targetFile, appendString.toString(), true);
}
- protected void appendSourceMapLocation(String path, String projectName)
+ protected void appendSourceMapLocation(File path, String projectName)
throws IOException
{
StringBuilder appendString = new StringBuilder();
@@ -207,14 +201,13 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
writeFile(path, appendString.toString(), true);
}
- protected void copyFile(String srcPath, String tgtPath) throws IOException
+ protected void copyFile(File source, File target) throws IOException
{
- File srcFile = new File(srcPath);
- if (srcFile.isDirectory())
- org.apache.commons.io.FileUtils.copyDirectory(srcFile, new File(
- tgtPath));
- else
- org.apache.commons.io.FileUtils.copyFile(srcFile, new File(tgtPath));
+ if (source.isDirectory()) {
+ FileUtils.copyDirectory(source, target);
+ } else {
+ FileUtils.copyFile(source, target);
+ }
}
protected void writeHTML(String type, String projectName, String dirPath)
@@ -253,28 +246,26 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
htmlFile.append("</body>\n");
htmlFile.append("</html>");
- writeFile(dirPath + File.separator + "index.html", htmlFile.toString(),
- false);
+ writeFile(new File(dirPath, "index.html"), htmlFile.toString(),false);
}
- protected void writeFile(String path, String content, boolean append)
+ protected void writeFile(File target, String content, boolean append)
throws IOException
{
- File tgtFile = new File(path);
-
- if (!tgtFile.exists())
- tgtFile.createNewFile();
+ if (!target.exists()) {
+ target.createNewFile();
+ }
- FileWriter fw = new FileWriter(tgtFile, append);
+ FileWriter fw = new FileWriter(target, append);
fw.write(content);
fw.close();
}
- protected List<SourceFile> addClasspathResources(File jarFile) throws IOException {
- return addClasspathResources(jarFile, null);
+ protected List<SourceFile> getClasspathResources(File jarFile) throws IOException {
+ return getClasspathResources(jarFile, null);
}
- protected List<SourceFile> addClasspathResources(File jarFile, Properties whiteList) throws IOException {
+ protected List<SourceFile> getClasspathResources(File jarFile, Properties whiteList) throws IOException {
List<SourceFile> sourceFiles = new LinkedList<SourceFile>();
JarFile jar = null;
@@ -302,10 +293,10 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
return sourceFiles;
}
- protected List<SourceFile> addDirectoryResources(File directory) throws IOException {
+ protected List<SourceFile> getDirectoryResources(File directory) throws IOException {
List<SourceFile> sourceFiles = new LinkedList<SourceFile>();
- Collection<File> files = org.apache.commons.io.FileUtils.listFiles(directory,
+ Collection<File> files = FileUtils.listFiles(directory,
new RegexFileFilter("^.*(\\.js)"), DirectoryFileFilter.DIRECTORY);
for (File file : files)
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JarSourceFile.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JarSourceFile.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JarSourceFile.java
index 8db5bc9..327df22 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JarSourceFile.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/goog/JarSourceFile.java
@@ -96,17 +96,17 @@ public class JarSourceFile extends SourceFile {
@Override
public int getColumnOfOffset(int offset) {
- throw new RuntimeException("Not implemented");
+ return super.getColumnOfOffset(offset);
}
@Override
public String getLine(int lineNumber) {
- throw new RuntimeException("Not implemented");
+ return super.getLine(lineNumber);
}
@Override
public Region getRegion(int lineNumber) {
- throw new RuntimeException("Not implemented");
+ return super.getRegion(lineNumber);
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
index 21c456c..3399269 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jsc/JSCPublisher.java
@@ -62,7 +62,7 @@ public class JSCPublisher extends MXMLFlexJSPublisher
}
@Override
- protected void writeHTML(String type, String projectName, String dirPath,
+ protected void writeHTML(String type, String projectName, File targetDir,
String deps, List<String> additionalHTML) throws IOException
{
if ("intermediate".equals(type))
@@ -72,7 +72,7 @@ public class JSCPublisher extends MXMLFlexJSPublisher
depsFile.append("goog.require(\"");
depsFile.append(projectName);
depsFile.append("\");\n");
- writeFile(dirPath + File.separator + projectName + "-dependencies.js", depsFile.toString(), false);
+ writeFile(new File(targetDir, projectName + "-dependencies.js"), depsFile.toString(), false);
}
//don't call super.writeHTML() because asjsc defaults to no HTML
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
index 12dc411..7be2c42 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/SuperCallEmitter.java
@@ -19,8 +19,6 @@
package org.apache.flex.compiler.internal.codegen.js.jx;
-import org.apache.flex.compiler.clients.MXMLJSC;
-import org.apache.flex.compiler.clients.MXMLJSC.JSOutputType;
import org.apache.flex.compiler.codegen.js.IJSEmitter;
import org.apache.flex.compiler.definitions.IClassDefinition;
import org.apache.flex.compiler.definitions.IDefinition;
@@ -33,7 +31,6 @@ import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens
import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
-import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAssignmentNode;
import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
@@ -61,43 +58,42 @@ public class SuperCallEmitter extends JSSubEmitter
final IClassDefinition thisClass = getModel().getCurrentClass();
- if (type == JSSessionModel.SUPER_FUNCTION_CALL)
+ if (JSSessionModel.SUPER_FUNCTION_CALL.equals(type))
{
- if (fnode == null)
- fnode = (IFunctionNode) fcnode
- .getAncestorOfType(IFunctionNode.class);
+ // FIXME: This is obviously wrong.
+ /*if (fnode == null) {
+ fnode = (IFunctionNode) fcnode.getAncestorOfType(IFunctionNode.class);
+ }*/
if (fnode != null && fnode.isConstructor()
- && !EmitterUtils.hasSuperClass(getProject(), fnode))
+ && !EmitterUtils.hasSuperClass(getProject(), fnode)) {
return;
+ }
- IClassNode cnode = (IClassNode) node
- .getAncestorOfType(IClassNode.class);
-
- // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
- if (cnode == null && MXMLJSC.jsOutputType == JSOutputType.VF2JS)
- return;
+ IClassNode cnode = (IClassNode) node.getAncestorOfType(IClassNode.class);
if (fnode != null
&& (fnode.getNodeID() == ASTNodeID.GetterID || fnode
.getNodeID() == ASTNodeID.SetterID))
{
- if (cnode == null && thisClass != null)
+ if (cnode == null && thisClass != null) {
write(getEmitter().formatQualifiedName(
thisClass.getQualifiedName()));
- else
+ } else if(cnode != null) {
write(getEmitter().formatQualifiedName(
cnode.getQualifiedName()));
+ }
write(ASEmitterTokens.MEMBER_ACCESS);
write(JSGoogEmitterTokens.GOOG_BASE);
write(ASEmitterTokens.PAREN_OPEN);
write(ASEmitterTokens.THIS);
writeToken(ASEmitterTokens.COMMA);
write(ASEmitterTokens.SINGLE_QUOTE);
- if (fnode.getNodeID() == ASTNodeID.GetterID)
+ if (fnode.getNodeID() == ASTNodeID.GetterID) {
write(JSFlexJSEmitterTokens.GETTER_PREFIX);
- else
+ } else {
write(JSFlexJSEmitterTokens.SETTER_PREFIX);
+ }
write(fnode.getName());
write(ASEmitterTokens.SINGLE_QUOTE);
@@ -109,35 +105,19 @@ public class SuperCallEmitter extends JSSubEmitter
writeArguments = anodes.length > 0;
}
- else if (fnode != null && fnode.isConstructor())
+ else if (fnode.isConstructor())
{
anodes = fnode.getParameterNodes();
writeArguments = (anodes != null && anodes.length > 0);
}
- else if (node instanceof IFunctionNode
- && node instanceof BinaryOperatorAssignmentNode)
- {
- BinaryOperatorAssignmentNode bnode = (BinaryOperatorAssignmentNode) node;
-
- IFunctionNode pnode = (IFunctionNode) bnode
- .getAncestorOfType(IFunctionNode.class);
-
- if (pnode.getNodeID() == ASTNodeID.SetterID)
- {
- writeToken(ASEmitterTokens.COMMA);
- getWalker().walk(bnode.getRightOperandNode());
- }
- }
if (writeArguments)
{
- int len = anodes.length;
- for (int i = 0; i < len; i++)
- {
+ for (IASNode anode : anodes) {
writeToken(ASEmitterTokens.COMMA);
- getWalker().walk(anodes[i]);
+ getWalker().walk(anode);
}
}
@@ -153,38 +133,37 @@ public class SuperCallEmitter extends JSSubEmitter
// TODO (mschmalle) will remove this cast as more things get abstracted
JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
- IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node
- : null;
- IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node
- : null;
+ IFunctionNode fnode = (node instanceof IFunctionNode) ? (IFunctionNode) node : null;
+ IFunctionCallNode fcnode = (node instanceof IFunctionCallNode) ? (FunctionCallNode) node : null;
- if (type == JSSessionModel.CONSTRUCTOR_EMPTY)
+ if (JSSessionModel.CONSTRUCTOR_EMPTY.equals(type))
{
indentPush();
writeNewline();
indentPop();
}
- else if (type == JSSessionModel.SUPER_FUNCTION_CALL)
+ else if (JSSessionModel.SUPER_FUNCTION_CALL.equals(type))
{
- if (fnode == null)
- fnode = (IFunctionNode) fcnode
- .getAncestorOfType(IFunctionNode.class);
+ // FIXME: This is obviously wrong.
+ if (fnode == null) {
+ fnode = (IFunctionNode) fcnode.getAncestorOfType(IFunctionNode.class);
+ }
}
- if (fnode.isConstructor()
- && !EmitterUtils.hasSuperClass(getProject(), fnode))
+ if (fnode.isConstructor() && !EmitterUtils.hasSuperClass(getProject(), fnode)) {
return;
+ }
- IClassNode cnode = (IClassNode) node
- .getAncestorOfType(IClassNode.class);
+ IClassNode cnode = (IClassNode) node.getAncestorOfType(IClassNode.class);
if (cnode == null)
{
IDefinition cdef = getModel().getCurrentClass();
write(fjs.formatQualifiedName(cdef.getQualifiedName()));
}
- else
+ else {
write(fjs.formatQualifiedName(cnode.getQualifiedName()));
+ }
write(ASEmitterTokens.MEMBER_ACCESS);
write(JSGoogEmitterTokens.GOOG_BASE);
write(ASEmitterTokens.PAREN_OPEN);
@@ -198,7 +177,7 @@ public class SuperCallEmitter extends JSSubEmitter
write(ASEmitterTokens.SINGLE_QUOTE);
}
- if (fnode != null && !fnode.isConstructor())
+ if (!fnode.isConstructor())
{
writeToken(ASEmitterTokens.COMMA);
write(ASEmitterTokens.SINGLE_QUOTE);
@@ -213,9 +192,9 @@ public class SuperCallEmitter extends JSSubEmitter
superName = ((IdentifierNode)namenode).getName();
}
}
- if (def instanceof FunctionDefinition && fjs.isCustomNamespace((FunctionDefinition)def))
+ if (def instanceof FunctionDefinition && fjs.isCustomNamespace((FunctionDefinition) def))
{
- INamespaceDefinition nsDef = ((FunctionDefinition)def).getNamespaceReference().resolveNamespaceReference(getProject());
+ INamespaceDefinition nsDef = def.getNamespaceReference().resolveNamespaceReference(getProject());
if (nsDef.getContainingScope() != null) // was null for flash_proxy in unit test
fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names
String s = nsDef.getURI();
@@ -249,23 +228,21 @@ public class SuperCallEmitter extends JSSubEmitter
if (writeArguments)
{
- int len = anodes.length;
- for (int i = 0; i < len; i++)
- {
+ for (IASNode anode : anodes) {
writeToken(ASEmitterTokens.COMMA);
- getWalker().walk(anodes[i]);
+ getWalker().walk(anode);
}
}
write(ASEmitterTokens.PAREN_CLOSE);
- if (type == JSSessionModel.CONSTRUCTOR_FULL)
+ if (JSSessionModel.CONSTRUCTOR_FULL.equals(type))
{
write(ASEmitterTokens.SEMICOLON);
writeNewline();
}
- else if (type == JSSessionModel.CONSTRUCTOR_EMPTY)
+ else if (JSSessionModel.CONSTRUCTOR_EMPTY.equals(type))
{
write(ASEmitterTokens.SEMICOLON);
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
index cf3a99e..d4b26a8 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/node/NodePublisher.java
@@ -70,12 +70,12 @@ public class NodePublisher extends JSCPublisher
}
@Override
- protected void writeHTML(String type, String projectName, String dirPath,
+ protected void writeHTML(String type, String projectName, File targetDir,
String deps, List<String> additionalHTML) throws IOException
{
StringBuilder contents = new StringBuilder();
contents.append(getTemplateDependencies(type, projectName, deps));
contents.append(getTemplateBody(projectName));
- writeFile(dirPath + File.separator + "index.js", contents.toString(), false);
+ writeFile(new File(targetDir, "index.js"), contents.toString(), false);
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
deleted file mode 100644
index 3147c20..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/vf2js/JSVF2JSDocEmitter.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- *
- * 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.js.vf2js;
-
-import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
-import org.apache.flex.compiler.clients.MXMLJSC;
-import org.apache.flex.compiler.codegen.js.IJSEmitter;
-import org.apache.flex.compiler.common.ASModifier;
-import org.apache.flex.compiler.common.DependencyType;
-import org.apache.flex.compiler.constants.IASKeywordConstants;
-import org.apache.flex.compiler.constants.IASLanguageConstants;
-import org.apache.flex.compiler.definitions.IClassDefinition;
-import org.apache.flex.compiler.definitions.IDefinition;
-import org.apache.flex.compiler.definitions.IFunctionDefinition;
-import org.apache.flex.compiler.definitions.ITypeDefinition;
-import org.apache.flex.compiler.definitions.references.IReference;
-import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
-import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
-import org.apache.flex.compiler.internal.scopes.ASScope;
-import org.apache.flex.compiler.projects.ICompilerProject;
-import org.apache.flex.compiler.tree.as.IDefinitionNode;
-import org.apache.flex.compiler.tree.as.IExpressionNode;
-import org.apache.flex.compiler.tree.as.IFunctionNode;
-import org.apache.flex.compiler.tree.as.IParameterNode;
-import org.apache.flex.compiler.tree.as.IVariableNode;
-
-public class JSVF2JSDocEmitter extends JSGoogDocEmitter
-{
-
- public JSVF2JSDocEmitter(IJSEmitter emitter)
- {
- super(emitter);
- }
-
- @Override
- public void emitMethodDoc(IFunctionNode node, ICompilerProject project)
- {
- IClassDefinition classDefinition = resolveClassDefinition(node);
-
- ASDocComment asDoc = (ASDocComment) node.getASDocComment();
-
- if (node instanceof IFunctionNode)
- {
- boolean hasDoc = false;
-
- if (node.isConstructor())
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- hasDoc = true;
-
- emitJSDocLine(JSEmitterTokens.CONSTRUCTOR);
-
- IClassDefinition parent = (IClassDefinition) node
- .getDefinition().getParent();
- IClassDefinition superClass = parent.resolveBaseClass(project);
- String qname = (superClass != null) ? superClass.getQualifiedName() : null;
-
- if (superClass != null
- && !qname.equals(IASLanguageConstants.Object))
- emitExtends(superClass, superClass.getPackageName());
-
- IReference[] references = classDefinition
- .getImplementedInterfaceReferences();
- for (IReference iReference : references)
- {
- ITypeDefinition type = (ITypeDefinition) iReference
- .resolve(project, (ASScope) classDefinition
- .getContainingScope(),
- DependencyType.INHERITANCE, true);
- if (type == null)
- System.out.println(iReference.getDisplayString() + " not resolved in " + classDefinition.getQualifiedName());
- emitImplements(type, type.getPackageName());
- }
- }
- else
- {
- String ns = node.getNamespace();
- if (ns != null)
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- emitMethodAccess(node);
- hasDoc = true;
- }
- }
-
- // @param
- IParameterNode[] parameters = node.getParameterNodes();
- for (IParameterNode pnode : parameters)
- {
- if (!hasDoc)
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- emitMethodAccess(node);
- hasDoc = true;
- }
-
- IExpressionNode enode = pnode.getNameExpressionNode();
-
- // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation
- ITypeDefinition tdef = enode.resolveType(project);
- if (tdef == null)
- continue;
-
- emitParam(pnode, tdef.getPackageName());
- }
-
- if (!node.isConstructor())
- {
- // @return
- String returnType = node.getReturnType();
- if (returnType != ""
- && returnType != ASEmitterTokens.VOID.getToken())
- {
- if (!hasDoc)
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- emitMethodAccess(node);
- hasDoc = true;
- }
-
- ITypeDefinition tdef = ((IFunctionDefinition)node.getDefinition())
- .resolveReturnType(project);
-
- String packageName = "";
- if (tdef instanceof InterfaceDefinition)
- packageName = tdef.getPackageName();
- else
- packageName = node.getPackageName();
-
- emitReturn(node, packageName);
- }
-
- // @override
- Boolean override = node.hasModifier(ASModifier.OVERRIDE);
- if (override)
- {
- if (!hasDoc)
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- emitMethodAccess(node);
- hasDoc = true;
- }
-
- emitOverride(node);
- }
- }
-
- if (hasDoc)
- end();
- }
- }
-
- @Override
- public void emitVarDoc(IVariableNode node, IDefinition def, ICompilerProject project)
- {
- String packageName = "";
- if (def != null)
- packageName = def.getPackageName();
-
- if (!node.isConst())
- {
- IDefinition ndef = node.getDefinition();
- if (emitter != null && emitter instanceof JSVF2JSEmitter)
- {
- if (project != null)
- {
- packageName = ((ITypeDefinition)ndef.resolveType(project))
- .getPackageName();
- }
- }
- }
-
- emitTypeShort(node, packageName);
- }
-
-
- public void emitInterfaceMemberDoc(IDefinitionNode node, ICompilerProject project)
- {
- boolean hasDoc = false;
-
- ASDocComment asDoc = (ASDocComment) ((IFunctionNode) node).getASDocComment();
-
- String returnType = ((IFunctionNode) node).getReturnType();
- if (returnType != ""
- && returnType != ASEmitterTokens.VOID.getToken()) // has return
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- hasDoc = true;
-
- ITypeDefinition tdef = ((IFunctionDefinition)node.getDefinition())
- .resolveReturnType(project);
-
- emitReturn((IFunctionNode) node, tdef.getPackageName());
- }
-
- IParameterNode[] parameters = ((IFunctionNode) node).getParameterNodes();
- for (IParameterNode pnode : parameters)
- {
- if (!hasDoc)
- {
- if (asDoc != null && MXMLJSC.keepASDoc)
- write(asDoc.commentNoEnd());
- else
- begin();
- hasDoc = true;
- }
-
- IExpressionNode enode = pnode.getNameExpressionNode();
- emitParam(pnode, enode.resolveType(project).getPackageName());
- }
-
- if (hasDoc)
- end();
- }
-
- @Override
- public void emitMethodAccess(IFunctionNode node)
- {
- String ns = node.getNamespace();
- if (ns == IASKeywordConstants.PRIVATE)
- {
- emitPrivate(node);
- }
- else if (ns == IASKeywordConstants.PROTECTED)
- {
- emitProtected(node);
- }
- else if (ns == IASKeywordConstants.PUBLIC)
- {
- emitPublic(node);
- }
- }
-}
[4/7] git commit: [flex-falcon]
[refs/heads/feature-autobuild/closure-classpath-sources] - - Greatly worked
on cleaning up the compiler code
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3724c2ff/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
deleted file mode 100644
index 6e2dfba..0000000
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/vf2js/MXMLVF2JSEmitter.java
+++ /dev/null
@@ -1,1589 +0,0 @@
-/*
- *
- * 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.mxml.vf2js;
-
-
-import java.io.FilterWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.flex.abc.semantics.MethodInfo;
-import org.apache.flex.abc.semantics.Name;
-import org.apache.flex.abc.semantics.Namespace;
-import org.apache.flex.compiler.codegen.as.IASEmitter;
-import org.apache.flex.compiler.codegen.mxml.flexjs.IMXMLFlexJSEmitter;
-import org.apache.flex.compiler.definitions.IClassDefinition;
-import org.apache.flex.compiler.definitions.IDefinition;
-import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.databinding.BindingDatabase;
-import org.apache.flex.compiler.internal.codegen.databinding.BindingInfo;
-import org.apache.flex.compiler.internal.codegen.databinding.FunctionWatcherInfo;
-import org.apache.flex.compiler.internal.codegen.databinding.PropertyWatcherInfo;
-import org.apache.flex.compiler.internal.codegen.databinding.StaticPropertyWatcherInfo;
-import org.apache.flex.compiler.internal.codegen.databinding.WatcherInfoBase;
-import org.apache.flex.compiler.internal.codegen.databinding.WatcherInfoBase.WatcherType;
-import org.apache.flex.compiler.internal.codegen.databinding.XMLWatcherInfo;
-import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
-import org.apache.flex.compiler.internal.codegen.mxml.MXMLEmitter;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLEventSpecifier;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitterTokens;
-import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLScriptSpecifier;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.projects.FlexProject;
-import org.apache.flex.compiler.internal.scopes.ASProjectScope;
-import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
-import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
-import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
-import org.apache.flex.compiler.internal.tree.mxml.MXMLDocumentNode;
-import org.apache.flex.compiler.projects.ICompilerProject;
-import org.apache.flex.compiler.tree.ASTNodeID;
-import org.apache.flex.compiler.tree.as.IASNode;
-import org.apache.flex.compiler.tree.as.IExpressionNode;
-import org.apache.flex.compiler.tree.as.IImportNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLArrayNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLClassNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLComponentNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLDataBindingNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLEventSpecifierNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLFactoryNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLLiteralNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLSpecifierNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLStateNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLStyleSpecifierNode;
-import org.apache.flex.compiler.units.ICompilationUnit;
-import org.apache.flex.compiler.utils.NativeUtils;
-import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
-
-/**
- * @author Erik de Bruin
- */
-public class MXMLVF2JSEmitter extends MXMLEmitter implements
- IMXMLFlexJSEmitter
-{
-
- private ArrayList<MXMLVF2JSDescriptorSpecifier> currentInstances;
- private ArrayList<MXMLVF2JSDescriptorSpecifier> currentPropertySpecifiers;
- private ArrayList<MXMLVF2JSDescriptorSpecifier> descriptorTree;
- private MXMLVF2JSDescriptorSpecifier propertiesTree;
- private ArrayList<MXMLEventSpecifier> events;
- private ArrayList<MXMLVF2JSDescriptorSpecifier> instances;
- private ArrayList<MXMLScriptSpecifier> scripts;
- //private ArrayList<MXMLStyleSpecifier> styles;
-
- private int eventCounter;
- private int idCounter;
-
- private boolean inMXMLContent;
- private boolean inStatesOverride;
-
- private StringBuilder subDocuments = new StringBuilder();
- private ArrayList<String> subDocumentNames = new ArrayList<String>();
-
- public MXMLVF2JSEmitter(FilterWriter out)
- {
- super(out);
- }
-
- @Override
- protected String getIndent(int numIndent)
- {
- final StringBuilder sb = new StringBuilder();
- for (int i = 0; i < numIndent; i++)
- sb.append(JSFlexJSEmitterTokens.INDENT.getToken());
- return sb.toString();
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- public void emitDocument(IMXMLDocumentNode node)
- {
- descriptorTree = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
- propertiesTree = new MXMLVF2JSDescriptorSpecifier();
-
- events = new ArrayList<MXMLEventSpecifier>();
- instances = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
- scripts = new ArrayList<MXMLScriptSpecifier>();
- //styles = new ArrayList<MXMLStyleSpecifier>();
-
- currentInstances = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
- currentPropertySpecifiers = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
-
- eventCounter = 0;
- idCounter = 0;
-
- // visit MXML
- IClassDefinition cdef = node.getClassDefinition();
- IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
- .getASEmitter();
- ((JSVF2JSEmitter) asEmitter).getModel().setCurrentClass(cdef);
-
- // visit tags
- final int len = node.getChildCount();
- for (int i = 0; i < len; i++)
- {
- getMXMLWalker().walk(node.getChild(i));
- }
-
- String cname = node.getFileNode().getName();
-
- emitHeader(node);
-
- write(subDocuments.toString());
- writeNewline();
-
- emitClassDeclStart(cname, node.getBaseClassName(), false);
-
- emitPropertyDecls();
-
- emitClassDeclEnd(cname, node.getBaseClassName());
-
- emitMetaData(cdef);
-
- emitScripts();
-
- emitEvents(cname);
-
- emitPropertyGetterSetters(cname);
-
- emitMXMLDescriptorFuncs(cname);
-
- emitBindingData(cname, cdef);
-
- }
-
- public void emitSubDocument(IMXMLComponentNode node)
- {
- ArrayList<MXMLVF2JSDescriptorSpecifier> oldDescriptorTree;
- MXMLVF2JSDescriptorSpecifier oldPropertiesTree;
- ArrayList<MXMLEventSpecifier> oldEvents;
- ArrayList<MXMLScriptSpecifier> oldScripts;
- ArrayList<MXMLVF2JSDescriptorSpecifier> oldCurrentInstances;
- ArrayList<MXMLVF2JSDescriptorSpecifier> oldCurrentPropertySpecifiers;
- int oldEventCounter;
- int oldIdCounter;
-
- oldDescriptorTree = descriptorTree;
- descriptorTree = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
- oldPropertiesTree = propertiesTree;
- propertiesTree = new MXMLVF2JSDescriptorSpecifier();
-
- oldEvents = events;
- events = new ArrayList<MXMLEventSpecifier>();
- // we don't save these. We want all requires to be generated at the top of the file
- instances = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
- oldScripts = scripts;
- scripts = new ArrayList<MXMLScriptSpecifier>();
- //styles = new ArrayList<MXMLStyleSpecifier>();
-
- oldCurrentInstances = currentInstances;
- currentInstances = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
- oldCurrentPropertySpecifiers = currentPropertySpecifiers;
- currentPropertySpecifiers = new ArrayList<MXMLVF2JSDescriptorSpecifier>();
-
- oldEventCounter = eventCounter;
- eventCounter = 0;
- oldIdCounter = idCounter;
- idCounter = 0;
-
- // visit MXML
- IClassDefinition cdef = node.getContainedClassDefinition();
- IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
- .getASEmitter();
- ((JSVF2JSEmitter) asEmitter).getModel().setCurrentClass(cdef);
-
- IASNode classNode = node.getContainedClassDefinitionNode();
- // visit tags
- final int len = classNode.getChildCount();
- for (int i = 0; i < len; i++)
- {
- getMXMLWalker().walk(classNode.getChild(i));
- }
-
- String cname = cdef.getQualifiedName();
- subDocumentNames.add(cname);
- String baseClassName = cdef.getBaseClassAsDisplayString();
-
- emitClassDeclStart(cname, baseClassName, false);
-
- emitPropertyDecls();
-
- emitClassDeclEnd(cname, baseClassName);
-
- emitMetaData(cdef);
-
- emitScripts();
-
- emitEvents(cname);
-
- emitPropertyGetterSetters(cname);
-
- emitMXMLDescriptorFuncs(cname);
-
- emitBindingData(cname, cdef);
-
- descriptorTree = oldDescriptorTree;
- propertiesTree = oldPropertiesTree;
- events = oldEvents;
- scripts = oldScripts;
- currentInstances = oldCurrentInstances;
- currentPropertySpecifiers = oldCurrentPropertySpecifiers;
- eventCounter = oldEventCounter;
- idCounter = oldIdCounter;
-
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitClassDeclStart(String cname, String baseClassName,
- boolean indent)
- {
- writeNewline();
- writeNewline("/**");
- writeNewline(" * @constructor");
- writeNewline(" * @extends {" + baseClassName + "}");
- writeNewline(" */");
- writeToken(cname);
- writeToken(ASEmitterTokens.EQUAL);
- write(ASEmitterTokens.FUNCTION);
- write(ASEmitterTokens.PAREN_OPEN);
- writeToken(ASEmitterTokens.PAREN_CLOSE);
- if (indent)
- indentPush();
- writeNewline(ASEmitterTokens.BLOCK_OPEN, true);
- write(cname);
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(JSGoogEmitterTokens.GOOG_BASE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.THIS);
- writeToken(ASEmitterTokens.COMMA);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(JSGoogEmitterTokens.GOOG_CONSTRUCTOR);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitClassDeclEnd(String cname, String baseClassName)
- {
- write(ASEmitterTokens.BLOCK_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- write(JSGoogEmitterTokens.GOOG_INHERITS);
- write(ASEmitterTokens.PAREN_OPEN);
- write(cname);
- writeToken(ASEmitterTokens.COMMA);
- write(baseClassName);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- writeNewline();
- writeNewline();
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitMetaData(IClassDefinition cdef)
- {
- String cname = cdef.getQualifiedName();
-
- writeNewline("/**");
- writeNewline(" * Metadata");
- writeNewline(" *");
- writeNewline(" * @type {Object.<string, Array.<Object>>}");
- writeNewline(" */");
- write(cname + ".prototype.FLEXJS_CLASS_INFO = { names: [{ name: '");
- write(cdef.getBaseName());
- write("', qName: '");
- write(cname);
- writeNewline("' }] };");
- writeNewline();
- writeNewline();
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitPropertyDecls()
- {
- indentPop();
-
- for (MXMLVF2JSDescriptorSpecifier instance : instances)
- {
- indentPush();
- writeNewline();
- writeNewline("/**");
- writeNewline(" * @private");
- writeNewline(" * @type {" + instance.name + "}");
- writeNewline(" */");
- write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
- write(instance.id);
- indentPop();
- writeNewline(ASEmitterTokens.SEMICOLON);
- }
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitBindingData(String cname, IClassDefinition cdef)
- {
- BindingDatabase bd = BindingDatabase.bindingMap.get(cdef);
- if (bd == null)
- return;
- if (bd.getBindingInfo().isEmpty())
- return;
-
- outputBindingInfoAsData(cname, bd);
- }
-
- private void outputBindingInfoAsData(String cname, BindingDatabase bindingDataBase)
- {
- IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
- .getASEmitter();
-
- writeNewline("/**");
- writeNewline(" * @export");
- writeNewline(" */");
- writeNewline(cname
- + ".prototype._bindings = [");
-
- Set<BindingInfo> bindingInfo = bindingDataBase.getBindingInfo();
- writeNewline(bindingInfo.size() + ","); // number of bindings
-
- for (BindingInfo bi : bindingInfo)
- {
- String s;
- s = bi.getSourceString();
- if (s == null)
- s = getSourceStringFromGetter(bi.getExpressionNodesForGetter());
- if (s.contains("."))
- {
- String[] parts = s.split("\\.");
- write(ASEmitterTokens.SQUARE_OPEN.getToken() + ASEmitterTokens.DOUBLE_QUOTE.getToken() +
- parts[0] + ASEmitterTokens.DOUBLE_QUOTE.getToken());
- int n = parts.length;
- for (int i = 1; i < n; i++)
- {
- String part = parts[i];
- write(", " + ASEmitterTokens.DOUBLE_QUOTE.getToken() + part + ASEmitterTokens.DOUBLE_QUOTE.getToken());
- }
- writeNewline(ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
- }
- else if (s == null || s.length() == 0)
- {
- List<IExpressionNode> getterNodes = bi.getExpressionNodesForGetter();
- StringBuilder sb = new StringBuilder();
- sb.append("function() { return ");
- for (IExpressionNode getterNode : getterNodes)
- {
- sb.append(asEmitter.stringifyNode(getterNode));
- }
- sb.append("; },");
- writeNewline(sb.toString());
- }
- else
- writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + s +
- ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
-
- IExpressionNode destNode = bi.getExpressionNodeForDestination();
- if (destNode != null)
- {
- StringBuilder sb = new StringBuilder();
- sb.append(asEmitter.stringifyNode(destNode));
- writeNewline(sb.toString());
- }
- else
- writeNewline(ASEmitterTokens.NULL.getToken() + ASEmitterTokens.COMMA.getToken());
-
- s = bi.getDestinationString();
- if (s.contains("."))
- {
- String[] parts = s.split("\\.");
- write(ASEmitterTokens.SQUARE_OPEN.getToken() + ASEmitterTokens.DOUBLE_QUOTE.getToken() +
- parts[0] + ASEmitterTokens.DOUBLE_QUOTE.getToken());
- int n = parts.length;
- for (int i = 1; i < n; i++)
- {
- String part = parts[i];
- write(", " + ASEmitterTokens.DOUBLE_QUOTE.getToken() + part + ASEmitterTokens.DOUBLE_QUOTE.getToken());
- }
- writeNewline(ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
- }
- else
- writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + s +
- ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
- }
- Set<Entry<Object, WatcherInfoBase>> watcherChains = bindingDataBase.getWatcherChains();
- for (Entry<Object, WatcherInfoBase> entry : watcherChains)
- {
- WatcherInfoBase watcherInfoBase = entry.getValue();
- encodeWatcher(watcherInfoBase);
- }
- // add a trailing null for now so I don't have to have logic where the watcher figures out not to add
- // a comma
- writeNewline("null" + ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.SEMICOLON.getToken());
- }
-
- private void encodeWatcher(WatcherInfoBase watcherInfoBase)
- {
- IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
- .getASEmitter();
-
- writeNewline(watcherInfoBase.getIndex() + ASEmitterTokens.COMMA.getToken());
- WatcherType type = watcherInfoBase.getType();
- if (type == WatcherType.FUNCTION)
- {
- writeNewline("0" + ASEmitterTokens.COMMA.getToken());
-
- FunctionWatcherInfo functionWatcherInfo = (FunctionWatcherInfo)watcherInfoBase;
-
- writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + functionWatcherInfo.getFunctionName() +
- ASEmitterTokens.DOUBLE_QUOTE.getToken());
- IExpressionNode params[] = functionWatcherInfo.params;
- StringBuilder sb = new StringBuilder();
- sb.append("function() { return [");
- boolean firstone = true;
- for (IExpressionNode param : params)
- {
- if (firstone)
- firstone = false;
- sb.append(ASEmitterTokens.COMMA.getToken());
- sb.append(asEmitter.stringifyNode(param));
- }
- sb.append("]; },");
- outputEventNames(functionWatcherInfo.getEventNames());
- outputBindings(functionWatcherInfo.getBindings());
- }
- else if ((type == WatcherType.STATIC_PROPERTY) || (type == WatcherType.PROPERTY))
- {
- writeNewline((type == WatcherType.STATIC_PROPERTY ? "1" : "2") +
- ASEmitterTokens.COMMA.getToken());
-
- PropertyWatcherInfo propertyWatcherInfo = (PropertyWatcherInfo)watcherInfoBase;
-
- boolean makeStaticWatcher = (watcherInfoBase.getType() == WatcherType.STATIC_PROPERTY);
-
- // round up the getter function for the watcher, or null if we don't need one
- MethodInfo propertyGetterFunction = null;
- if (watcherInfoBase.isRoot && !makeStaticWatcher)
- {
- // TODO: figure out what this looks like
- // propertyGetterFunction = this.propertyGetter;
- // assert propertyGetterFunction != null;
- }
- else if (watcherInfoBase.isRoot && makeStaticWatcher)
- {
- // TODO: implement getter func for static watcher.
- }
- writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + propertyWatcherInfo.getPropertyName() +
- ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
- outputEventNames(propertyWatcherInfo.getEventNames());
- outputBindings(propertyWatcherInfo.getBindings());
- if (propertyGetterFunction == null)
- writeNewline("null" + ASEmitterTokens.COMMA.getToken()); // null is valid
- if (type == WatcherType.STATIC_PROPERTY)
- {
- StaticPropertyWatcherInfo pwinfo = (StaticPropertyWatcherInfo)watcherInfoBase;
- Name classMName = pwinfo.getContainingClass(getMXMLWalker().getProject());
- writeNewline(nameToString(classMName));
- }
- }
- else if (type == WatcherType.XML)
- {
- writeNewline("3" + ASEmitterTokens.COMMA.getToken());
-
- XMLWatcherInfo xmlWatcherInfo = (XMLWatcherInfo)watcherInfoBase;
- writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + xmlWatcherInfo.getPropertyName() +
- ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
- outputBindings(xmlWatcherInfo.getBindings());
- }
- else assert false;
-
- // then recurse into children
- Set<Entry<Object, WatcherInfoBase>> children = watcherInfoBase.getChildren();
- if (children != null)
- {
- writeNewline(ASEmitterTokens.SQUARE_OPEN.getToken());
- for ( Entry<Object, WatcherInfoBase> ent : children)
- {
- encodeWatcher(ent.getValue());
- }
- writeNewline("null" + ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
- }
- else
- {
- writeNewline("null" + ASEmitterTokens.COMMA.getToken());
- }
- }
-
- private String getSourceStringFromMemberAccessExpressionNode(MemberAccessExpressionNode node)
- {
- String s = "";
-
- IExpressionNode left = node.getLeftOperandNode();
- if (left instanceof FunctionCallNode) // probably a cast
- {
- IASNode child = ((FunctionCallNode)left).getArgumentsNode().getChild(0);
- if (child instanceof IdentifierNode)
- s = getSourceStringFromIdentifierNode((IdentifierNode)child);
- else if (child instanceof MemberAccessExpressionNode)
- s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)child);
- }
- else if (left instanceof MemberAccessExpressionNode)
- s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)left);
- else if (left instanceof IdentifierNode)
- s = getSourceStringFromIdentifierNode((IdentifierNode)left);
- else
- System.out.println("expected binding member access left node" + node.toString());
- s += ".";
-
- IExpressionNode right = node.getRightOperandNode();
- if (right instanceof FunctionCallNode) // probably a cast
- {
- IASNode child = ((FunctionCallNode)right).getArgumentsNode().getChild(0);
- if (child instanceof IdentifierNode)
- s += getSourceStringFromIdentifierNode((IdentifierNode)child);
- else if (child instanceof MemberAccessExpressionNode)
- s += getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)child);
- }
- else if (right instanceof MemberAccessExpressionNode)
- s += getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)right);
- else if (right instanceof IdentifierNode)
- s += getSourceStringFromIdentifierNode((IdentifierNode)right);
- else
- System.out.println("expected binding member access right node" + node.toString());
-
- return s;
- }
-
- private String getSourceStringFromIdentifierNode(IdentifierNode node)
- {
- return node.getName();
- }
-
- private String getSourceStringFromGetter(List<IExpressionNode> nodes)
- {
- String s = "";
- IExpressionNode node = nodes.get(0);
- if (node instanceof MemberAccessExpressionNode)
- {
- s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)node);
- }
- return s;
- }
-
- private void outputEventNames(List<String> events)
- {
- if (events.size() > 1)
- {
- int n = events.size();
- write(ASEmitterTokens.SQUARE_OPEN.getToken() + ASEmitterTokens.DOUBLE_QUOTE.getToken() +
- events.get(0) + ASEmitterTokens.DOUBLE_QUOTE.getToken());
- for (int i = 1; i < n; i++)
- {
- String event = events.get(i);
- write(ASEmitterTokens.COMMA.getToken() + ASEmitterTokens.DOUBLE_QUOTE.getToken() +
- event + ASEmitterTokens.DOUBLE_QUOTE.getToken());
- }
- writeNewline(ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
- }
- else if (events.size() == 1)
- writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + events.get(0) +
- ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
- else
- writeNewline("null" + ASEmitterTokens.COMMA.getToken());
- }
-
- private void outputBindings(List<BindingInfo> bindings)
- {
- if (bindings.size() > 1)
- {
- int n = bindings.size();
- write(ASEmitterTokens.SQUARE_OPEN.getToken() + bindings.get(0).getIndex());
- for (int i = 1; i < n; i++)
- {
- BindingInfo binding = bindings.get(i);
- write(ASEmitterTokens.COMMA.getToken() + binding.getIndex());
- }
- writeNewline(ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
- }
- else if (bindings.size() == 1)
- writeNewline(bindings.get(0).getIndex() + ASEmitterTokens.COMMA.getToken());
- else
- writeNewline("null" + ASEmitterTokens.COMMA.getToken());
-
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitScripts()
- {
- for (MXMLScriptSpecifier script : scripts)
- {
- String output = script.output();
-
- if (!output.equals(""))
- {
- writeNewline(output);
- }
- }
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitEvents(String cname)
- {
- for (MXMLEventSpecifier event : events)
- {
- writeNewline("/**");
- writeNewline(" * @export");
- writeNewline(" * @param {" + event.type + "} event");
- writeNewline(" */");
- writeNewline(cname
- + ".prototype." + event.eventHandler + " = function(event)");
- writeNewline(ASEmitterTokens.BLOCK_OPEN, true);
-
- writeNewline(event.value + ASEmitterTokens.SEMICOLON.getToken(),
- false);
-
- write(ASEmitterTokens.BLOCK_CLOSE);
- writeNewline(";");
- writeNewline();
- writeNewline();
- }
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitPropertyGetterSetters(String cname)
- {
- for (MXMLVF2JSDescriptorSpecifier instance : instances)
- {
- if (!instance.id.startsWith(MXMLFlexJSEmitterTokens.ID_PREFIX
- .getToken()))
- {
- writeNewline("/**");
- writeNewline(" * @export");
- writeNewline(" * @return {" + instance.name + "}");
- writeNewline(" */");
- writeNewline(cname
- + ".prototype.get_" + instance.id + " = function()");
- indentPush();
- writeNewline("{");
- indentPop();
- writeNewline("return this." + instance.id + ";");
- writeNewline("};");
- writeNewline();
- writeNewline();
- writeNewline("/**");
- writeNewline(" * @export");
- writeNewline(" * @param {" + instance.name + "} value");
- writeNewline(" */");
- writeNewline(cname
- + ".prototype.set_" + instance.id
- + " = function(value)");
- indentPush();
- writeNewline("{");
- indentPush();
- writeNewline("if (value != this." + instance.id + ")");
- indentPop();
- indentPop();
- writeNewline("this." + instance.id + " = value;");
- writeNewline("};");
- writeNewline();
- writeNewline();
- }
- }
- }
-
- //--------------------------------------------------------------------------
-
- protected void emitMXMLDescriptorFuncs(String cname)
- {
- // top level is 'mxmlContent', skip it...
- if (descriptorTree.size() > 0)
- {
- MXMLVF2JSDescriptorSpecifier root = descriptorTree.get(0);
- root.isTopNode = false;
-
- //writeNewline(root.output(true));
- }
-
- if (propertiesTree.propertySpecifiers.size() > 0 ||
- propertiesTree.eventSpecifiers.size() > 0)
- {
- MXMLVF2JSDescriptorSpecifier root = propertiesTree;
- root.isTopNode = true;
-
- writeNewline("/**");
- writeNewline(" * start");
- writeNewline(" *");
- writeNewline(" * @export");
- writeNewline(" */");
- writeNewline(cname + ".prototype.start = function () {");
- //writeNewline(root.output(true));
- writeNewline("};");
- }
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- public void emitEventSpecifier(IMXMLEventSpecifierNode node)
- {
- IDefinition cdef = node.getDefinition();
-
- MXMLVF2JSDescriptorSpecifier currentDescriptor = getCurrentDescriptor("i");
-
- MXMLEventSpecifier eventSpecifier = new MXMLEventSpecifier();
- eventSpecifier.eventHandler = MXMLFlexJSEmitterTokens.EVENT_PREFIX
- .getToken() + eventCounter++;
- eventSpecifier.name = cdef.getBaseName();
- eventSpecifier.type = node.getEventParameterDefinition()
- .getTypeAsDisplayString();
-
- IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
- .getASEmitter();
-
- StringBuilder sb = null;
- int len = node.getChildCount();
- if (len > 0)
- {
- sb = new StringBuilder();
- for (int i = 0; i < len; i++)
- {
- sb.append(getIndent((i > 0) ? 1 : 0)
- + asEmitter.stringifyNode(node.getChild(i)));
- if (i < len - 1)
- {
- sb.append(ASEmitterTokens.SEMICOLON.getToken());
- sb.append(ASEmitterTokens.NEW_LINE.getToken());
- }
- }
- }
- eventSpecifier.value = sb.toString();
-
- if (currentDescriptor != null)
- currentDescriptor.eventSpecifiers.add(eventSpecifier);
- else // in theory, if no currentdescriptor must be top tag event
- propertiesTree.eventSpecifiers.add(eventSpecifier);
-
- events.add(eventSpecifier);
- }
-
- @Override
- public void emitInstance(IMXMLInstanceNode node)
- {
- if (isStateDependent(node) && !inStatesOverride)
- return;
-
- IClassDefinition cdef = node
- .getClassReference((ICompilerProject) getMXMLWalker()
- .getProject());
-
- MXMLVF2JSDescriptorSpecifier currentPropertySpecifier = getCurrentDescriptor("ps");
-
- String id = node.getID();
- if (id == null)
- id = node.getEffectiveID();
- if (id == null)
- id = MXMLFlexJSEmitterTokens.ID_PREFIX.getToken() + idCounter++;
-
- MXMLVF2JSDescriptorSpecifier currentInstance = new MXMLVF2JSDescriptorSpecifier();
- currentInstance.isProperty = false;
- currentInstance.id = id;
- currentInstance.name = cdef.getQualifiedName();
- currentInstance.parent = currentPropertySpecifier;
-
- if (currentPropertySpecifier != null)
- currentPropertySpecifier.propertySpecifiers.add(currentInstance);
- else if (inMXMLContent)
- descriptorTree.add(currentInstance);
- else
- {
- currentInstance.parent = propertiesTree;
- propertiesTree.propertySpecifiers.add(currentInstance);
- }
-
- instances.add(currentInstance);
-
- IMXMLPropertySpecifierNode[] pnodes = node.getPropertySpecifierNodes();
- if (pnodes != null)
- {
- moveDown(false, currentInstance, null);
-
- for (IMXMLPropertySpecifierNode pnode : pnodes)
- {
- getMXMLWalker().walk(pnode); // Property Specifier
- }
-
- moveUp(false, true);
- }
- else if (node instanceof IMXMLStateNode)
- {
- IMXMLStateNode stateNode = (IMXMLStateNode)node;
- String name = stateNode.getStateName();
- if (name != null)
- {
- MXMLVF2JSDescriptorSpecifier stateName = new MXMLVF2JSDescriptorSpecifier();
- stateName.isProperty = true;
- stateName.id = id;
- stateName.name = "name";
- stateName.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + name + ASEmitterTokens.SINGLE_QUOTE.getToken();
- stateName.parent = currentInstance;
- currentInstance.propertySpecifiers.add(stateName);
- }
- MXMLVF2JSDescriptorSpecifier overrides = new MXMLVF2JSDescriptorSpecifier();
- overrides.isProperty = true;
- overrides.hasArray = true;
- overrides.id = id;
- overrides.name = "overrides";
- overrides.parent = currentInstance;
- currentInstance.propertySpecifiers.add(overrides);
- moveDown(false, null, overrides);
-
- IMXMLClassDefinitionNode classDefinitionNode = stateNode.getClassDefinitionNode();
- List<IMXMLNode> snodes = classDefinitionNode.getNodesDependentOnState(stateNode.getStateName());
- if (snodes != null)
- {
- for (int i=snodes.size()-1; i>=0; --i)
- {
- IMXMLNode inode = snodes.get(i);
- if (inode.getNodeID() == ASTNodeID.MXMLInstanceID)
- {
- emitInstanceOverride((IMXMLInstanceNode)inode);
- }
- }
- // Next process the non-instance overrides dependent on this state.
- // Each one will generate code to push an IOverride instance.
- for (IMXMLNode anode : snodes)
- {
- switch (anode.getNodeID())
- {
- case MXMLPropertySpecifierID:
- {
- emitPropertyOverride((IMXMLPropertySpecifierNode)anode);
- break;
- }
- case MXMLStyleSpecifierID:
- {
- if (node instanceof IMXMLStyleSpecifierNode)
- {
- emitStyleOverride((IMXMLStyleSpecifierNode)node);
- }
- break;
- }
- case MXMLEventSpecifierID:
- {
- emitEventOverride((IMXMLEventSpecifierNode)node);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- }
-
- moveUp(false, false);
- }
-
- IMXMLEventSpecifierNode[] enodes = node.getEventSpecifierNodes();
- if (enodes != null)
- {
- moveDown(false, currentInstance, null);
-
- for (IMXMLEventSpecifierNode enode : enodes)
- {
- getMXMLWalker().walk(enode); // Event Specifier
- }
-
- moveUp(false, true);
- }
- }
-
- public void emitPropertyOverride(IMXMLPropertySpecifierNode propertyNode)
- {
- FlexProject project = (FlexProject) getMXMLWalker().getProject();
- Name propertyOverride = project.getPropertyOverrideClassName();
- emitPropertyOrStyleOverride(propertyOverride, propertyNode);
- }
-
- /**
- * Generates instructions in the current context
- * to create an instance of mx.states.SetStyle
- * with its <code>target</code>, <code>name</code>,
- * and <code>value</code> properties set.
- */
- void emitStyleOverride(IMXMLStyleSpecifierNode styleNode)
- {
- FlexProject project = (FlexProject) getMXMLWalker().getProject();
- Name styleOverride = project.getStyleOverrideClassName();
- emitPropertyOrStyleOverride(styleOverride, styleNode);
- }
-
- void emitPropertyOrStyleOverride(Name overrideName, IMXMLPropertySpecifierNode propertyOrStyleNode)
- {
- MXMLVF2JSDescriptorSpecifier currentInstance = getCurrentDescriptor("ps");
- IASNode parentNode = propertyOrStyleNode.getParent();
- String id = parentNode instanceof IMXMLInstanceNode ?
- ((IMXMLInstanceNode)parentNode).getEffectiveID() :
- "";
-
- String name = propertyOrStyleNode.getName();
-
- IMXMLInstanceNode propertyOrStyleValueNode = propertyOrStyleNode.getInstanceNode();
-
- MXMLVF2JSDescriptorSpecifier setProp = new MXMLVF2JSDescriptorSpecifier();
- setProp.isProperty = false;
- setProp.name = nameToString(overrideName);
- setProp.parent = currentInstance;
- currentInstance.propertySpecifiers.add(setProp);
- // Set its 'target' property to the id of the object
- // whose property or style this override will set.
- MXMLVF2JSDescriptorSpecifier target = new MXMLVF2JSDescriptorSpecifier();
- target.isProperty = true;
- target.name = "target";
- target.parent = setProp;
- target.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + id + ASEmitterTokens.SINGLE_QUOTE.getToken();
- setProp.propertySpecifiers.add(target);
-
- // Set its 'name' property to the name of the property or style.
- MXMLVF2JSDescriptorSpecifier pname = new MXMLVF2JSDescriptorSpecifier();
- pname.isProperty = true;
- pname.name = "name";
- pname.parent = setProp;
- pname.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + name + ASEmitterTokens.SINGLE_QUOTE.getToken();
- setProp.propertySpecifiers.add(pname);
-
- // Set its 'value' property to the value of the property or style.
- MXMLVF2JSDescriptorSpecifier value = new MXMLVF2JSDescriptorSpecifier();
- value.isProperty = true;
- value.name = "value";
- value.parent = setProp;
- setProp.propertySpecifiers.add(value);
- moveDown(false, null, value);
- getMXMLWalker().walk(propertyOrStyleValueNode); // instance node
- moveUp(false, false);
- }
-
- /**
- * Generates instructions in the current context
- * to create an instance of mx.states.SetEventHandler
- * with its <code>target</code>, <code>name</code>,
- * and <code>handlerFunction</code> properties set.
- */
- void emitEventOverride(IMXMLEventSpecifierNode eventNode)
- {
- MXMLVF2JSDescriptorSpecifier currentInstance = getCurrentDescriptor("ps");
- FlexProject project = (FlexProject) getMXMLWalker().getProject();
- Name eventOverride = project.getEventOverrideClassName();
-
- IASNode parentNode = eventNode.getParent();
- String id = parentNode instanceof IMXMLInstanceNode ?
- ((IMXMLInstanceNode)parentNode).getEffectiveID() :
- "";
-
- String name = eventNode.getName();
-
- MXMLDocumentNode doc = (MXMLDocumentNode)eventNode.getAncestorOfType(MXMLDocumentNode.class);
-
- Name eventHandler = doc.cdp.getEventHandlerName(eventNode);
-
- MXMLVF2JSDescriptorSpecifier setEvent = new MXMLVF2JSDescriptorSpecifier();
- setEvent.isProperty = true;
- setEvent.name = nameToString(eventOverride);
- setEvent.parent = currentInstance;
- currentInstance.propertySpecifiers.add(setEvent);
- // Set its 'target' property to the id of the object
- // whose event this override will set.
- MXMLVF2JSDescriptorSpecifier target = new MXMLVF2JSDescriptorSpecifier();
- target.isProperty = true;
- target.name = "target";
- target.parent = setEvent;
- target.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + id + ASEmitterTokens.SINGLE_QUOTE.getToken();
- setEvent.propertySpecifiers.add(target);
-
- // Set its 'name' property to the name of the property or style.
- MXMLVF2JSDescriptorSpecifier pname = new MXMLVF2JSDescriptorSpecifier();
- pname.isProperty = true;
- pname.name = "name";
- pname.parent = setEvent;
- pname.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + name + ASEmitterTokens.SINGLE_QUOTE.getToken();
- setEvent.propertySpecifiers.add(pname);
-
- // Set its 'handlerFunction' property to the autogenerated event handler.
- MXMLVF2JSDescriptorSpecifier handler = new MXMLVF2JSDescriptorSpecifier();
- handler.isProperty = false;
- handler.name = "handlerFunction";
- handler.parent = setEvent;
- handler.value = eventHandler.toString();
- setEvent.propertySpecifiers.add(handler);
-
- }
-
- public void emitInstanceOverride(IMXMLInstanceNode instanceNode)
- {
- inStatesOverride = true;
-
- MXMLVF2JSDescriptorSpecifier currentInstance = getCurrentDescriptor("ps");
- FlexProject project = (FlexProject) getMXMLWalker().getProject();
- Name instanceOverrideName = project.getInstanceOverrideClassName();
-
- MXMLVF2JSDescriptorSpecifier addItems = new MXMLVF2JSDescriptorSpecifier();
- addItems.isProperty = false;
- addItems.name = nameToString(instanceOverrideName);
- addItems.parent = currentInstance;
- currentInstance.propertySpecifiers.add(addItems);
- MXMLVF2JSDescriptorSpecifier itemsDesc = new MXMLVF2JSDescriptorSpecifier();
- itemsDesc.isProperty = true;
- itemsDesc.hasArray = true;
- itemsDesc.name = "itemsDescriptor";
- itemsDesc.parent = addItems;
- addItems.propertySpecifiers.add(itemsDesc);
- boolean oldInMXMLContent = inMXMLContent;
- moveDown(false, null, itemsDesc);
- inMXMLContent = true;
- getMXMLWalker().walk(instanceNode); // instance node
- inMXMLContent = oldInMXMLContent;
- moveUp(false, false);
-
- //-----------------------------------------------------------------------------
- // Second property set: maybe set destination and propertyName
-
- // get the property specifier node for the property the instanceNode represents
- IMXMLPropertySpecifierNode propertySpecifier = (IMXMLPropertySpecifierNode)
- instanceNode.getAncestorOfType( IMXMLPropertySpecifierNode.class);
-
- if (propertySpecifier == null)
- {
- assert false; // I think this indicates an invalid tree...
- }
- else
- {
- // Check the parent - if it's an instance then we want to use these
- // nodes to get our property values from. If not, then it's the root
- // and we don't need to specify destination
-
- IASNode parent = propertySpecifier.getParent();
- if (parent instanceof IMXMLInstanceNode)
- {
- IMXMLInstanceNode parentInstance = (IMXMLInstanceNode)parent;
- String parentId = parentInstance.getEffectiveID();
- assert parentId != null;
- String propName = propertySpecifier.getName();
-
- MXMLVF2JSDescriptorSpecifier dest = new MXMLVF2JSDescriptorSpecifier();
- dest.isProperty = true;
- dest.name = "destination";
- dest.parent = addItems;
- dest.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + parentId + ASEmitterTokens.SINGLE_QUOTE.getToken();
- addItems.propertySpecifiers.add(dest);
-
- MXMLVF2JSDescriptorSpecifier prop = new MXMLVF2JSDescriptorSpecifier();
- prop.isProperty = true;
- prop.name = "propertyName";
- prop.parent = addItems;
- prop.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + propName + ASEmitterTokens.SINGLE_QUOTE.getToken();
- addItems.propertySpecifiers.add(prop);
- }
- }
-
- //---------------------------------------------------------------
- // Third property set: position and relativeTo
- String positionPropertyValue = null;
- String relativeToPropertyValue = null;
-
- // look to see if we have any sibling nodes that are not state dependent
- // that come BEFORE us
- IASNode instanceParent = instanceNode.getParent();
- IASNode prevStatelessSibling=null;
- for (int i=0; i< instanceParent.getChildCount(); ++i)
- {
- IASNode sib = instanceParent.getChild(i);
- assert sib instanceof IMXMLInstanceNode; // surely our siblings are also instances?
-
- // stop looking for previous nodes when we find ourself
- if (sib == instanceNode)
- break;
-
- if (!isStateDependent(sib))
- {
- prevStatelessSibling = sib;
- }
- }
-
- if (prevStatelessSibling == null) {
- positionPropertyValue = "first"; // TODO: these should be named constants
- }
- else {
- positionPropertyValue = "after";
- relativeToPropertyValue = ((IMXMLInstanceNode)prevStatelessSibling).getEffectiveID();
- }
-
- MXMLVF2JSDescriptorSpecifier pos = new MXMLVF2JSDescriptorSpecifier();
- pos.isProperty = true;
- pos.name = "position";
- pos.parent = addItems;
- pos.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + positionPropertyValue + ASEmitterTokens.SINGLE_QUOTE.getToken();
- addItems.propertySpecifiers.add(pos);
-
- if (relativeToPropertyValue != null)
- {
- MXMLVF2JSDescriptorSpecifier rel = new MXMLVF2JSDescriptorSpecifier();
- rel.isProperty = true;
- rel.name = "relativeTo";
- rel.parent = addItems;
- rel.value = ASEmitterTokens.SINGLE_QUOTE.getToken() + relativeToPropertyValue + ASEmitterTokens.SINGLE_QUOTE.getToken();
- addItems.propertySpecifiers.add(rel);
- }
-
- inStatesOverride = false;
- }
-
- private String nameToString(Name name)
- {
- String s = "";
- Namespace ns = name.getSingleQualifier();
- s = ns.getName() + ASEmitterTokens.MEMBER_ACCESS.getToken() + name.getBaseName();
- return s;
- }
- /**
- * Determines whether a node is state-dependent.
- * TODO: we should move to IMXMLNode
- */
- protected boolean isStateDependent(IASNode node)
- {
- if (node instanceof IMXMLSpecifierNode)
- {
- String suffix = ((IMXMLSpecifierNode)node).getSuffix();
- return suffix != null && suffix.length() > 0;
- }
- else if (isStateDependentInstance(node))
- return true;
- return false;
- }
-
- /**
- * Determines whether the geven node is an instance node, as is state dependent
- */
- protected boolean isStateDependentInstance(IASNode node)
- {
- if (node instanceof IMXMLInstanceNode)
- {
- String[] includeIn = ((IMXMLInstanceNode)node).getIncludeIn();
- String[] excludeFrom = ((IMXMLInstanceNode)node).getExcludeFrom();
- return includeIn != null || excludeFrom != null;
- }
- return false;
- }
-
- /**
- * Is a give node a "databinding node"?
- */
- public static boolean isDataBindingNode(IASNode node)
- {
- return node instanceof IMXMLDataBindingNode;
- }
-
- protected static boolean isDataboundProp(IMXMLPropertySpecifierNode propertyNode)
- {
- boolean ret = propertyNode.getChildCount() > 0 && isDataBindingNode(propertyNode.getInstanceNode());
-
- // Sanity check that we based our conclusion about databinding on the correct node.
- // (code assumes only one child if databinding)
- int n = propertyNode.getChildCount();
- for (int i = 0; i < n; i++)
- {
- boolean db = isDataBindingNode(propertyNode.getChild(i));
- assert db == ret;
- }
-
- return ret;
- }
-
- @Override
- public void emitPropertySpecifier(IMXMLPropertySpecifierNode node)
- {
- if (isDataboundProp(node))
- return;
-
- IDefinition cdef = node.getDefinition();
-
- IASNode cnode = node.getChild(0);
-
- MXMLVF2JSDescriptorSpecifier currentInstance = getCurrentDescriptor("i");
-
- MXMLVF2JSDescriptorSpecifier currentPropertySpecifier = new MXMLVF2JSDescriptorSpecifier();
- currentPropertySpecifier.isProperty = true;
- currentPropertySpecifier.name = cdef.getQualifiedName();
- currentPropertySpecifier.parent = currentInstance;
-
- boolean oldInMXMLContent = inMXMLContent;
- if (currentPropertySpecifier.name.equals("mxmlContent"))
- inMXMLContent = true;
-
- if (currentInstance != null)
- currentInstance.propertySpecifiers.add(currentPropertySpecifier);
- else if (inMXMLContent)
- descriptorTree.add(currentPropertySpecifier);
- else
- {
- currentPropertySpecifier.parent = propertiesTree;
- propertiesTree.propertySpecifiers.add(currentPropertySpecifier);
- }
-
- boolean bypass = cnode != null && cnode instanceof IMXMLArrayNode;
-
- currentPropertySpecifier.hasArray = bypass;
-
- moveDown(bypass, null, currentPropertySpecifier);
-
- getMXMLWalker().walk(cnode); // Array or Instance
-
- moveUp(bypass, false);
-
- inMXMLContent = oldInMXMLContent;
- }
-
- @Override
- public void emitScript(IMXMLScriptNode node)
- {
- IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
- .getASEmitter();
-
- String nl = ASEmitterTokens.NEW_LINE.getToken();
-
- StringBuilder sb = null;
- MXMLScriptSpecifier scriptSpecifier = null;
-
- int len = node.getChildCount();
- if (len > 0)
- {
- for (int i = 0; i < len; i++)
- {
- IASNode cnode = node.getChild(i);
-
- if (!(cnode instanceof IImportNode))
- {
- sb = new StringBuilder();
- scriptSpecifier = new MXMLScriptSpecifier();
-
- sb.append(asEmitter.stringifyNode(cnode));
-
- sb.append(ASEmitterTokens.SEMICOLON.getToken());
-
- if (i == len - 1)
- indentPop();
-
- sb.append(nl);
- sb.append(nl);
-
- scriptSpecifier.fragment = sb.toString();
-
- scripts.add(scriptSpecifier);
- }
- }
- }
- }
-
- @Override
- public void emitStyleSpecifier(IMXMLStyleSpecifierNode node)
- {
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- public void emitArray(IMXMLArrayNode node)
- {
- moveDown(false, null, null);
-
- final int len = node.getChildCount();
- for (int i = 0; i < len; i++)
- {
- getMXMLWalker().walk(node.getChild(i)); // Instance
- }
-
- moveUp(false, false);
- }
-
- @Override
- public void emitString(IMXMLStringNode node)
- {
- getCurrentDescriptor("ps").valueNeedsQuotes = true;
-
- emitAttributeValue(node);
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- public void emitLiteral(IMXMLLiteralNode node)
- {
- MXMLVF2JSDescriptorSpecifier ps = getCurrentDescriptor("ps");
- ps.value = "";
-
- if (ps.valueNeedsQuotes)
- ps.value += ASEmitterTokens.SINGLE_QUOTE.getToken();
-
- String s = node.getValue().toString();
- if (ps.valueNeedsQuotes)
- {
- // escape all single quotes found within the string
- s = s.replace(ASEmitterTokens.SINGLE_QUOTE.getToken(),
- "\\" + ASEmitterTokens.SINGLE_QUOTE.getToken());
- }
- ps.value += s;
-
- if (ps.valueNeedsQuotes)
- ps.value += ASEmitterTokens.SINGLE_QUOTE.getToken();
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- public void emitFactory(IMXMLFactoryNode node)
- {
- MXMLVF2JSDescriptorSpecifier ps = getCurrentDescriptor("ps");
- ps.value = "new mx.core.ClassFactory(";
-
- IASNode cnode = node.getChild(0);
- if (cnode instanceof IMXMLClassNode)
- {
- ps.value += ((IMXMLClassNode)cnode).getValue(getMXMLWalker().getProject()).getQualifiedName();
- }
- ps.value += ")";
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- public void emitComponent(IMXMLComponentNode node)
- {
- MXMLVF2JSDescriptorSpecifier ps = getCurrentDescriptor("ps");
- ps.value = "new mx.core.ClassFactory(";
-
- ps.value += node.getName();
- ps.value += ")";
-
- setBufferWrite(true);
- emitSubDocument(node);
- subDocuments.append(getBuilder().toString());
- getBuilder().setLength(0);
- setBufferWrite(false);
- }
-
- //--------------------------------------------------------------------------
- // JS output
- //--------------------------------------------------------------------------
-
- private void emitHeader(IMXMLDocumentNode node)
- {
- String cname = node.getFileNode().getName();
- String bcname = node.getBaseClassName();
-
- writeNewline("/**");
- writeNewline(" * " + cname);
- writeNewline(" *");
- writeNewline(" * @fileoverview");
- writeNewline(" *");
- writeNewline(" * @suppress {checkTypes}");
- writeNewline(" */");
- writeNewline();
-
- emitHeaderLine(cname, true); // provide
- for (String subDocumentName : subDocumentNames)
- emitHeaderLine(subDocumentName, true);
- writeNewline();
- emitHeaderLine(bcname);
- ArrayList<String> writtenInstances = new ArrayList<String>();
- writtenInstances.add(cname); // make sure we don't add ourselves
- writtenInstances.add(bcname); // make sure we don't add the baseclass twice
- for (MXMLVF2JSDescriptorSpecifier instance : instances)
- {
- String name = instance.name;
- if (writtenInstances.indexOf(name) == -1)
- {
- emitHeaderLine(name);
- writtenInstances.add(name);
- }
- }
- FlexJSProject project = (FlexJSProject) getMXMLWalker().getProject();
- ASProjectScope projectScope = (ASProjectScope) project.getScope();
- IDefinition cdef = node.getDefinition();
- ICompilationUnit cu = projectScope
- .getCompilationUnitForDefinition(cdef);
- ArrayList<String> deps = project.getRequires(cu);
-
- if (deps != null)
- {
- for (String imp : deps)
- {
- if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
- continue;
-
- if (imp.equals(cname))
- continue;
-
- if (imp.equals("mx.binding.Binding"))
- continue;
- if (imp.equals("mx.binding.BindingManager"))
- continue;
- if (imp.equals("mx.binding.FunctionReturnWatcher"))
- continue;
- if (imp.equals("mx.binding.PropertyWatcher"))
- continue;
- if (imp.equals("mx.binding.StaticPropertyWatcher"))
- continue;
- if (imp.equals("mx.binding.XMLWatcher"))
- continue;
- if (imp.equals("mx.events.PropertyChangeEvent"))
- continue;
- if (imp.equals("mx.events.PropertyChangeEventKind"))
- continue;
- if (imp.equals("mx.core.DeferredInstanceFromFunction"))
- continue;
-
- if (NativeUtils.isNative(imp))
- continue;
-
- if (writtenInstances.indexOf(imp) == -1)
- {
- emitHeaderLine(imp);
- writtenInstances.add(imp);
- }
- }
- }
-
- // erikdebruin: Add missing language feature support, like the 'is' and
- // 'as' operators. We don't need to worry about requiring
- // this in every project: ADVANCED_OPTIMISATIONS will NOT
- // include any of the code if it is not used in the project.
- if (project.mainCU != null &&
- cu.getName().equals(project.mainCU.getName()))
- {
- emitHeaderLine(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken());
- }
-
- writeNewline();
- writeNewline();
- }
-
- private void emitHeaderLine(String qname)
- {
- emitHeaderLine(qname, false);
- }
-
- private void emitHeaderLine(String qname, boolean isProvide)
- {
- write((isProvide) ? JSGoogEmitterTokens.GOOG_PROVIDE
- : JSGoogEmitterTokens.GOOG_REQUIRE);
- write(ASEmitterTokens.PAREN_OPEN);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(qname);
- write(ASEmitterTokens.SINGLE_QUOTE);
- write(ASEmitterTokens.PAREN_CLOSE);
- writeNewline(ASEmitterTokens.SEMICOLON);
- }
-
- //--------------------------------------------------------------------------
- // Utils
- //--------------------------------------------------------------------------
-
- @Override
- protected void emitAttributeValue(IASNode node)
- {
- IMXMLLiteralNode cnode = (IMXMLLiteralNode) node.getChild(0);
-
- if (cnode.getValue() != null)
- getMXMLWalker().walk((IASNode) cnode); // Literal
- }
-
- private MXMLVF2JSDescriptorSpecifier getCurrentDescriptor(String type)
- {
- MXMLVF2JSDescriptorSpecifier currentDescriptor = null;
-
- int index;
-
- if (type.equals("i"))
- {
- index = currentInstances.size() - 1;
- if (index > -1)
- currentDescriptor = currentInstances.get(index);
- }
- else
- {
- index = currentPropertySpecifiers.size() - 1;
- if (index > -1)
- currentDescriptor = currentPropertySpecifiers.get(index);
- }
-
- return currentDescriptor;
- }
-
- protected void moveDown(boolean byPass,
- MXMLVF2JSDescriptorSpecifier currentInstance,
- MXMLVF2JSDescriptorSpecifier currentPropertySpecifier)
- {
- if (!byPass)
- {
- if (currentInstance != null)
- currentInstances.add(currentInstance);
- }
-
- if (currentPropertySpecifier != null)
- currentPropertySpecifiers.add(currentPropertySpecifier);
- }
-
- protected void moveUp(boolean byPass, boolean isInstance)
- {
- if (!byPass)
- {
- int index;
-
- if (isInstance)
- {
- index = currentInstances.size() - 1;
- if (index > -1)
- currentInstances.remove(index);
- }
- else
- {
- index = currentPropertySpecifiers.size() - 1;
- if (index > -1)
- currentPropertySpecifiers.remove(index);
- }
- }
- }
-
-}