Changeset 2144

Show
Ignore:
Timestamp:
06/30/08 21:00:34 (3 months ago)
Author:
sukyoungryu
Message:

[refactoring] Cleaning up the repositories.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ProjectFortress/src/com/sun/fortress/Shell.java

    r2132 r2144  
    192192    } 
    193193 
    194     private static boolean isApi(String file){ 
     194    public static boolean isApi(String file){ 
    195195        return file.endsWith(ProjectProperties.API_SOURCE_SUFFIX); 
    196196    } 
    197197 
    198     private static boolean isComponent(String file){ 
     198    public static boolean isComponent(String file){ 
    199199        return file.endsWith(ProjectProperties.COMP_SOURCE_SUFFIX); 
    200200    } 
    201201 
    202     private static APIName cuName( String file ){ 
     202    public static APIName cuName( String file ){ 
    203203        if ( file.endsWith( ProjectProperties.COMP_SOURCE_SUFFIX ) || 
    204204             file.endsWith( ProjectProperties.API_SOURCE_SUFFIX ) ){ 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/Fortress.java

    r2133 r2144  
    2727import com.sun.fortress.repository.GraphRepository; 
    2828import com.sun.fortress.repository.CacheBasedRepository; 
     29import com.sun.fortress.Shell; 
    2930import com.sun.fortress.compiler.environments.TopLevelEnvGen; 
    3031import com.sun.fortress.compiler.index.ApiIndex; 
     
    6970    } 
    7071 
    71     private static FortressRepository specificRepository(Path p) { 
     72    public static FortressRepository specificRepository(Path p) { 
    7273        // This is bogus; we need to find a better way to communicate with the 
    7374        // syntax transfomer. 
     
    8889     * they depend on, and add them to the fortress. 
    8990     */ 
    90     public Iterable<? extends StaticError> compile(Path path, String... files) { 
     91    public Iterable<? extends StaticError> compile(Path path, String file) { 
    9192        FortressRepository bcr = new GraphRepository( path, _repository ); 
    9293        CURRENT_INTERPRETER_REPOSITORY = bcr; 
    9394 
    94         Debug.debug( 2, "Compiling files " + java.util.Arrays.asList(files) ); 
    95         Parser.Result result = compileInner(bcr, files); 
     95        Debug.debug( 2, "Compiling file " + file ); 
     96        Parser.Result result = compileInner(bcr, file); 
    9697 
    9798        if (!result.isSuccessful()) { return result.errors(); } 
     
    104105    } 
    105106 
    106  private Parser.Result compileInner(FortressRepository bcr, 
    107    String... files) { 
    108   Parser.Result result = new Parser.Result(); 
    109  
    110   // bcr.addRootApis(); 
    111  
    112   for (String s : files) { 
    113    APIName name  = Driver.fileAsApi(s); 
    114  
    115    try { 
    116     if (name != null) { 
    117      result = addApiToResult(bcr, result, name); 
    118     } else { 
    119      name = Driver.fileAsComponent(s); 
    120  
    121      if (name != null) { 
    122       result = addComponentToResult(bcr, result, name); 
    123      } else { 
    124       result = addComponentToResult(bcr, result, NodeFactory.makeAPIName(s)); 
    125      } 
    126     } 
    127    } catch (ProgramError pe) { 
    128     Iterable<? extends StaticError> se = pe.getStaticErrors(); 
    129     if (se == null) { 
    130      result = new Parser.Result(result, new Parser.Result(new WrappedException(pe, ProjectProperties.debug))); 
    131     } 
    132     else { 
    133      result = new Parser.Result(result, new Parser.Result(se)); 
    134     } 
    135    } catch (RepositoryError ex) { 
    136     throw ex; 
    137                         } catch ( FileNotFoundException ex ){ 
    138                             throw new WrappedException(ex); 
    139                         } catch ( IOException e ){ 
    140                             throw new WrappedException(e); 
    141    } catch (StaticError ex) { 
    142                             result = addExceptionToResult(result, ex); 
    143    } 
    144   } 
     107    private Parser.Result compileInner(FortressRepository bcr, 
     108                                       String file) { 
     109        Parser.Result result = new Parser.Result(); 
     110 
     111        // bcr.addRootApis(); 
     112 
     113        APIName name  = Shell.cuName(file); 
     114 
     115        try { 
     116            if (Shell.isApi(file)) { 
     117                result = addApiToResult(bcr, result, name); 
     118            } else if (Shell.isComponent(file)) { 
     119                result = addComponentToResult(bcr, result, name); 
     120            } else { 
     121                result = addComponentToResult(bcr, result, NodeFactory.makeAPIName(file)); 
     122            } 
     123        } catch (ProgramError pe) { 
     124            Iterable<? extends StaticError> se = pe.getStaticErrors(); 
     125            if (se == null) { 
     126                result = new Parser.Result(result, new Parser.Result(new WrappedException(pe, ProjectProperties.debug))); 
     127            } 
     128            else { 
     129                result = new Parser.Result(result, new Parser.Result(se)); 
     130            } 
     131        } catch (RepositoryError ex) { 
     132            throw ex; 
     133        } catch ( FileNotFoundException ex ){ 
     134            throw new WrappedException(ex); 
     135        } catch ( IOException e ){ 
     136            throw new WrappedException(e); 
     137        } catch (StaticError ex) { 
     138            result = addExceptionToResult(result, ex); 
     139        } 
    145140 
    146141                /*