Changeset 43 for trunk/t3q/src/org/etsi
- Timestamp:
- 12/07/11 00:34:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/t3q/src/org/etsi/t3q/T3Q.java
r30 r43 58 58 59 59 private boolean formattingEnabled = false; 60 61 62 60 //TODO: statistics shall be ideally based on XSLT, meaning the output shall be transformed into XML 63 61 //TODO: also add exception checking for the profiles … … 230 228 //TODO: core functionality, encapsulate and extract 231 229 for (int i = 0; i < ttcn3Resources.size(); i++) { 232 analyzer = analyzerFactory.getTTCN3Analyzer(ttcn3Resources 233 .get(i)); 234 System.out.println("Analyzing: " + analyzer.getFilename()); 235 T3QVisitor visitor = new T3QVisitor(); 236 visitor.setFilename(analyzer.getFilename()); 237 visitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 230 if (MiscTools.regExpMatch(activeProfile.getIgnoredResourceRegExp() , ttcn3Resources.get(i))){ 231 System.out.println("Analyzing: " + ttcn3Resources.get(i) + " (Skipped) "); //TODO: may need to use analyzer.getFilename for consistency 232 } else { 233 analyzer = analyzerFactory.getTTCN3Analyzer(ttcn3Resources 234 .get(i)); 235 System.out.println("Analyzing: " + analyzer.getFilename()); 236 T3QVisitor visitor = new T3QVisitor(); 237 visitor.setFilename(analyzer.getFilename()); 238 visitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 239 } 238 240 } 239 241 endTime = System.currentTimeMillis(); … … 295 297 296 298 for (int i = 0; i < ttcn3Resources.size(); i++) { 297 analyzer = analyzerFactory.getTTCN3Analyzer(ttcn3Resources 298 .get(i)); 299 System.out.println(" Formatting file: " 300 + analyzer.getFilename()); 301 try { 302 303 String resourcePath = ttcn3Resources.get(i); 304 305 String source = MiscTools.readFile(resourcePath); 306 307 String formatted = formatter.formatTTCN3Source(source, 308 T3Q.activeProfile.getFormattingParameters()); 309 310 // calculate the target path for the current resource 311 312 // TODO: look into it and fix it -> is it not fixed now? 313 // reason is: absolute paths are difficult to handle 314 // String subPath = resourcePath; 315 // String subPath = "/" + new File(resourcePath).getName(); 316 317 String canonicalResourcePath = new File(resourcePath).getCanonicalPath(); 318 String canonicalWorkingPath = new File(".").getCanonicalPath(); 319 320 String destinationSubPath = canonicalResourcePath; 321 322 //TODO: make this subtraction optional and document the feature 323 //CF: Manuel's remark and my answer - it introduces a dependency on the working path which may not be easily understood and has at least be documented properly 324 if (canonicalResourcePath.startsWith(canonicalWorkingPath)){ 325 destinationSubPath = canonicalResourcePath.substring(canonicalWorkingPath.length()); 299 if (MiscTools.regExpMatch(activeProfile.getIgnoredResourceRegExp() , ttcn3Resources.get(i))){ 300 System.out.println(" Formatting file: " 301 + ttcn3Resources.get(i) + " (Skipped) "); 302 } else { 303 analyzer = analyzerFactory.getTTCN3Analyzer(ttcn3Resources 304 .get(i)); 305 System.out.println(" Formatting file: " 306 + analyzer.getFilename()); 307 try { 308 309 String resourcePath = ttcn3Resources.get(i); 310 311 String source = MiscTools.readFile(resourcePath); 312 313 String formatted = formatter.formatTTCN3Source(source, 314 T3Q.activeProfile.getFormattingParameters()); 315 316 // calculate the target path for the current resource 317 318 // TODO: look into it and fix it -> is it not fixed now? 319 // reason is: absolute paths are difficult to handle 320 // String subPath = resourcePath; 321 // String subPath = "/" + new File(resourcePath).getName(); 322 323 String canonicalResourcePath = new File(resourcePath).getCanonicalPath(); 324 String canonicalWorkingPath = new File(".").getCanonicalPath(); 325 326 String destinationSubPath = canonicalResourcePath; 327 328 //TODO: make this subtraction optional and document the feature 329 //CF: Manuel's remark and my answer - it introduces a dependency on the working path which may not be easily understood and has at least be documented properly 330 if (canonicalResourcePath.startsWith(canonicalWorkingPath)){ 331 destinationSubPath = canonicalResourcePath.substring(canonicalWorkingPath.length()); 332 } 333 334 if (destinationSubPath.substring(0,3).endsWith(":\\")){ 335 destinationSubPath=destinationSubPath.substring(2); 336 } 337 338 String outputPathArg = new File(getDestinationPath()).getPath(); // also 339 // strips 340 // the 341 // slash 342 // if 343 // present 344 String outputPath = outputPathArg + destinationSubPath; 345 346 347 348 // System.out.println("****************************"); 349 // System.out.println("ABSOLUTE: \t\t"+canonicalResourcePath); 350 // System.out.println("WORKING: \t\t"+canonicalWorkingPath); 351 // System.out.println("ResourcePath: \t\t"+resourcePath); 352 // System.out.println("SubPath: \t\t"+destinationSubPath); 353 // System.out.println("OutputPath: \t\t"+outputPath); 354 // System.out.println("****************************"); 355 // System.out.println(formatted); 356 // System.out.println(outputPath); 357 MiscTools.writeFile(outputPath, formatted); 358 System.out.println("File \""+outputPath+"\" written successfully!"); 359 360 } catch (RecognitionException e1) { 361 System.err.println("Recognition exception:"); 362 System.err.println(e1.getLocalizedMessage()); 363 } catch (TokenStreamException e) { 364 System.err.println("Token stream exception:"); 365 e.printStackTrace(); 366 } catch (Exception e) { 367 System.err.println("Exception:"); 368 e.printStackTrace(); 326 369 } 327 328 if (destinationSubPath.substring(0,3).endsWith(":\\")){329 destinationSubPath=destinationSubPath.substring(2);330 }331 332 String outputPathArg = new File(getDestinationPath()).getPath(); // also333 // strips334 // the335 // slash336 // if337 // present338 String outputPath = outputPathArg + destinationSubPath;339 340 341 342 // System.out.println("****************************");343 // System.out.println("ABSOLUTE: \t\t"+canonicalResourcePath);344 // System.out.println("WORKING: \t\t"+canonicalWorkingPath);345 // System.out.println("ResourcePath: \t\t"+resourcePath);346 // System.out.println("SubPath: \t\t"+destinationSubPath);347 // System.out.println("OutputPath: \t\t"+outputPath);348 // System.out.println("****************************");349 // System.out.println(formatted);350 // System.out.println(outputPath);351 MiscTools.writeFile(outputPath, formatted);352 System.out.println("File \""+outputPath+"\" written successfully!");353 354 } catch (RecognitionException e1) {355 System.err.println("Recognition exception:");356 System.err.println(e1.getLocalizedMessage());357 } catch (TokenStreamException e) {358 System.err.println("Token stream exception:");359 e.printStackTrace();360 } catch (Exception e) {361 System.err.println("Exception:");362 e.printStackTrace();363 370 } 364 371 … … 369 376 System.out.println("Code formatting finished in " + elapsed 370 377 + "ms (" + MiscTools.doubleToString(elapsedMinutes) + " minutes)."); 371 372 378 } 373 379 return analyzer;
Note: See TracChangeset
for help on using the changeset viewer.