Skip to content

Commit 58c5267

Browse files
committed
working on generics
still not implemented: (o$ = (this.addItem$TE || this.addItem$O)).apply(o$, [o])
1 parent 9afa9d7 commit 58c5267

8 files changed

Lines changed: 306 additions & 284 deletions

File tree

sources/net.sf.j2s.core/src/net/sf/j2s/core/adapters/VariableAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static String listFinalVariables(List<FinalVariable> list, String seperat
181181
* @param node
182182
* @return
183183
*/
184-
public String getConstantValue(Expression node) {
184+
public static String getConstantValue(Expression node) {
185185
if (node == null)
186186
return null;
187187
Object constValue = node.resolveConstantExpressionValue();
@@ -223,7 +223,7 @@ public List<FinalVariable> getVariableList(char fvn) {
223223
}
224224
}
225225

226-
private void addChar(char c, StringBuffer buffer) {
226+
private static void addChar(char c, StringBuffer buffer) {
227227
if (c < 32 || c > 127) {
228228
String hexStr = "0000" + Integer.toHexString(c);
229229
buffer.append("\\u").append(hexStr.substring(hexStr.length() - 4));

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTEmptyVisitor.java

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@
4747
import org.eclipse.jdt.core.dom.EmptyStatement;
4848
import org.eclipse.jdt.core.dom.EnhancedForStatement;
4949
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
50-
import org.eclipse.jdt.core.dom.Expression;
5150
import org.eclipse.jdt.core.dom.ExpressionStatement;
5251
import org.eclipse.jdt.core.dom.FieldAccess;
5352
import org.eclipse.jdt.core.dom.FieldDeclaration;
5453
import org.eclipse.jdt.core.dom.ForStatement;
5554
import org.eclipse.jdt.core.dom.ITypeBinding;
56-
import org.eclipse.jdt.core.dom.IVariableBinding;
5755
import org.eclipse.jdt.core.dom.IfStatement;
5856
import org.eclipse.jdt.core.dom.ImportDeclaration;
5957
import org.eclipse.jdt.core.dom.InfixExpression;
@@ -104,7 +102,6 @@
104102
import org.eclipse.jdt.core.dom.WildcardType;
105103

106104
import net.sf.j2s.core.adapters.AbstractPluginAdapter;
107-
import net.sf.j2s.core.adapters.FieldAdapter;
108105
import net.sf.j2s.core.adapters.FinalVariable;
109106
import net.sf.j2s.core.adapters.J2SMapAdapter;
110107
import net.sf.j2s.core.adapters.TypeAdapter;
@@ -218,62 +215,22 @@ protected static boolean isStatic(BodyDeclaration b) {
218215
}
219216

220217

221-
/**
222-
* We need to check packages only for local "var" variables, as only those will be
223-
* references as unqualified names. And the problem is only the same method.
224-
*
225-
* For example,
226-
*
227-
* var test = 3
228-
*
229-
* x = test.Test_1.getX();
230-
*
231-
*
232-
*
233-
* @param name
234-
* @param checkPackages
235-
* @param addName TODO
236-
* @return
237-
*/
238-
protected void appendValidFieldName$Qualifier(String name, boolean checkPackages, boolean addName) {
239-
boolean isViolation = FieldAdapter.checkKeywordViolation(name, checkPackages ? definedPackageNames : null);
240-
if (isViolation)
241-
buffer.append("$");
242-
if (addName)
243-
buffer.append(name);
244-
}
245-
246-
protected String getClassName() {
218+
protected String getUnqualifiedClassName() {
247219
return ((TypeAdapter) getAdaptable(TypeAdapter.class)).getClassName();
248220
}
249-
protected String getConstantValue(Expression exp) {
250-
return ((VariableAdapter) getAdaptable(VariableAdapter.class)).getConstantValue(exp);
251-
}
252221

253-
protected String getFieldName$Appended(ITypeBinding binding, String name) {
254-
return J2SMapAdapter.getFieldName$Appended(binding, name);
222+
protected String getQualifiedClassName() {
223+
return ((TypeAdapter) getAdaptable(TypeAdapter.class)).getFullClassName();
255224
}
256225

257226
protected List<FinalVariable> getVariableList(char fvn) {
258227
return ((VariableAdapter) getAdaptable(VariableAdapter.class)).getVariableList(fvn);
259228
}
260229

261-
protected String getFullClassName() {
262-
return ((TypeAdapter) getAdaptable(TypeAdapter.class)).getFullClassName();
263-
}
264-
265230
protected String getIndexedVarName(String name, int i) {
266231
return ((VariableAdapter) getAdaptable(VariableAdapter.class)).getIndexedVarName(name, i);
267232
}
268233

269-
protected String getJ2SName(SimpleName node) {
270-
return J2SMapAdapter.getJ2SName(node);
271-
}
272-
273-
protected String getJ2SName(IVariableBinding binding) {
274-
return J2SMapAdapter.getJ2SName(binding);
275-
}
276-
277234
protected String getNormalVariableName(String name) {
278235
return ((VariableAdapter) getAdaptable(VariableAdapter.class)).getNormalVariableName(name);
279236
}

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTJ2SDocVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private boolean addSourceForTagExtended(TagElement tagEl, String prefix, String
262262
StringBuffer buf = new StringBuffer();
263263
String firstLine = getSource(tagEl, buf, true);
264264
buffer.append(prefix);
265-
buffer.append(ExtendedAdapter.buildXSource(getFullClassName(), tagEl.getTagName(), firstLine, buf.toString().trim()));
265+
buffer.append(ExtendedAdapter.buildXSource(getQualifiedClassName(), tagEl.getTagName(), firstLine, buf.toString().trim()));
266266
buffer.append(suffix);
267267
return true;
268268
}

0 commit comments

Comments
 (0)