88import java .text .SimpleDateFormat ;
99import java .util .ArrayList ;
1010import java .util .Date ;
11- import java .util .HashMap ;
1211import java .util .Iterator ;
1312import java .util .List ;
14- import java .util .Map ;
1513import java .util .Properties ;
1614import java .util .regex .Matcher ;
1715import java .util .regex .Pattern ;
2422import org .eclipse .jdt .core .dom .CompilationUnit ;
2523import org .eclipse .jdt .internal .compiler .env .ICompilationUnit ;
2624
27- import net .sf .j2s .core .astvisitors .ASTJ2SMapVisitor ;
25+ import net .sf .j2s .core .astvisitors .ASTEmptyVisitor ;
2826import net .sf .j2s .core .astvisitors .ASTScriptVisitor ;
2927import net .sf .j2s .core .astvisitors .ASTVariableVisitor ;
3028import net .sf .j2s .core .astvisitors .DependencyASTVisitor ;
31- import net .sf .j2s .core .astvisitors .NameConvertItem ;
3229import net .sf .j2s .core .astvisitors .SWTDependencyASTVisitor ;
3330import net .sf .j2s .core .astvisitors .SWTScriptVisitor ;
3431import net .sf .j2s .core .builder .SourceFile ;
@@ -161,7 +158,8 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
161158 }
162159 }
163160 if (dvisitor == null ) {
164- dvisitor = new SWTDependencyASTVisitor ();
161+ // BH - we are done with SWT dvisitor = new SWTDependencyASTVisitor();
162+ dvisitor = new DependencyASTVisitor ();
165163 }
166164 }
167165 try {
@@ -206,6 +204,7 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
206204 visitor = new SWTScriptVisitor ();
207205 }
208206 }
207+ ASTEmptyVisitor .setNoQualifiedNamePackages (props .getProperty ("j2s.compiler.method.overloading" ));
209208 boolean ignoreMethodOverloading = !("enable" .equals (props .getProperty ("j2s.compiler.method.overloading" )));
210209 visitor .setSupportsMethodOverloading (!ignoreMethodOverloading );
211210 boolean supportsInterfaceCasting = "enable" .equals (props .getProperty ("j2s.compiler.interface.casting" ));
@@ -215,13 +214,12 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
215214 boolean isDebugging = "debug" .equals (props .getProperty ("j2s.compiler.mode" ));
216215 visitor .setDebugging (isDebugging );
217216 dvisitor .setDebugging (isDebugging );
218- boolean toCompress = "enable" .equals (props .getProperty ("j2s.compiler.allow.compression" ))
219- && "release" .equals (props .getProperty ("j2s.compiler.mode" )); // BH added
217+ boolean toCompress = false ; //"enable".equals(props.getProperty("j2s.compiler.allow.compression"))); // BH
220218 ((ASTVariableVisitor ) visitor .getAdaptable (ASTVariableVisitor .class )).setToCompileVariableName (toCompress );
221219 dvisitor .setToCompileVariableName (toCompress );
222- if (toCompress ) {
223- updateJ2SMap (prjFolder );
224- }
220+ // if (toCompress) {
221+ // updateJ2SMap(prjFolder);
222+ // }
225223 errorOccurred = false ;
226224 try {
227225 root .accept (visitor );
@@ -248,61 +246,61 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
248246 }
249247 }
250248
251- public static void updateJ2SMap (String prjFolder ) {
252- File j2sMap = new File (prjFolder , ".j2smap" );
253- if (j2sMap .exists ()) {
254- String mapStr = FileUtil .readSource (j2sMap );
255- if (mapStr != null ) {
256- String lastClassName = null ;
257- Map <String , NameConvertItem > varList = new HashMap <String , NameConvertItem >();
258- String [] lines = mapStr .split ("\r \n |\r |\n " );
259- for (int j = 0 ; j < lines .length ; j ++) {
260- String line = lines [j ].trim ();
261- if (line .length () > 0 ) {
262- if (!line .startsWith ("#" )) {
263- int index = line .indexOf ("=" );
264- if (index != -1 ) {
265- String key = line .substring (0 , index ).trim ();
266- String toVarName = line .substring (index + 1 ).trim ();
267- boolean isMethod = true ;
268- int idx = key .lastIndexOf ('#' );
269- if (idx == -1 ) {
270- isMethod = false ;
271- idx = key .lastIndexOf ('.' );
272- if (idx == -1 ) {
273- continue ;
274- }
275- }
276- String className = key .substring (0 , idx );
277- if (className .startsWith ("$" )) {
278- if (lastClassName != null ) {
279- className = className .replaceAll ("\\ $" , lastClassName );
280- // System.out.println(className + "..." + lastClassName);
281- } else {
282- className = className .replaceAll ("\\ $" , "" );
283- lastClassName = className ;
284- }
285- } else {
286- lastClassName = className ;
287- }
288- String varName = key .substring (idx + 1 );
289- // System.out.println(className + "." + varName + "->" + toVarName);
290- if (isMethod ) {
291- key = className + "#" + varName ;
292- } else {
293- key = className + "." + varName ;
294- }
295- varList .put (key , new NameConvertItem (className , varName , toVarName , isMethod ));
296- }
297- }
298- }
299- }
300- ASTJ2SMapVisitor .setJ2SMap (varList );
301- return ;
302- }
303- }
304- ASTJ2SMapVisitor .setJ2SMap (null );
305- }
249+ // public static void updateJ2SMap(String prjFolder) {
250+ // File j2sMap = new File(prjFolder, ".j2smap");
251+ // if (j2sMap.exists()) {
252+ // String mapStr = FileUtil.readSource(j2sMap);
253+ // if (mapStr != null) {
254+ // String lastClassName = null;
255+ // Map<String, NameConvertItem> varList = new HashMap<String, NameConvertItem>();
256+ // String[] lines = mapStr.split("\r\n|\r|\n");
257+ // for (int j = 0; j < lines.length; j++) {
258+ // String line = lines[j].trim();
259+ // if (line.length() > 0) {
260+ // if (!line.startsWith("#")) {
261+ // int index = line.indexOf("=");
262+ // if (index != -1) {
263+ // String key = line.substring(0, index).trim();
264+ // String toVarName = line.substring(index + 1).trim();
265+ // boolean isMethod = true;
266+ // int idx = key.lastIndexOf('#');
267+ // if (idx == -1) {
268+ // isMethod = false;
269+ // idx = key.lastIndexOf('.');
270+ // if (idx == -1) {
271+ // continue;
272+ // }
273+ // }
274+ // String className = key.substring(0, idx);
275+ // if (className.startsWith("$")) {
276+ // if (lastClassName != null) {
277+ // className = className.replaceAll("\\$", lastClassName);
278+ //// System.out.println(className + "..." + lastClassName);
279+ // } else {
280+ // className = className.replaceAll("\\$", "");
281+ // lastClassName = className;
282+ // }
283+ // } else {
284+ // lastClassName = className;
285+ // }
286+ // String varName = key.substring(idx + 1);
287+ //// System.out.println(className + "." + varName + "->" + toVarName);
288+ // if (isMethod) {
289+ // key = className + "#" + varName;
290+ // } else {
291+ // key = className + "." + varName;
292+ // }
293+ // varList.put(key, new NameConvertItem(className, varName, toVarName, isMethod));
294+ // }
295+ // }
296+ // }
297+ // }
298+ // ASTJ2SMapVisitor.setJ2SMap(varList);
299+ // return ;
300+ // }
301+ // }
302+ // ASTJ2SMapVisitor.setJ2SMap(null);
303+ // }
306304
307305 public static void outputJavaScript (ASTScriptVisitor visitor , DependencyASTVisitor dvisitor , CompilationUnit fRoot ,
308306 String folderPath , Properties props ) {
0 commit comments