Skip to content

Commit d7159a7

Browse files
author
zhourenjian
committed
Merge branch 3.3's modifications to revision 918
1 parent 537147d commit d7159a7

File tree

5 files changed

+84
-16
lines changed

5 files changed

+84
-16
lines changed

META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Java2Script Core
44
Bundle-SymbolicName: net.sf.j2s.core; singleton:=true
5-
Bundle-Version: 1.0.0
5+
Bundle-Version: 2.0.0
66
Bundle-Activator: net.sf.j2s.core.CorePlugin
77
Bundle-Vendor: j2s.sourceforge.net
88
Bundle-Localization: plugin

src/net/sf/j2s/core/astvisitors/ASTKeywordVisitor.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,19 +1061,39 @@ public boolean visit(TryStatement node) {
10611061
buffer.append("try ");
10621062
node.getBody().accept(this);
10631063
List catchClauses = node.catchClauses();
1064-
if (catchClauses.size() > 0) {
1065-
buffer.append(" catch (e) {\r\n");
1066-
buffer.append("if (Clazz.instanceOf (e, ");
1064+
int size = catchClauses.size();
1065+
if (size > 0) {
1066+
String catchEName = "e$$";
1067+
if (size == 1) {
1068+
CatchClause element = (CatchClause) catchClauses.get(0);
1069+
SimpleName exName = element.getException().getName();
1070+
catchEName = exName.getIdentifier();
1071+
}
1072+
buffer.append(" catch (" + catchEName + ") {\r\n");
1073+
buffer.append("if (Clazz.instanceOf (" + catchEName + ", ");
10671074
for (Iterator iter = catchClauses.iterator(); iter.hasNext();) {
10681075
CatchClause element = (CatchClause) iter.next();
10691076
element.getException().getType().accept(this);
10701077
buffer.append(")) ");
1078+
SimpleName exName = element.getException().getName();
1079+
String eName = exName.getIdentifier();
1080+
boolean notEName = false;
1081+
if (!catchEName.equals(eName)) {
1082+
buffer.append("{\r\n");
1083+
buffer.append("var ");
1084+
buffer.append(eName);
1085+
buffer.append(" = " + catchEName + ";\r\n");
1086+
notEName = true;
1087+
}
10711088
element.getBody().accept(this);
1089+
if (notEName) {
1090+
buffer.append("\r\n}");
1091+
}
10721092
if (iter.hasNext()) {
1073-
buffer.append(" else if (Clazz.instanceOf (e, ");
1093+
buffer.append(" else if (Clazz.instanceOf (" + catchEName + ", ");
10741094
}
10751095
}
1076-
buffer.append(" else {\r\nthrow e;\r\n}\r\n}");
1096+
buffer.append(" else {\r\nthrow " + catchEName + ";\r\n}\r\n}");
10771097
}
10781098
Block finallys = node.getFinally();
10791099
if (finallys != null) {

src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.eclipse.jdt.core.dom.SimpleType;
4848
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
4949
import org.eclipse.jdt.core.dom.Statement;
50-
import org.eclipse.jdt.core.dom.StringLiteral;
5150
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
5251
import org.eclipse.jdt.core.dom.SuperFieldAccess;
5352
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
@@ -1144,6 +1143,26 @@ public void endVisit(MethodDeclaration node) {
11441143
return;
11451144
}
11461145
}
1146+
String[] pipeMethods = new String[] {
1147+
"pipeSetup",
1148+
"pipeThrough",
1149+
"through",
1150+
"pipeMonitoring",
1151+
"pipeMonitoringInterval",
1152+
"setPipeHelper"
1153+
};
1154+
for (int i = 0; i < pipeMethods.length; i++) {
1155+
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.SimplePipeRunnable", pipeMethods[i])) {
1156+
if (getJ2SDocTag(node, "@j2sKeep") == null) {
1157+
return;
1158+
}
1159+
}
1160+
}
1161+
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.CompoundPipeSession", "convert")) {
1162+
if (getJ2SDocTag(node, "@j2sKeep") == null) {
1163+
return;
1164+
}
1165+
}
11471166
if (mBinding != null) {
11481167
methodDeclareStack.pop();
11491168
}
@@ -1166,17 +1185,12 @@ public boolean visit(MethodDeclaration node) {
11661185
}
11671186
}
11681187
String[] pipeMethods = new String[] {
1169-
"isPipeLive",
1170-
"keepPipeLive",
1171-
"pipeDestroy",
11721188
"pipeSetup",
11731189
"pipeThrough",
11741190
"through",
1175-
"pipeInit",
11761191
"pipeMonitoring",
11771192
"pipeMonitoringInterval",
1178-
"setPipeHelper",
1179-
"updateStatus"
1193+
"setPipeHelper"
11801194
};
11811195
for (int i = 0; i < pipeMethods.length; i++) {
11821196
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.SimplePipeRunnable", pipeMethods[i])) {
@@ -1185,6 +1199,11 @@ public boolean visit(MethodDeclaration node) {
11851199
}
11861200
}
11871201
}
1202+
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.CompoundPipeSession", "convert")) {
1203+
if (getJ2SDocTag(node, "@j2sKeep") == null) {
1204+
return false;
1205+
}
1206+
}
11881207
if (mBinding != null) {
11891208
methodDeclareStack.push(mBinding.getKey());
11901209
}

