Changeset 43


Ignore:
Timestamp:
12/07/11 00:34:32 (12 years ago)
Author:
phdmakk
Message:

+ added functionality for the specification of resources to be ignored during processing

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.etsi.common/src/org/etsi/common/MiscTools.java

    r29 r43  
    1111import java.io.Writer; 
    1212import java.text.DecimalFormat; 
     13import java.util.regex.Matcher; 
     14import java.util.regex.Pattern; 
    1315 
    1416import org.etsi.common.exceptions.TerminationException; 
     
    170172        } 
    171173 
    172  
     174        //TODO: cloned from NamingConventionsChecker => needs to be unified and reused 
     175        public static boolean regExpMatch(String regExp, String subject) { 
     176                boolean matches = false; 
     177                Pattern pattern = Pattern.compile(regExp); 
     178                Matcher matcher = pattern.matcher(subject); 
     179//              System.out.println(regExp + " : " + subject); 
     180                if (matcher.matches()) { 
     181                        matches = true; 
     182                } 
     183                return matches; 
     184        } 
    173185} 
  • trunk/org.etsi.common/src/org/etsi/common/configuration/ConfigurationProfile.java

    r7 r43  
    88        protected String profileVersion; 
    99        protected String resourceExtensionsRegExp = "ttcn|ttcn3|3mp"; 
     10        protected String ignoredResourceRegExp = ".*IGNORED.*"; 
    1011        protected String projectExtension = "t3p"; 
    1112        protected boolean settingRecursiveProcessing = true; 
     
    9192        } 
    9293 
     94        public void setIgnoredResourceRegExt(String ignoredResourceRegExp) { 
     95                this.ignoredResourceRegExp = ignoredResourceRegExp; 
     96        } 
     97 
     98        public String getIgnoredResourceRegExp() { 
     99                return ignoredResourceRegExp; 
     100        } 
     101 
    93102} 
  • trunk/t3d/src/org/etsi/t3d/T3D.java

    r32 r43  
    257257                        //TODO: core functionality, encapsulate, split, and extract 
    258258                        for (int i = 0; i < ttcn3Resources.size(); i++) { 
    259                                 analyzer = analyzerFactory.getTTCN3Analyzer(ttcn3Resources 
    260                                                 .get(i)); 
    261                                 System.out.println("Preparing documentation for " 
    262                                                 + analyzer.getFilename()); 
    263 //TODO: review logging interface 
    264                                 //loggingInterface.setCurrentTTCN3File(analyzer.getFilename()); 
    265                                 T3D.getLoggingInterface().setLogSourceName(analyzer.getFilename()); 
    266                                 if (isGenerateMainXML() || isGenerateHTML()) { 
    267                                         T3DVisitor visitor = new T3DVisitor(xmlPrinter); 
    268                                         visitor.setFilename(analyzer.getFilename()); 
    269                                         ImportVisitor importVisitor = new ImportVisitor(importPrinter); 
    270                                         importVisitor.setFilename(analyzer.getFilename()); 
    271 //                                      xmlPrinter.setCurrentTTCN3File(analyzer.getFilename()); 
    272                                         // visitor.setFilename(analyzer.getFilename()); 
    273                                         visitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 
    274                                         importVisitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 
    275                                 } 
    276                                 if (isGenerateDependenciesXML()) { 
    277                                         DependencyVisitor dependencyVisitor = new DependencyVisitor(depPrinter); 
    278                                         depPrinter.setCurrentTTCN3File(analyzer.getFilename()); 
    279                                         dependencyVisitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 
     259                                if (MiscTools.regExpMatch(activeProfile.getIgnoredResourceRegExp() , ttcn3Resources.get(i))){ 
     260                                        System.out.println("Preparing documentation for " + ttcn3Resources.get(i) + " (Skipped) "); //TODO: may need to use analyzer.getFilename for consistency 
     261                                } else { 
     262                                        analyzer = analyzerFactory.getTTCN3Analyzer(ttcn3Resources 
     263                                                        .get(i)); 
     264                                        System.out.println("Preparing documentation for " 
     265                                                        + analyzer.getFilename()); 
     266        //TODO: review logging interface 
     267                                        //loggingInterface.setCurrentTTCN3File(analyzer.getFilename()); 
     268                                        T3D.getLoggingInterface().setLogSourceName(analyzer.getFilename()); 
     269                                        if (isGenerateMainXML() || isGenerateHTML()) { 
     270                                                T3DVisitor visitor = new T3DVisitor(xmlPrinter); 
     271                                                visitor.setFilename(analyzer.getFilename()); 
     272                                                ImportVisitor importVisitor = new ImportVisitor(importPrinter); 
     273                                                importVisitor.setFilename(analyzer.getFilename()); 
     274        //                                      xmlPrinter.setCurrentTTCN3File(analyzer.getFilename()); 
     275                                                // visitor.setFilename(analyzer.getFilename()); 
     276                                                visitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 
     277                                                importVisitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 
     278                                        } 
     279                                        if (isGenerateDependenciesXML()) { 
     280                                                DependencyVisitor dependencyVisitor = new DependencyVisitor(depPrinter); 
     281                                                depPrinter.setCurrentTTCN3File(analyzer.getFilename()); 
     282                                                dependencyVisitor.acceptDFS((LocationAST) analyzer.getParser().getAST()); 
     283                                        } 
    280284                                } 
    281285 
  • trunk/t3q/src/org/etsi/t3q/T3Q.java

    r30 r43  
    5858         
    5959        private boolean formattingEnabled = false; 
    60          
    61  
    6260        //TODO: statistics shall be ideally based on XSLT, meaning the output shall be transformed into XML  
    6361        //TODO: also add exception checking for the profiles  
     
    230228                        //TODO: core functionality, encapsulate and extract 
    231229                        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                                } 
    238240                        } 
    239241                        endTime = System.currentTimeMillis(); 
     
    295297 
    296298                        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(); 
    326369                                        } 
    327  
    328                                         if (destinationSubPath.substring(0,3).endsWith(":\\")){ 
    329                                                 destinationSubPath=destinationSubPath.substring(2); 
    330                                         } 
    331                                          
    332                                         String outputPathArg = new File(getDestinationPath()).getPath(); // also 
    333                                                                                                                                                 // strips 
    334                                                                                                                                                 // the 
    335                                                                                                                                                 // slash 
    336                                                                                                                                                 // if 
    337                                                                                                                                                 // present 
    338                                         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(); 
    363370                                } 
    364371 
     
    369376                        System.out.println("Code formatting finished in " + elapsed 
    370377                                        + "ms (" + MiscTools.doubleToString(elapsedMinutes) + " minutes)."); 
    371  
    372378                } 
    373379                return analyzer; 
Note: See TracChangeset for help on using the changeset viewer.