Skip to content

Commit 08aec50

Browse files
committed
DnD implemented; JSFileBytes implemented; Proxy fixed
1 parent 332516b commit 08aec50

File tree

20 files changed

+374
-4187
lines changed

20 files changed

+374
-4187
lines changed

sources/net.sf.j2s.core/unused/adapters/Bindings.java

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,6 @@
1313
*******************************************************************************/
1414
package net.sf.j2s.core.astvisitors.adapters;
1515

16-
import org.eclipse.jdt.core.dom.IBinding;
17-
import org.eclipse.jdt.core.dom.ITypeBinding;
18-
1916
public class Bindings {
20-
21-
/**
22-
* Checks if the two bindings are equal. First an identity check is
23-
* made an then the key of the bindings are compared.
24-
* @param b1 first binding treated as <code>this</code>. So it must
25-
* not be <code>null</code>
26-
* @param b2 the second binding.
27-
* @return boolean
28-
*/
29-
private static boolean equals(IBinding b1, IBinding b2) {
30-
boolean isEqualTo= b1.isEqualTo(b2);
31-
if (!isEqualTo
32-
&& b1 instanceof ITypeBinding
33-
&& b2 instanceof ITypeBinding) {
34-
ITypeBinding bb1 = (ITypeBinding) b1;
35-
ITypeBinding bb2 = (ITypeBinding) b2;
36-
String bb1Name = bb1.getBinaryName();
37-
if (bb1Name != null) {
38-
isEqualTo = bb1Name.equals(bb2.getBinaryName());
39-
}
40-
}
41-
return isEqualTo;
42-
}
43-
44-
/**
45-
* Returns <code>true</code> if the given type is a super type of a candidate.
46-
* <code>true</code> is returned if the two type bindings are identical
47-
* @param possibleSuperType the type to inspect
48-
* @param type the type whose super types are looked at
49-
* @return <code>true</code> iff <code>possibleSuperType</code> is
50-
* a super type of <code>type</code> or is equal to it
51-
*/
52-
public static boolean isSuperType(ITypeBinding possibleSuperType, ITypeBinding type) {
53-
if (type.isArray() || type.isPrimitive()) {
54-
return false;
55-
}
56-
if (Bindings.equals(type, possibleSuperType)) {
57-
return true;
58-
}
59-
ITypeBinding superClass= type.getSuperclass();
60-
if (superClass != null && isSuperType(possibleSuperType, superClass))
61-
return true;
62-
63-
if (possibleSuperType.isInterface()) {
64-
ITypeBinding[] superInterfaces= type.getInterfaces();
65-
for (int i= 0; i < superInterfaces.length; i++) {
66-
if (isSuperType(possibleSuperType, superInterfaces[i])) {
67-
return true;
68-
}
69-
}
70-
}
71-
return false;
72-
}
7317

7418
}

sources/net.sf.j2s.core/unused/adapters/FieldAdapter.java

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -13,87 +13,11 @@
1313

1414
import java.util.HashSet;
1515

