flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [7/8] git commit: [flex-falcon] [refs/heads/develop] - allow omission of unused types from jsdoc
Date Sat, 15 Nov 2014 06:28:29 GMT
allow omission of unused types from jsdoc


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/e7f31d1c
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/e7f31d1c
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/e7f31d1c

Branch: refs/heads/develop
Commit: e7f31d1c50767e001db43fcdf8c0f13ce916ab6a
Parents: 2ee9fb2
Author: Alex Harui <aharui@apache.org>
Authored: Fri Nov 14 16:46:57 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Nov 14 16:46:57 2014 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSDocEmitter.java   | 47 +++++++++++++++++++-
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 32 ++++++++++++-
 .../codegen/js/goog/JSGoogDocEmitter.java       |  2 +-
 3 files changed, 76 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e7f31d1c/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 052547c..b676956 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
@@ -19,6 +19,8 @@
 
 package org.apache.flex.compiler.internal.codegen.js.flexjs;
 
+import java.util.ArrayList;
+
 import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
 import org.apache.flex.compiler.clients.MXMLJSC;
 import org.apache.flex.compiler.codegen.js.IJSEmitter;
@@ -33,7 +35,6 @@ 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;
@@ -49,9 +50,30 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
         super(emitter);
     }
 
+    public ArrayList<String> classIgnoreList;
+    private ArrayList<String> ignoreList;
+    
+    @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;
+    	}
+    	return super.convertASTypeToJS(name, pname);
+    }
+
     @Override
     public void emitMethodDoc(IFunctionNode node, ICompilerProject project)
     {
+        ignoreList = null;
+        
         IClassDefinition classDefinition = resolveClassDefinition(node);
 
         ASDocComment asDoc = (ASDocComment) node.getASDocComment();
@@ -98,7 +120,13 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
                 if (ns != null)
                 {
                     if (asDoc != null && MXMLJSC.keepASDoc)
+                    {
+                    	String docText = asDoc.commentNoEnd();
+    		            String ignoreToken = JSFlexJSEmitterTokens.IGNORE_COERCION.getToken();
+                    	if (docText.contains(ignoreToken))
+                    		loadIgnores(docText);
                         write(changeAnnotations(asDoc.commentNoEnd()));
+                    }
                     else
                         begin();
                     emitMethodAccess(node);
@@ -178,7 +206,22 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter
                 end();
         }
     }
-    
+
+    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);
+    	}
+    }
     private String changeAnnotations(String doc)
     {
     	// rename these tags so they don't conflict with generated

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e7f31d1c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 7dbd74e..5e4951b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
+import org.apache.flex.compiler.clients.MXMLJSC;
 import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants;
 import org.apache.flex.compiler.codegen.IDocEmitter;
 import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter;
@@ -130,6 +131,10 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     {
         thisClass = node.getDefinition();
 
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        if (asDoc != null && MXMLJSC.keepASDoc)
+        	loadImportIgnores(asDoc.commentNoEnd());
+        
         project = getWalker().getProject();
 
         IClassDefinition definition = node.getDefinition();
@@ -200,7 +205,25 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         }
     }
 
-    @Override
+    private void loadImportIgnores(String doc) 
+    {
+    	ArrayList<String> ignoreList = new ArrayList<String>();
+    	String ignoreToken = JSFlexJSEmitterTokens.IGNORE_IMPORT.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);
+    	}
+    	this.getDocEmitter();
+    	docEmitter.classIgnoreList = ignoreList;
+	}
+
+	@Override
     public void emitInterface(IInterfaceNode node)
     {
         ICompilerProject project = getWalker().getProject();
@@ -1260,10 +1283,14 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         write("_");
     }
 
+    private JSFlexJSDocEmitter docEmitter = null;
+    
     @Override
     public IDocEmitter getDocEmitter()
     {
-        return new JSFlexJSDocEmitter(this);
+        if (docEmitter == null)
+        	docEmitter = new JSFlexJSDocEmitter(this);
+        return docEmitter;
     }
 
     @Override
@@ -1744,4 +1771,5 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         }
         super.emitUnaryOperator(node);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e7f31d1c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogDocEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogDocEmitter.java
index 242cc4e..8986fa4 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogDocEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogDocEmitter.java
@@ -455,7 +455,7 @@ public class JSGoogDocEmitter extends JSDocEmitter implements IJSGoogDocEmitter
         return false;
     }
 
-    private String convertASTypeToJS(String name, String pname)
+    protected String convertASTypeToJS(String name, String pname)
     {
         String result = "";
 


Mime
View raw message