You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/06/04 08:06:15 UTC
[09/42] git commit: [flex-falcon] [refs/heads/develop] - - Refactored
Class emitting into shared jx package for future use. - Refactored Bindable
class level emittion;
- Refactored GetSet class level emition - Created a shared model for each
emitter sess
- Refactored Class emitting into shared jx package for future use.
- Refactored Bindable class level emittion;
- Refactored GetSet class level emition
- Created a shared model for each emitter session.
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/ab1c421d
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/ab1c421d
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/ab1c421d
Branch: refs/heads/develop
Commit: ab1c421dcd7b60dcef6f118db2379bb5f4bfe8e5
Parents: dca1ad1
Author: Michael Schmalle <ms...@apache.org>
Authored: Sat May 30 17:40:46 2015 -0400
Committer: Frédéric THOMAS <we...@gmail.com>
Committed: Tue Jun 2 13:40:06 2015 +0100
----------------------------------------------------------------------
.../js/flexjs/TestFlexJSExpressions.java | 18 +-
.../mxml/flexjs/TestFlexJSMXMLScript.java | 2 +-
.../flex/compiler/codegen/ISubEmitter.java | 45 +
.../flex/compiler/codegen/js/IJSEmitter.java | 3 +-
.../compiler/internal/codegen/as/ASEmitter.java | 2 +-
.../compiler/internal/codegen/js/JSEmitter.java | 9 +
.../internal/codegen/js/JSSessionModel.java | 79 +
.../internal/codegen/js/JSSubEmitter.java | 99 ++
.../internal/codegen/js/amd/JSAMDEmitter.java | 2 +
.../codegen/js/flexjs/JSFlexJSDocEmitter.java | 134 +-
.../codegen/js/flexjs/JSFlexJSEmitter.java | 1524 +++++++-----------
.../internal/codegen/js/goog/JSGoogEmitter.java | 33 +-
.../internal/codegen/js/jx/BindableEmitter.java | 76 +
.../internal/codegen/js/jx/ClassEmitter.java | 156 ++
.../internal/codegen/js/jx/GetSetEmitter.java | 195 +++
.../codegen/js/utils/DocEmitterUtils.java | 49 +
.../internal/codegen/js/utils/EmitterUtils.java | 121 ++
.../codegen/js/vf2js/JSVF2JSEmitter.java | 10 +-
.../codegen/mxml/flexjs/MXMLFlexJSEmitter.java | 14 +-
.../codegen/mxml/vf2js/MXMLVF2JSEmitter.java | 4 +-
20 files changed, 1573 insertions(+), 1002 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index 9691b70..99fc70f 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -19,7 +19,7 @@
package org.apache.flex.compiler.internal.codegen.js.flexjs;
-import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.IClassDefinition;
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.flexjs.FlexJSBackend;
@@ -164,9 +164,9 @@ public class TestFlexJSExpressions extends TestGoogExpressions
IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
fnode, IBinaryOperatorNode.class);
((NodeBase)fnode).setParent(null);
- IDefinition def = classnode.getDefinition();
+ IClassDefinition def = classnode.getDefinition();
- ((JSFlexJSEmitter)asEmitter).thisClass = def;
+ ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
asBlockWalker.visitBinaryOperator(bnode);
assertOut("this.b = 1");
}
@@ -188,9 +188,9 @@ public class TestFlexJSExpressions extends TestGoogExpressions
IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
fnode, IBinaryOperatorNode.class);
((NodeBase)fnode).setParent(null);
- IDefinition def = classnode.getDefinition();
+ IClassDefinition def = classnode.getDefinition();
- ((JSFlexJSEmitter)asEmitter).thisClass = def;
+ ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
asBlockWalker.visitBinaryOperator(bnode);
assertOut("this.b = 1");
}
@@ -478,9 +478,9 @@ public class TestFlexJSExpressions extends TestGoogExpressions
IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
fnode, IBinaryOperatorNode.class);
((NodeBase)fnode).setParent(null);
- IDefinition def = classnode.getDefinition();
+ IClassDefinition def = classnode.getDefinition();
- ((JSFlexJSEmitter)asEmitter).thisClass = def;
+ ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
asBlockWalker.visitBinaryOperator(bnode);
assertOut("foo_bar_B.d.b = 1");
}
@@ -538,9 +538,9 @@ public class TestFlexJSExpressions extends TestGoogExpressions
IBinaryOperatorNode bnode = (IBinaryOperatorNode) findFirstDescendantOfType(
fnode, IBinaryOperatorNode.class);
((NodeBase)fnode).setParent(null);
- IDefinition def = classnode.getDefinition();
+ IClassDefinition def = classnode.getDefinition();
- ((JSFlexJSEmitter)asEmitter).thisClass = def;
+ ((JSFlexJSEmitter)asEmitter).getModel().setCurrentClass(def);
asBlockWalker.visitBinaryOperator(bnode);
assertOut("org_apache_flex_utils_Language.as(this.model, foo_bar_E, true).labelText = null");
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLScript.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLScript.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLScript.java
index 8984cd4..6d79603 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLScript.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLScript.java
@@ -40,7 +40,7 @@ public class TestFlexJSMXMLScript extends FlexJSTestBase
IMXMLDocumentNode dnode = (IMXMLDocumentNode) node
.getAncestorOfType(IMXMLDocumentNode.class);
- ((JSFlexJSEmitter)(mxmlBlockWalker.getASEmitter())).thisClass = dnode.getDefinition();
+ ((JSFlexJSEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
mxmlBlockWalker.visitDocument(dnode);
String appName = dnode.getQualifiedName();
String outTemplate = "/**\n * AppName\n *\n * @fileoverview\n *\n * @suppress {checkTypes}\n */\n\ngoog.provide('AppName');\n\ngoog.require('org_apache_flex_core_Application');\n\n\n\n\n/**\n * @constructor\n * @extends {org_apache_flex_core_Application}\n */\nAppName = function() {\n AppName.base(this, 'constructor');\n \n /**\n * @private\n * @type {Array}\n */\n this.mxmldd;\n \n /**\n * @private\n * @type {Array}\n */\n this.mxmldp;\n};\ngoog.inherits(AppName, org_apache_flex_core_Application);\n\n\n/**\n * Metadata\n *\n * @type {Object.<string, Array.<Object>>}\n */\nAppName.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'AppName', qName: 'AppName' }] };\n\n\n/**\n * @expose\n * @override\n */\nAppName.prototype.addedToParent = function() {\n AppName.base(this, 'addedToParent');\n};\n\n\n";
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/codegen/ISubEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/ISubEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/ISubEmitter.java
new file mode 100644
index 0000000..1431c4b
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/ISubEmitter.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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;
+
+import org.apache.flex.compiler.tree.as.IASNode;
+
+/**
+ * The {@link IEmitter} emitter can use composition for it's more
+ * complicated production sequences with member, dynamic, binary expressions and
+ * identifiers etc.
+ *
+ * @author Michael Schmalle
+ */
+public interface ISubEmitter<T>
+{
+ /**
+ * The main emitter will call this method of the sub emitter with the
+ * correct generic type implemented.
+ * <p>
+ * The main idea here is abstraction. Producing JavaScript can get
+ * complicated, the best way to avoid bugs is to avoid as much state and
+ * interdependence between emit() calls of the main emitter.
+ *
+ * @param node The current {@link IASNode} being emitted by the
+ * {@link IEmitter}.
+ */
+ void emit(T node);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
index 09bb858..01444e7 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
@@ -22,6 +22,7 @@ package org.apache.flex.compiler.codegen.js;
import java.io.Writer;
import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
import org.apache.flex.compiler.visitor.IASNodeStrategy;
/**
@@ -32,5 +33,5 @@ import org.apache.flex.compiler.visitor.IASNodeStrategy;
*/
public interface IJSEmitter extends IASEmitter
{
-
+ JSSessionModel getModel();
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index b7db495..423571b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -717,7 +717,7 @@ public class ASEmitter implements IASEmitter, IEmitter
getWalker().walk(node.getNameExpressionNode());
}
- protected void emitParameters(IParameterNode[] nodes)
+ public void emitParameters(IParameterNode[] nodes)
{
write(ASEmitterTokens.PAREN_OPEN);
int len = nodes.length;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
index 6fb5576..4eb6ccb 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
@@ -33,10 +33,19 @@ import org.apache.flex.compiler.tree.as.IFunctionObjectNode;
*/
public class JSEmitter extends ASEmitter implements IJSEmitter
{
+ private JSSessionModel model;
+
+ @Override
+ public JSSessionModel getModel()
+ {
+ return model;
+ }
public JSEmitter(FilterWriter out)
{
super(out);
+
+ model = new JSSessionModel();
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
new file mode 100644
index 0000000..97cc52b
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSessionModel.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+
+/**
+ * @author Michael Schmalle
+ */
+public class JSSessionModel
+{
+ private IClassDefinition currentClass;
+
+ public static class PropertyNodes
+ {
+ public IGetterNode getter;
+ public ISetterNode setter;
+ }
+
+ private HashMap<String, PropertyNodes> propertyMap = new HashMap<String, PropertyNodes>();
+
+ private HashMap<String, PropertyNodes> staticPropertyMap = new HashMap<String, PropertyNodes>();
+
+ private ArrayList<String> bindableVars = new ArrayList<String>();
+
+ public IClassDefinition getCurrentClass()
+ {
+ return currentClass;
+ }
+
+ public void setCurrentClass(IClassDefinition currentClass)
+ {
+ this.currentClass = currentClass;
+ }
+
+ public HashMap<String, PropertyNodes> getPropertyMap()
+ {
+ return propertyMap;
+ }
+
+ public HashMap<String, PropertyNodes> getStaticPropertyMap()
+ {
+ return staticPropertyMap;
+ }
+
+ public boolean hasBindableVars()
+ {
+ return bindableVars.size() > 0;
+ }
+
+ public List<String> getBindableVars()
+ {
+ return bindableVars;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
new file mode 100644
index 0000000..00ed207
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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;
+
+import org.apache.flex.compiler.codegen.IEmitterTokens;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.projects.ICompilerProject;
+
+public class JSSubEmitter
+{
+ private IJSEmitter emitter;
+
+ protected IJSEmitter getEmitter()
+ {
+ return emitter;
+ }
+
+ protected ICompilerProject getProject()
+ {
+ return emitter.getWalker().getProject();
+ }
+
+ protected JSSessionModel getModel()
+ {
+ return emitter.getModel();
+ }
+
+ public JSSubEmitter(IJSEmitter emitter)
+ {
+ this.emitter = emitter;
+ }
+
+ protected void write(IEmitterTokens value)
+ {
+ emitter.write(value);
+ }
+
+ protected void write(String value)
+ {
+ emitter.write(value);
+ }
+
+ protected void writeToken(IEmitterTokens value)
+ {
+ emitter.writeToken(value);
+ }
+
+ protected void writeToken(String value)
+ {
+ emitter.writeToken(value);
+ }
+
+ protected void writeNewline()
+ {
+ emitter.writeNewline();
+ }
+
+ protected void writeNewline(IEmitterTokens value)
+ {
+ emitter.writeNewline(value);
+ }
+
+ protected void writeNewline(String value)
+ {
+ emitter.writeNewline(value);
+ }
+
+ protected void writeNewline(String value, boolean pushIndent)
+ {
+ emitter.writeNewline(value, pushIndent);
+ }
+
+ protected void indentPush()
+ {
+ emitter.indentPush();
+ }
+
+ protected void indentPop()
+ {
+ emitter.indentPop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
index bc45058..8dcbb2c 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
@@ -251,6 +251,8 @@ public class JSAMDEmitter extends JSEmitter implements IJSAMDEmitter
//ICompilerProject project = getWalker().getProject();
IClassDefinition definition = node.getDefinition();
+ getModel().setCurrentClass(definition);
+
final String className = definition.getBaseName();
write("AS3.compilationUnit($exports, function($primaryDeclaration){");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab1c421d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
index 701bb99..b7ba9bd 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java
@@ -20,6 +20,7 @@
package org.apache.flex.compiler.internal.codegen.js.flexjs;
import java.util.ArrayList;
+import java.util.List;
import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
import org.apache.flex.compiler.clients.MXMLJSC;
@@ -46,50 +47,59 @@ import org.apache.flex.compiler.tree.as.IVariableNode;
public class JSFlexJSDocEmitter extends JSGoogDocEmitter
{
+ private List<String> classIgnoreList;
+ private List<String> ignoreList;
public JSFlexJSDocEmitter(IJSEmitter emitter)
{
super(emitter);
}
- public ArrayList<String> classIgnoreList;
- private ArrayList<String> ignoreList;
+ public List<String> getClassIgnoreList()
+ {
+ return classIgnoreList;
+ }
+ public void setClassIgnoreList(List<String> value)
+ {
+ this.classIgnoreList = value;
+ }
+
@Override
protected String convertASTypeToJS(String name, String pname)
{
- if (ignoreList != null)
- {
- if (ignoreList.contains(pname + "." + name))
- return IASLanguageConstants.Object;
- }
- if (classIgnoreList != null)
- {
- if (classIgnoreList.contains(pname + "." + name))
- return IASLanguageConstants.Object;
- }
- name = super.convertASTypeToJS(name, pname);
- return formatQualifiedName(name);
+ if (ignoreList != null)
+ {
+ if (ignoreList.contains(pname + "." + name))
+ return IASLanguageConstants.Object;
+ }
+ if (classIgnoreList != null)
+ {
+ if (classIgnoreList.contains(pname + "." + name))
+ return IASLanguageConstants.Object;
+ }
+ name = super.convertASTypeToJS(name, pname);
+ return formatQualifiedName(name);
}
-
+
@Override
protected String formatQualifiedName(String name)
{
- if (name.contains("goog.") || name.startsWith("Vector."))
- return name;
- name = name.replaceAll("\\.", "_");
- return name;
+ if (name.contains("goog.") || name.startsWith("Vector."))
+ return name;
+ name = name.replaceAll("\\.", "_");
+ return name;
}
@Override
public void emitMethodDoc(IFunctionNode node, ICompilerProject project)
{
ignoreList = null;
-
+
IClassDefinition classDefinition = resolveClassDefinition(node);
ASDocComment asDoc = (ASDocComment) node.getASDocComment();
-
+
if (node instanceof IFunctionNode)
{
boolean hasDoc = false;
@@ -122,7 +132,9 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
.getContainingScope(),
DependencyType.INHERITANCE, true);
if (type == null)
- System.out.println(iReference.getDisplayString() + " not resolved in " + classDefinition.getQualifiedName());
+ System.out.println(iReference.getDisplayString()
+ + " not resolved in "
+ + classDefinition.getQualifiedName());
emitImplements(type, type.getPackageName());
}
}
@@ -133,10 +145,11 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
{
if (asDoc != null && MXMLJSC.keepASDoc)
{
- String docText = asDoc.commentNoEnd();
- String ignoreToken = JSFlexJSEmitterTokens.IGNORE_COERCION.getToken();
- if (docText.contains(ignoreToken))
- loadIgnores(docText);
+ String docText = asDoc.commentNoEnd();
+ String ignoreToken = JSFlexJSEmitterTokens.IGNORE_COERCION
+ .getToken();
+ if (docText.contains(ignoreToken))
+ loadIgnores(docText);
write(changeAnnotations(asDoc.commentNoEnd()));
}
else
@@ -166,7 +179,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
ITypeDefinition tdef = enode.resolveType(project);
if (tdef == null)
continue;
-
+
emitParam(pnode, tdef.getPackageName());
}
@@ -187,12 +200,12 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
hasDoc = true;
}
- ITypeDefinition tdef = ((IFunctionDefinition)node.getDefinition())
- .resolveReturnType(project);
+ ITypeDefinition tdef = ((IFunctionDefinition) node
+ .getDefinition()).resolveReturnType(project);
String packageName = "";
packageName = tdef.getPackageName();
-
+
emitReturn(node, packageName);
}
@@ -221,38 +234,40 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
private void loadIgnores(String doc)
{
- ignoreList = new ArrayList<String>();
- String ignoreToken = JSFlexJSEmitterTokens.IGNORE_COERCION.getToken();
- int index = doc.indexOf(ignoreToken);
- while (index != -1)
- {
- String ignorable = doc.substring(index + ignoreToken.length());
- int endIndex = ignorable.indexOf("\n");
- ignorable = ignorable.substring(0, endIndex);
- ignorable = ignorable.trim();
- ignoreList.add(ignorable);
- index = doc.indexOf(ignoreToken, index + endIndex);
- }
+ ignoreList = new ArrayList<String>();
+ String ignoreToken = JSFlexJSEmitterTokens.IGNORE_COERCION.getToken();
+ int index = doc.indexOf(ignoreToken);
+ while (index != -1)
+ {
+ String ignorable = doc.substring(index + ignoreToken.length());
+ int endIndex = ignorable.indexOf("\n");
+ ignorable = ignorable.substring(0, endIndex);
+ ignorable = ignorable.trim();
+ ignoreList.add(ignorable);
+ index = doc.indexOf(ignoreToken, index + endIndex);
+ }
}
+
private String changeAnnotations(String doc)
{
- // rename these tags so they don't conflict with generated
- // jsdoc tags
- String pass1 = doc.replaceAll("@param", "@asparam");
- String pass2 = pass1.replaceAll("@return", "@asreturn");
- String pass3 = pass2.replaceAll("@private", "@asprivate");
- return pass3;
+ // rename these tags so they don't conflict with generated
+ // jsdoc tags
+ String pass1 = doc.replaceAll("@param", "@asparam");
+ String pass2 = pass1.replaceAll("@return", "@asreturn");
+ String pass3 = pass2.replaceAll("@private", "@asprivate");
+ return pass3;
}
-
- public void emitInterfaceMemberDoc(IDefinitionNode node, ICompilerProject project)
+
+ public void emitInterfaceMemberDoc(IDefinitionNode node,
+ ICompilerProject project)
{
boolean hasDoc = false;
-
- ASDocComment asDoc = (ASDocComment) ((IFunctionNode) node).getASDocComment();
-
+
+ ASDocComment asDoc = (ASDocComment) ((IFunctionNode) node)
+ .getASDocComment();
+
String returnType = ((IFunctionNode) node).getReturnType();
- if (returnType != ""
- && returnType != ASEmitterTokens.VOID.getToken()) // has return
+ if (returnType != "" && returnType != ASEmitterTokens.VOID.getToken()) // has return
{
if (asDoc != null && MXMLJSC.keepASDoc)
write(changeAnnotations(asDoc.commentNoEnd()));
@@ -260,13 +275,14 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
begin();
hasDoc = true;
- ITypeDefinition tdef = ((IFunctionDefinition)node.getDefinition())
+ ITypeDefinition tdef = ((IFunctionDefinition) node.getDefinition())
.resolveReturnType(project);
emitReturn((IFunctionNode) node, tdef.getPackageName());
}
- IParameterNode[] parameters = ((IFunctionNode) node).getParameterNodes();
+ IParameterNode[] parameters = ((IFunctionNode) node)
+ .getParameterNodes();
for (IParameterNode pnode : parameters)
{
if (!hasDoc)
@@ -303,7 +319,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
emitPublic(node);
}
}
-
+
@Override
public void emitFieldDoc(IVariableNode node, IDefinition def)
{
@@ -320,7 +336,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
}
else
{
- emitPublic(node);
+ emitPublic(node);
}
if (node.isConst())