16-
import org.eclipse.jdt.core.dom.Name;
17-
import org.eclipse.jdt.core.dom.QualifiedName;
18-
import org.eclipse.jdt.core.dom.SimpleName;
19-
2016
/**
2117
* @author zhou renjian
2218
*
2319
* 2006-12-3
2420
*/
2521
public class FieldAdapter extends AbstractPluginAdapter {
2622

27-
/*
28-
* IE passes the following:
29-
* public,protected,private,static,package,
30-
* implements,prototype,false,throws,label
31-
*
32-
* Firefox passes the following:
33-
* public,prototype,false,label
34-
*
35-
* The following does not contains all the reserved keywords:
36-
* http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Reserved_Words
37-
*
38-
* abstract, boolean, break, byte,
39-
* case, catch, char, class,
40-
* const, continue, debugger, default,
41-
* delete, do, double, else,
42-
* enum, export, extends, false,
43-
* final, finally, float, for,
44-
* function, goto, if, implements,
45-
* import, in, instanceof, int,
46-
* interface, long, native, new,
47-
* null, package, private, protected,
48-
* public, return, short, static,
49-
* super, switch, synchronized, this,
50-
* throw, throws, transient, true,
51-
* try, typeof, var, void,
52-
* volatile, while, with,
53-
*
54-
*
55-
*
56-
*/
57-
static String[] keywords = new String[] {
58-
"class", /*"java", "javax", "sun", */"for", "while", "do", "in", "return", "function", "var",
59-
"class", "pubic", "protected", "private", "new", "delete",
60-
"static", "package", "import", "extends", "implements",
61-
"instanceof", "typeof", "void", "if", "this", "super",
62-
"prototype", "else", "break", "true", "false", "try",
63-
"catch", "throw", "throws", "continue", "switch", "default",
64-
"case", "export", "import", "const",/*"label", */"with",
65-
// BH and a few of our own, based on checking developer console:
66-
"c$", "apply", "arguments", "bind", "call", "caller",
67-
"watch", "unwatch", "valueOf", "isPrototypeOf", "isGenerator",
68-
"prototype"
69-
};
70-
71-
72-
public static boolean checkKeywordViolation(String name) {
73-
for (int i = 0; i < keywords.length; i++) {
74-
if (keywords[i].equals(name)) {
75-
return true;
76-
}
77-
}
78-
return false;
79-
}
80-
81-
/**
82-
* Check whether the given QualifiedName is just simple or not.
83-
* The "just simple" means foo.bar not just foo?
84-
*
85-
* @param node
86-
* @return
87-
*/
88-
public static boolean isSimpleQualified(QualifiedName node) {
89-
Name qualifier = node.getQualifier();
90-
if (qualifier instanceof SimpleName) {
91-
return true;
92-
} else if (qualifier instanceof QualifiedName) {
93-
return isSimpleQualified((QualifiedName) qualifier);
94-
}
95-
System.err.println(">>> FieldAdapter not simple " + node.getFullyQualifiedName());
96-
return false;
97-
}
98-
9923
}
Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,2 @@
1-
package net.sf.j2s.core.astvisitors.adapters;
1+
package net.sf.j2s.core.astvisitors;
22

3-
/**
4-
* FinalVariable that is used to record variable state, which will provide
5-
* information for compiler to decide the generated name in *.js.
6-
*
7-
* @author zhou renjian
8-
*
9-
* 2006-12-6
10-
*/
11-
public class FinalVariable {
12-
13-
/**
14-
* Level of the block
15-
*/
16-
public int blockLevel;
17-
18-
/**
19-
* Final variable may be in a very deep anonymous class
20-
*/
21-
public String methodScope;
22-
23-
/**
24-
* Variable name that is defined in Java sources
25-
*/
26-
public String variableName;
27-
28-
/**
29-
* Variable name that is to be generated in the compiled *.js
30-
*/
31-
public String toVariableName;
32-
33-
public FinalVariable(int blockLevel, String variableName, String methodScope) {
34-
super();
35-
this.blockLevel = blockLevel;
36-
this.variableName = variableName;
37-
this.methodScope = methodScope;
38-
}
39-
40-
public String toString() {
41-
return variableName + ":" + variableName;
42-
}
43-
44-
public int hashCode() {
45-
final int prime = 31;
46-
int result = 1;
47-
result = prime * result + blockLevel;
48-
result = prime * result
49-
+ ((methodScope == null) ? 0 : methodScope.hashCode());
50-
result = prime * result
51-
+ ((toVariableName == null) ? 0 : toVariableName.hashCode());
52-
result = prime * result
53-
+ ((variableName == null) ? 0 : variableName.hashCode());
54-
return result;
55-
}
56-
57-
public boolean equals(Object obj) {
58-
if (this == obj)
59-
return true;
60-
if (obj == null || getClass() != obj.getClass())
61-
return false;
62-
final FinalVariable other = (FinalVariable) obj;
63-
if (blockLevel != other.blockLevel)
64-
return false;
65-
if (methodScope == null) {
66-
if (other.methodScope != null)
67-
return false;
68-
} else if (!methodScope.equals(other.methodScope))
69-
return false;
70-
if (toVariableName == null) {
71-
if (other.toVariableName != null)
72-
return false;
73-
} else if (!toVariableName.equals(other.toVariableName))
74-
return false;
75-
if (variableName == null) {
76-
if (other.variableName != null)
77-
return false;
78-
} else if (!variableName.equals(other.variableName))
79-
return false;
80-
return true;
81-
}
82-
83-
}

0 commit comments

Comments
 (0)