Changeset 1229

Show
Ignore:
Timestamp:
07/14/08 01:05:01 (2 months ago)
Author:
fraserofthenight
Message:

Builder stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.building/src/descent/building/BuilderLaunchDelegate.java

    r1197 r1229  
    3535            throw error(String.format(DebuildMessages.BuilderLaunchDelegate_error_could_not_instantiate_builder, builderType.getIdentifier())); 
    3636         
    37         builder.build(config, pm); 
     37        builder.build(config, launch, pm); 
    3838    } 
    3939     
  • trunk/descent.building/src/descent/building/IDBuilder.java

    r1174 r1229  
    11package descent.building; 
    22 
    3 import org.eclipse.core.runtime.CoreException; 
    43import org.eclipse.core.runtime.IProgressMonitor; 
     4import org.eclipse.debug.core.ILaunch; 
    55import org.eclipse.debug.core.ILaunchConfiguration; 
    66 
     
    2424public interface IDBuilder 
    2525{ 
    26     public String build(ILaunchConfiguration config, IProgressMonitor pm) throws CoreException; 
     26    public String build(ILaunchConfiguration config, ILaunch launch, 
     27            IProgressMonitor pm); 
    2728} 
  • trunk/descent.building/src/descent/internal/building/BuilderUtil.java

    r1216 r1229  
    1111import org.eclipse.core.runtime.CoreException; 
    1212import org.eclipse.core.runtime.IPath; 
     13import org.eclipse.core.runtime.IProgressMonitor; 
     14import org.eclipse.core.runtime.NullProgressMonitor; 
    1315import org.eclipse.debug.core.ILaunchConfiguration; 
    1416 
     
    2123 
    2224/** 
    23  * Static utility methods used throughout the builder 
     25 * Static utility methods used throughout the builder. THis class is not part of 
     26 * the debuild package, as it is designed to be used in the UI as well. 
    2427 *  
    2528 * @author Robert Fraser 
     
    2831public class BuilderUtil 
    2932{ 
     33    //-------------------------------------------------------------------------- 
     34    // OS-Specific functionality 
     35     
    3036    /** 
    3137     * True if the current OS is Windows-based, false otherwise 
     
    4147    static 
    4248    { 
     49        // This needs to be initialized here to prevent constant folding 
    4350        IS_WINDOWS = System.getProperty("os.name").startsWith("Windows"); //$NON-NLS-1$ //$NON-NLS-2$ 
    4451         
     
    6067        } 
    6168    } 
     69     
     70    //-------------------------------------------------------------------------- 
     71    // Version/debug identifier management 
    6272     
    6373    /** 
     
    100110     
    101111    /** 
    102      * Gets the absolute OS path for the given Eclipse path (with portable 
    103      * separarators, etc.). 
    104      *  
    105      * @param path 
     112     * Checks whether the given string is a valid D identifier. Valid D 
     113     * identifiers are the same as valid Java identifiers with the exception 
     114     * that Java allows '$'. 
     115     *  
     116     * @param id 
    106117     * @return 
    107118     */ 
    108     public static String getAbsolutePath(IPath path) 
    109     { 
    110         IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path); 
    111         if(null != res) 
    112             path = res.getLocation(); 
    113          
    114         return path.toString(); 
    115     } 
    116  
    117119    public static boolean isValidIdentifier(String id) 
    118120    { 
     
    129131    } 
    130132     
     133    private static boolean isValidIdStart(char c) 
     134    { 
     135        return Character.isJavaIdentifierStart(c) && !(c == '$'); 
     136    } 
     137     
     138    private static boolean isValidIdPart(char c) 
     139    { 
     140        return Character.isJavaIdentifierPart(c) && !(c == '$'); 
     141    } 
     142     
     143    //-------------------------------------------------------------------------- 
     144    // Compiler management 
     145     
    131146    private static final CompilerInterfaceRegistry registry =  
    132147        CompilerInterfaceRegistry.getInstance(); 
    133148     
    134149    /** 
    135      * Gets the compielr interface for the given compiler. 
     150     * Gets the compiler interface for the given compiler. 
    136151     *  
    137152     * @param compiler the compiler to get the interface for 
     
    158173    } 
    159174     
    160     private static boolean isValidIdStart(char c) 
    161     { 
    162         return Character.isJavaIdentifierStart(c) && !(c == '$'); 
    163     } 
    164      
    165     private static boolean isValidIdPart(char c) 
    166     { 
    167         return Character.isJavaIdentifierPart(c) && !(c == '$'); 
    168     } 
     175    /** 
     176     * Gets the VMInstall (compiler) associated with the given project 
     177     *  
     178     * @param project the project to get the compiler for 
     179     * @return        the compiler associated with the project or null if either 
     180     *                poject was null or no compielr is associated with project 
     181     */ 
     182    public static IVMInstall getVMInstall(IJavaProject project) 
     183        throws CoreException 
     184    { 
     185        if(null == project) 
     186            return null; 
     187        return JavaRuntime.getVMInstall(project); 
     188    } 
     189     
     190    //-------------------------------------------------------------------------- 
     191    // Wrappers for ILaunchConfiguration methods which hide the exceptions, 
     192    // since the exception will never be thrown 
     193     
     194    public static String getAttribute(ILaunchConfiguration config, String id, 
     195            String defaultValue) 
     196    { 
     197        String value = defaultValue; 
     198        try 
     199        { 
     200            value = config.getAttribute(id, defaultValue); 
     201        } 
     202        catch(CoreException e) { } 
     203        return value; 
     204    } 
     205     
     206    public static boolean getAttribute(ILaunchConfiguration config, String id, 
     207            boolean defaultValue) 
     208    { 
     209        boolean value = defaultValue; 
     210        try 
     211        { 
     212            value = config.getAttribute(id, defaultValue); 
     213        } 
     214        catch(CoreException e) { } 
     215        return value; 
     216    } 
     217     
     218    public static int getAttribute(ILaunchConfiguration config, String id, 
     219            int defaultValue) 
     220    { 
     221        int value = defaultValue; 
     222        try 
     223        { 
     224            value = config.getAttribute(id, defaultValue); 
     225        } 
     226        catch(CoreException e) { } 
     227        return value; 
     228    } 
     229     
     230    public static List getAttribute(ILaunchConfiguration config, String id, 
     231            List defaultValue) 
     232    { 
     233        List value = defaultValue; 
     234        try 
     235        { 
     236            value = config.getAttribute(id, defaultValue); 
     237        } 
     238        catch(CoreException e) { } 
     239        return value; 
     240    } 
     241     
     242    public static Map getAttribute(ILaunchConfiguration config, String id, 
     243            Map defaultValue) 
     244    { 
     245        Map value = defaultValue; 
     246        try 
     247        { 
     248            value = config.getAttribute(id, defaultValue); 
     249        } 
     250        catch(CoreException e) { } 
     251        return value; 
     252    } 
     253     
     254    public static Set getAttribute(ILaunchConfiguration config, String id, 
     255            Set defaultValue) 
     256    { 
     257        Set value = defaultValue; 
     258        try 
     259        { 
     260            value = config.getAttribute(id, defaultValue); 
     261        } 
     262        catch(CoreException e) { } 
     263        return value; 
     264    } 
     265     
     266    //-------------------------------------------------------------------------- 
     267    // Miscellaneous 
     268     
     269    /** 
     270     * A monitor for tasks that do not require  
     271     *  
     272     * Don't use this as the main null progress monitor, since its  
     273     * canceleld state is not garunteed. 
     274     */ 
     275    public static final IProgressMonitor NO_MONITOR = new NullProgressMonitor(); 
    169276     
    170277    /** 
     
    181288    public static final Object[] EMPTY_ARRAY = new Object[] {}; 
    182289     
    183     //-------------------------------------------------------------------------- 
    184     // Wrappers for ILaunchConfiguration methods which hide the exceptions, 
    185     // since the exception will never be thrown 
    186      
    187     public static String getAttribute(ILaunchConfiguration config, String id, 
    188             String defaultValue) 
    189     { 
    190         String value = defaultValue; 
    191         try 
    192         { 
    193             value = config.getAttribute(id, defaultValue); 
    194         } 
    195         catch(CoreException e) { } 
    196         return value; 
    197     } 
    198      
    199     public static boolean getAttribute(ILaunchConfiguration config, String id, 
    200             boolean defaultValue) 
    201     { 
    202         boolean value = defaultValue; 
    203         try 
    204         { 
    205             value = config.getAttribute(id, defaultValue); 
    206         } 
    207         catch(CoreException e) { } 
    208         return value; 
    209     } 
    210      
    211     public static int getAttribute(ILaunchConfiguration config, String id, 
    212             int defaultValue) 
    213     { 
    214         int value = defaultValue; 
    215         try 
    216         { 
    217             value = config.getAttribute(id, defaultValue); 
    218         } 
    219         catch(CoreException e) { } 
    220         return value; 
    221     } 
    222      
    223     public static List getAttribute(ILaunchConfiguration config, String id, 
    224             List defaultValue) 
    225     { 
    226         List value = defaultValue; 
    227         try 
    228         { 
    229             value = config.getAttribute(id, defaultValue); 
    230         } 
    231         catch(CoreException e) { } 
    232         return value; 
    233     } 
    234      
    235     public static Map getAttribute(ILaunchConfiguration config, String id, 
    236             Map defaultValue) 
    237     { 
    238         Map value = defaultValue; 
    239         try 
    240         { 
    241             value = config.getAttribute(id, defaultValue); 
    242         } 
    243         catch(CoreException e) { } 
    244         return value; 
    245     } 
    246      
    247     public static Set getAttribute(ILaunchConfiguration config, String id, 
    248             Set defaultValue) 
    249     { 
    250         Set value = defaultValue; 
    251         try 
    252         { 
    253             value = config.getAttribute(id, defaultValue); 
    254         } 
    255         catch(CoreException e) { } 
    256         return value; 
    257     } 
    258  
    259     public static IVMInstall getVMInstall(IJavaProject project) 
    260         throws CoreException 
    261     { 
    262         if(null == project) 
    263             return null; 
    264         return JavaRuntime.getVMInstall(project); 
    265     } 
    266      
    267     /** 
    268      * This method is needed since  
    269      * {@link ILaunchConfiguration#contentsEqual(ILaunchConfiguration)} compares 
    270      * the paths of launch configurations as well, and the getInfo method is not 
    271      * publicly available. 
    272      */ 
    273     public static boolean launchConfigsEqual(ILaunchConfiguration config, 
    274             ILaunchConfiguration other) throws CoreException 
    275     { 
    276         return config.getName().equals(other.getName()) && 
    277                 config.getType().equals(other.getType()) && 
    278                 config.getAttributes().equals(other.getAttributes()); 
     290    /** 
     291     * Gets the absolute OS path for the given Eclipse path (with portable 
     292     * separarators, etc.). 
     293     *  
     294     * @param path 
     295     * @return 
     296     */ 
     297    public static String getAbsolutePath(IPath path) 
     298    { 
     299        IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path); 
     300        if(null != res) 
     301            path = res.getLocation(); 
     302         
     303        return path.toString(); 
    279304    } 
    280305} 
  • trunk/descent.building/src/descent/internal/building/debuild/BuildRequest.java

    r1216 r1229  
    314314        "std.", 
    315315    }; 
     316     
    316317    private static final String[] tangoIgnored = new String[] 
    317318    { 
     
    319320        "gcc.", 
    320321    }; 
     322     
     323    public final String[] getIgnoredModules() 
     324    { 
     325        // TODO 
     326        return phobosIgnored; 
     327    } 
    321328} 
  • trunk/descent.building/src/descent/internal/building/debuild/DebuildBuilder.java

    r1216 r1229  
    77import java.util.Set; 
    88 
    9 import org.eclipse.core.resources.IFile; 
    10 import org.eclipse.core.resources.IFolder; 
    11 import org.eclipse.core.resources.IResource; 
    12 import org.eclipse.core.runtime.CoreException; 
    139import org.eclipse.core.runtime.IProgressMonitor; 
    1410import org.eclipse.core.runtime.NullProgressMonitor; 
    15 import org.eclipse.debug.core.DebugPlugin; 
     11import org.eclipse.core.runtime.SubProgressMonitor; 
     12import org.eclipse.debug.core.ILaunch; 
    1613import org.eclipse.debug.core.ILaunchConfiguration; 
    17 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 
    1814 
    1915import descent.core.IClasspathEntry; 
     
    2319import descent.internal.building.BuilderUtil; 
    2420import descent.building.IDBuilder; 
     21import descent.building.compiler.IObjectFile; 
    2522 
    2623public class DebuildBuilder implements IDBuilder 
     
    2825    /* package */ static final boolean DEBUG = true; 
    2926     
    30     /** 
    31      * Note: don't use this as the main null progress monitor, since its  
    32      * canceleld state is not garunteed. 
    33      */ 
    34     private static final IProgressMonitor NO_MONITOR = new NullProgressMonitor(); 
    35      
    3627    private BuildRequest req; 
    3728    private ErrorReporter err; 
    3829    private List<File> importPath; 
    3930     
    40     public String build(ILaunchConfiguration config, IProgressMonitor pm) 
    41             throws CoreException 
     31    public String build(ILaunchConfiguration config, ILaunch launch, 
     32            IProgressMonitor pm) 
    4233    {    
    4334        if(null == pm) 
     
    5748            // If the launch configuration has changed, clear the output folder 
    5849            // to do a full rebuild 
    59             managePrecomiledResources(); 
     50            IncrementalConsistencyManager consistencyMgr =  
     51                new IncrementalConsistencyManager(req); 
     52            consistencyMgr.checkConsistentState(); 
    6053            pm.worked(5); // 10 
    6154             
     
    6760                return null; 
    6861             
     62            // Collect dependancies and create the associated object files 
     63            ObjectFileFactory objFactory = new ObjectFileFactory(req); 
     64            RecursiveDependancyCollector collector =  
     65                new RecursiveDependancyCollector(req, objFactory); 
     66            IObjectFile[] objectFiles = collector.getModules( 
     67                    new SubProgressMonitor(pm, 35)); // 50 
     68             
    6969            // TODO 
    7070            return null; 
     
    7373        { 
    7474            err.projectError(e.getMessage()); 
    75             throw e; // TODO remove 
     75            if(DEBUG) 
     76                e.printStackTrace(); 
     77            return null; 
    7678        } 
    7779        catch(Exception e) 
     
    8890            pm.done(); 
    8991        } 
    90     } 
    91      
    92     /** 
    93      * If the launch configuration has changed, all pre-compiled resources need to 
    94      * be removed and a full rebuild done (PERHAPS a more selective mechanism -- if 
    95      * the user just changed the output file, for example, no rebuild is needed). 
    96      * This method detects if the current launch configuration is different than the 
    97      * existing launch configuration and if so deletes everything in the folder. 
    98      *  
    99      * @param config 
    100      */ 
    101     private void managePrecomiledResources() 
    102     { 
    103         // TODO this doesn't work (it adds a new launch). FInd out if there's a way 
    104         // not to, alternatively a new serialization mechanism needs to be created 
    105         // (or maybe just somehow store the age/revision of the last change). 
    106         try 
    107         { 
    108             // Check if the folder exists 
    109             IFolder folder = req.getOutputResource(); 
    110             if(!folder.exists()) 
    111             { 
    112                 folder.create(true, true, NO_MONITOR); 
    113                 createConfigFile(); 
    114                 return; 
    115             } 
    116  
    117             folder.refreshLocal(IResource.DEPTH_INFINITE, NO_MONITOR); 
    118             IResource launchConfigFile = folder.findMember(getLaunchConfigFilename()); 
    119             if(null == launchConfigFile || !(launchConfigFile instanceof IFile)) 
    120             { 
    121                 System.out.println("File doesn't exist!"); 
    122                 clearOutputFolder(); 
    123                 createConfigFile(); 
    124                 return; 
    125             } 
    126              
    127             ILaunchConfiguration launchConfig = DebugPlugin.getDefault(). 
    128                     getLaunchManager().getLaunchConfiguration((IFile) launchConfigFile); 
    129             if(!BuilderUtil.launchConfigsEqual(launchConfig, req.getLaunchConfig())) 
    130             { 
    131                 System.out.println("Not equal!"); 
    132                 clearOutputFolder(); 
    133                 createConfigFile(); 
    134                 return; 
    135             } 
    136              
    137             // If we get here, we can safely use any object files already 
    138             // generated for incremental compilation. 
    139             System.out.println("Contents saved!!!"); 
    140         } 
    141         catch(CoreException e) 
    142         { 
    143             throw new DebuildException(String.format( 
    144                     "Error preparing output folder: %1$s", e.getMessage())); 
    145         } 
    146          
    147     } 
    148      
    149     private String getLaunchConfigFilename() 
    150     { 
    151         return req.getLaunchConfig().getName().concat("."). 
    152                 concat(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION); 
    153     } 
    154  
    155     private void createConfigFile() throws CoreException 
    156     { 
    157         ILaunchConfiguration config = req.getLaunchConfig(); 
    158         ILaunchConfigurationWorkingCopy copy = config.copy(config.getName()); 
    159         copy.setContainer(req.getOutputResource()); 
    160         copy.doSave(); 
    161     } 
    162      
    163     private void clearOutputFolder() throws CoreException 
    164     { 
    165         System.out.println("Folder cleared!!!"); 
    166          
    167         IFolder outputFolder = req.getOutputResource(); 
    168         IResource[] members = outputFolder.members(); 
    169         for(IResource file : members) 
    170         { 
    171             try 
    172             { 
    173                 file.delete(true, NO_MONITOR); 
    174             } 
    175             catch(CoreException e) 
    176             { 
    177                 throw new DebuildException(String.format( 
    178                         "Error deleting resource %1$s: %2$s",  
    179                         file.getFullPath().toString(), e.getMessage())); 
    180             } 
    181         } 
    18292    } 
    18393 
  • trunk/descent.building/src/descent/internal/building/debuild/ObjectFileFactory.java

    r1216 r1229  
    44 
    55import descent.building.compiler.IObjectFile; 
     6import descent.core.ICompilationUnit; 
     7import descent.internal.building.BuilderUtil; 
    68 
    79/* package */ final class ObjectFileFactory 
     
    3638        } 
    3739    } 
     40     
     41    private static final int MAX_FILENAME_LENGTH = 240; 
     42     
     43    private final BuildRequest req; 
     44     
     45    public ObjectFileFactory(BuildRequest req) 
     46    { 
     47        this.req = req; 
     48    } 
     49     
     50    public IObjectFile create(ICompilationUnit cu, 
     51            boolean isLibraryFile) 
     52    { 
     53        File inputFile = new File(BuilderUtil.getAbsolutePath(cu.getResource(). 
     54                getLocation())); 
     55        File outputFile = new File(req.getOutputLocation().getAbsolutePath() + 
     56                File.separator + getOutputFilename(cu)); 
     57        return new ObjectFile(inputFile, outputFile, isLibraryFile); 
     58    } 
     59     
     60    private static String getOutputFilename(ICompilationUnit cu) 
     61    { 
     62        String name = cu.getFullyQualifiedName().replace('.', '-') + "." + 
     63            BuilderUtil.EXTENSION_OBJECT_FILE; 
     64        int len = name.length(); 
     65        if(len > MAX_FILENAME_LENGTH) 
     66            name = name.substring(len - MAX_FILENAME_LENGTH); 
     67        return name; 
     68    } 
    3869} 
  • trunk/descent.building/src/descent/internal/building/debuild/RecursiveDependancyCollector.java

    r1216 r1229  
    2626 * Class that can recurse through dependencies to generate a list of all files 
    2727 * that need to be compiled in a module. This class mainly exists to abstract 
    28  * the actual source analysis from the builder. The only method in this class 
    29  * that should be called externally is  
    30  * {@link #getObjectFiles(IJavaProject, ICompilationUnit[], IProgressMonitor)}, 
    31  * which will get the actual object files necessary using an instance of this 
    32  * class. 
     28 * the actual source analysis from the builder. 
    3329 *  
    3430 * @author Robert Fraser 
    3531 */ 
    3632/* package */ class RecursiveDependancyCollector 
    37 {    
    38     /** 
    39      * Gets new {@link IObjectFile}s for all the compilation units given and any 
    40      * dependencies they may have. 
    41      *  
    42      * @param modules  the initial compilation units to search from 
    43      * @param toIgnore a list of modules to ignore (not build). Entire packages 
    44      *                 can be ignored by ending the package name with a "." 
    45      * @param pm       the progress monitor 
    46      * @return         the object files (and dependancies) taht must be built 
    47      *                 for this project 
    48      */ 
    49     public static IObjectFile[] getObjectFiles( 
    50             BuildRequest req, 
    51             ObjectFileFactory factory, 
    52             String[] modules, 
    53             IProgressMonitor pm) 
    54     { 
    55         RecursiveDependancyCollector collector = new RecursiveDependancyCollector 
    56             (req, factory); 
    57         return collector.collect(modules, pm); 
    58     } 
    59      
     33{        
    6034    private final BuildRequest req; 
    6135    private final ObjectFileFactory factory; 
     36    private final ConditionalEvaluator eval; 
    6237     
    6338    private final Map<String, IObjectFile> objectFiles =  
     
    7146    private final Set<IJavaProject> visitedProjectAccumulator = new HashSet<IJavaProject>(); 
    7247     
    73     // Shouldn't be constructed directly, use the getObjectFiles method instead 
    74     private RecursiveDependancyCollector(BuildRequest req, ObjectFileFactory factory) 
     48    /** 
     49     * Creates a new dependancy collectr 
     50     */ 
     51    public RecursiveDependancyCollector(BuildRequest req, ObjectFileFactory factory) 
    7552    { 
    7653        this.factory = factory; 
    7754        this.req = req; 
    78     } 
    79      
    80     private IObjectFile[] collect(String[] modules, IProgressMonitor pm) 
     55        this.eval = new ConditionalEvaluator(req); 
     56    } 
     57     
     58    /** 
     59     * Gets new {@link IObjectFile}s for all the compilation units given and any 
     60     * dependencies they may have. 
     61     */ 
     62    public IObjectFile[] getModules(IProgressMonitor pm) 
    8163    { 
     64        ICompilationUnit[] modules = req.getModules(); 
    8265        try 
    8366        { 
    8467            pm.beginTask("Collecting dependencies", modules.length * 10); 
    8568             
    86             for(String moduleName : modules) 
     69            for(ICompilationUnit module : modules) 
    8770            { 
    88                 // Since this can take a long time, checking every so often for cancellation 
    89                 // is good! 
     71                collectRecursive(module.getFullyQualifiedName(), pm); 
     72                pm.worked(10); 
     73                 
    9074                if(pm.isCanceled()) 
    91                     return null; 
    92                  
    93                 collectRecursive(moduleName); 
    94                 pm.worked(10); 
     75                    return null; 
    9576            } 
    9677             
     
    11495    } 
    11596     
    116     private void collectRecursive(String moduleName
     97    private void collectRecursive(String moduleName, IProgressMonitor pm
    11798        throws JavaModelException 
    118     {    
     99    { 
     100        // Check for user cancellation 
     101        if(pm.isCanceled()) 
     102            return; 
     103         
    119104        // Check if we've already traversed this module 
    120105        if(objectFiles.containsKey(moduleName)) 
    121106            return; 
    122107         
    123         // Check if it's a nodule that should be ignored 
    124         /* TODO for(String ignore : req.getIgnoredModules()) 
     108        // Check if it's a module that should be ignored 
     109        for(String ignore : req.getIgnoredModules()) 
    125110            if(moduleName.startsWith(ignore)) 
    126                 return; */ 
     111                return; 
    127112         
    128113        // Find the module 
     
    138123        // Recurse through imports 
    139124        for(String importedModule : getImports(module)) 
    140             collectRecursive(importedModule); 
     125            collectRecursive(importedModule, pm); 
    141126    } 
    142127     
     
    144129            boolean isLibraryFile) 
    145130    { 
    146         // TODO 
    147         return null; 
     131        return factory.create(cu, isLibraryFile); 
    148132    } 
    149133     
     
    247231            { 
    248232                IConditional cond = (IConditional) element; 
    249                 findImportsInElements((isActive(cond) ? cond.getThenChildren() : 
     233                findImportsInElements((eval.isActive(cond) ? cond.getThenChildren() : 
    250234                    cond.getElseChildren()), imports); 
    251235                continue; 
     
    253237        } 
    254238    } 
    255      
    256     private boolean isActive(IConditional cond) 
    257     { 
    258         System.out.println("Conditional with displayString: " + cond.getElementName()); 
    259         // TODO check if it's active 
    260         return true; 
    261     } 
    262239}