src/net/sf/j2s/core/astvisitors/DependencyASTVisitor.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import java.util.Set;
2121
import org.eclipse.jdt.core.dom.ASTNode;
2222
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
23-
import org.eclipse.jdt.core.dom.ArrayCreation;
24-
import org.eclipse.jdt.core.dom.ArrayType;
2523
import org.eclipse.jdt.core.dom.Block;
2624
import org.eclipse.jdt.core.dom.CatchClause;
2725
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -129,6 +127,12 @@ protected void checkSuperType(Set set) {
129127

130128

131129
protected void remedyReflectionDependency(Set set) {
130+
String[] classNames = getClassNames();
131+
for (int i = 0; i < classNames.length; i++) {
132+
if ("net.sf.j2s.ajax.ASWTClass".equals(classNames[i])) {
133+
return;
134+
}
135+
}
132136
boolean needRemedy = false;;
133137
for (Iterator iterator = set.iterator(); iterator.hasNext();) {
134138
Object next = iterator.next();
@@ -890,7 +894,32 @@ public void setToCompileVariableName(boolean toCompileVariableName) {
890894

891895
public boolean visit(MethodDeclaration node) {
892896
IMethodBinding mBinding = node.resolveBinding();
897+
boolean toBeIgnored = false;
893898
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.SimpleRPCRunnable", "ajaxRun")) {
899+
toBeIgnored = true;
900+
}
901+
if (!toBeIgnored) {
902+
String[] pipeMethods = new String[] {
903+
"pipeSetup",
904+
"pipeThrough",
905+
"through",
906+
"pipeMonitoring",
907+
"pipeMonitoringInterval",
908+
"setPipeHelper"
909+
};
910+
for (int i = 0; i < pipeMethods.length; i++) {
911+
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.SimplePipeRunnable", pipeMethods[i])) {
912+
toBeIgnored = true;
913+
break;
914+
}
915+
}
916+
}
917+
if (!toBeIgnored) {
918+
if (Bindings.isMethodInvoking(mBinding, "net.sf.j2s.ajax.CompoundPipeSession", "convert")) {
919+
toBeIgnored = true;
920+
}
921+
}
922+
if (toBeIgnored) {
894923
boolean toKeep = false;
895924
Javadoc javadoc = node.getJavadoc();
896925
if (javadoc != null) {

src/net/sf/j2s/core/astvisitors/MethodReferenceASTVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class MethodReferenceASTVisitor extends ASTVisitor {
3333

3434
private MethodReferenceASTVisitor(String methodSignature) {
3535
super();
36-
this.methodSignature = methodSignature;
36+
this.methodSignature = methodSignature.replaceAll("<[^>]+>", "");
3737
}
3838

3939
public static boolean checkReference(ASTNode node, String methodSignature) {

0 commit comments

Comments
 (0)