Changeset 51


Ignore:
Timestamp:
02/21/12 11:07:59 (12 years ago)
Author:
phdmakk
Message:
  • switched to upstream AbstractVisitor? and exceptions
  • changed version number
  • improved and unified error messages

+ added memory statistics in debug mode

Location:
trunk/t3q/src/org/etsi/t3q
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/t3q/src/org/etsi/t3q/T3Q.java

    r43 r51  
    1717import org.etsi.t3q.config.T3QConfig; 
    1818import org.etsi.t3q.config.T3QOptionsHandler; 
    19 import org.etsi.t3q.exceptions.TTCN3BehaviorException; 
    20 import org.etsi.t3q.exceptions.TTCN3ParserException; 
    2119import org.etsi.t3q.visitor.T3QVisitor; 
    2220import org.etsi.common.InputInterface; 
     
    3533import de.ugoe.cs.swe.trex.core.analyzer.rfparser.TTCN3Parser; 
    3634import de.ugoe.cs.swe.trex.core.formatter.TTCN3Formatter; 
     35import de.ugoe.cs.swe.trex.core.visitor.TTCN3BehaviorException; 
     36import de.ugoe.cs.swe.trex.core.visitor.TTCN3ParserException; 
    3737 
    3838public class T3Q { 
    3939 
    40         private static String versionNumber = "v1.0.2"; 
     40        private static String versionNumber = "v1.0.3"; 
    4141        //set during automated server builds 
    4242        private static String buildStamp = "---BUILD_STAMP---"; 
     
    169169                                                String className = analyzer.getExceptions().get(i1).getStackTrace()[0].getClassName(); 
    170170                                                String methodName = analyzer.getExceptions().get(i1).getStackTrace()[0].getMethodName(); 
    171                                                 exceptionMessage+="\n  "+className.substring(className.lastIndexOf(".")+1)+" : "+methodName; 
     171                                                //moved from below, migrate to t3d as well 
     172                                                String lineMessage = "Line " 
     173                                                                + analyzer.getExceptions().get(i1).getLine() 
     174                                                                + ": " 
     175                                                                + analyzer.getExceptions().get(i1).getMessage(); 
     176; 
     177//                                              if (className.substring(className.lastIndexOf(".")+1).equals("TTCN3Parser")){ 
     178                                                        exceptionMessage+="\n  "+className.substring(className.lastIndexOf(".")+1)+" : "+methodName +"\n    "+lineMessage; 
     179//                                              } 
    172180                                        } 
    173181                                        //TODO: adapt to T3D as well 
     
    186194                                                } catch (TTCN3ParserException e) { 
    187195                                                        System.err.println(e.getLocalizedMessage()); 
    188                                                         for (int i1 = 0; i1 < analyzer.getExceptions() 
    189                                                                         .size(); i1++) { 
    190                                                                 System.err.println("Line " 
    191                                                                                 + analyzer.getExceptions().get(i1) 
    192                                                                                                 .getLine() 
    193                                                                                 + ": " 
    194                                                                                 + analyzer.getExceptions().get(i1) 
    195                                                                                                 .getMessage()); 
    196                                                         } 
    197196                                                        // e.printStackTrace(); 
    198197                                                } 
     
    267266                        // parsing error 
    268267                        System.err.println(e.getLocalizedMessage()); 
    269                         for (int i = 0; i < analyzer.getExceptions().size(); i++) { 
    270                                 System.err.println("Line " 
    271                                                 + analyzer.getExceptions().get(i).getLine() + ": " 
    272                                                 + analyzer.getExceptions().get(i).getMessage()); 
    273                         } 
    274268                        // TODO: Isolate different steps and implement a recovery mechanism: 
    275269 
    276270                } 
    277  
     271                //TODO: move to common, use in T3D as well 
     272                if (getLogLevel().equals(LogLevel.DEBUG)) { 
     273                        int mb = 1024*1024; 
     274                        Runtime.getRuntime().maxMemory(); 
     275                        Runtime runtime = Runtime.getRuntime(); 
     276                        System.out.println(); 
     277                        System.out.println("============Memory statistics:==========="); 
     278                        // Print used memory 
     279                        System.out.println("Used Memory:\t" 
     280                                        + (runtime.totalMemory() - runtime.freeMemory()) / mb+" MB"); 
     281                        // Print free memory 
     282                        System.out.println("Free Memory:\t" + runtime.freeMemory() / mb+" MB"); 
     283                        // Print total available memory 
     284                        System.out.println("Total Memory:\t" + runtime.totalMemory() / mb+" MB"); 
     285                        // Print maximum available memory 
     286                        System.out.println("Max Memory:\t" + runtime.maxMemory() / mb+" MB"); 
     287                } 
    278288        } 
    279289 
     
    305315                                        System.out.println("  Formatting file: " 
    306316                                                        + analyzer.getFilename()); 
     317                                         
    307318                                        try { 
    308319         
     
    310321         
    311322                                                String source = MiscTools.readFile(resourcePath); 
    312          
     323                                                 
    313324                                                String formatted = formatter.formatTTCN3Source(source, 
    314325                                                                T3Q.activeProfile.getFormattingParameters()); 
     
    359370         
    360371                                        } catch (RecognitionException e1) { 
    361                                                 System.err.println("Recognition exception:"); 
    362                                                 System.err.println(e1.getLocalizedMessage()); 
     372                                                 
     373                                                String exceptionMessage = "Error while formatting file (recognition) " 
     374                                                        + analyzer.getFilename();  
     375                                                String className = e1.getStackTrace()[0].getClassName(); 
     376                                                String methodName = e1.getStackTrace()[0].getMethodName(); 
     377                                                String lineMessage = "Line " 
     378                                                                + e1.getLine() 
     379                                                                + ": " 
     380                                                                + e1.getMessage(); 
     381                                                 
     382                                                exceptionMessage+="\n  "+className.substring(className.lastIndexOf(".")+1)+" : "+methodName +"\n    "+lineMessage; 
     383                                                //TODO: adapt to T3D as well? 
     384 
     385                                                System.err.println(exceptionMessage); 
     386                                                 
     387                                                 
    363388                                        } catch (TokenStreamException e) { 
    364389                                                System.err.println("Token stream exception:"); 
    365390                                                e.printStackTrace(); 
    366391                                        } catch (Exception e) { 
    367                                                 System.err.println("Exception:"); 
     392                                                System.err.println("Exception while processing "+ttcn3Resources.get(i)+" :"); 
    368393                                                e.printStackTrace(); 
    369394                                        } 
  • trunk/t3q/src/org/etsi/t3q/T3QMT.java

    r7 r51  
    1111 
    1212import org.etsi.t3q.config.T3QConfig; 
    13 import org.etsi.t3q.exceptions.TTCN3BehaviorException; 
    14 import org.etsi.t3q.exceptions.TTCN3ParserException; 
    1513import org.etsi.t3q.visitor.T3QVisitor; 
    1614import org.etsi.common.MiscTools; 
     
    2927import de.ugoe.cs.swe.trex.core.formatter.TTCN3Formatter; 
    3028import de.ugoe.cs.swe.trex.core.formatter.TTCN3FormatterParameters; 
     29import de.ugoe.cs.swe.trex.core.visitor.TTCN3BehaviorException; 
     30import de.ugoe.cs.swe.trex.core.visitor.TTCN3ParserException; 
    3131 
    3232public class T3QMT { 
  • trunk/t3q/src/org/etsi/t3q/visitor/QualityChecker.java

    r47 r51  
    19001900                do { 
    19011901                        if (logItem.getFirstChild().getType()!=TTCN3ParserTokenTypes.TemplateInstance){ 
     1902                                //get actual log item text 
    19021903                                logStatementText += logItem.getFirstChild().getText(); 
    19031904                        } else { 
    1904                                 //TODO: attempt to perform resolution 
     1905                                //substitute other elements with empty string 
    19051906                                logStatementText += ""; 
    19061907                                //TODO: consider fixing the parser, this is an ugly workaround 
  • trunk/t3q/src/org/etsi/t3q/visitor/T3QVisitor.java

    r7 r51  
    44 
    55import org.etsi.t3q.T3Q; 
    6 import org.etsi.t3q.exceptions.TTCN3BehaviorException; 
    76 
    87import de.ugoe.cs.swe.trex.core.analyzer.rfparser.LocationAST; 
    9  
     8import de.ugoe.cs.swe.trex.core.visitor.AbstractVisitor; 
     9import de.ugoe.cs.swe.trex.core.visitor.TTCN3BehaviorException; 
     10 
     11//TODO: substitute with upstream abstract visitor 
    1012public class T3QVisitor extends AbstractVisitor { 
    1113 
Note: See TracChangeset for help on using the changeset viewer.