/**
  * Gets the module info for this compilation unit
  *
  * @param force if true, then a module info is created even if not a working copy. This occurs by
  *     temporarily turning the compilation unit into a working copy and then discarding it.
  * @return the {@link ModuleNodeInfo} for this compilation unit. Will be null if force is set to
  *     false and this unit is not a working copy. Also will be null if a problem occurs
  */
 public ModuleNodeInfo getModuleInfo(boolean force) {
   try {
     if (!isConsistent()) {
       makeConsistent(null);
     }
     boolean becameWorkingCopy = false;
     ModuleNodeMapper.getInstance().lock();
     // discard the working copy after finishing
     // if there was no working copy to begin with
     try {
       if (becameWorkingCopy = (force && !isWorkingCopy())) {
         becomeWorkingCopy(null);
       }
       PerWorkingCopyInfo info = getPerWorkingCopyInfo();
       if (info != null) {
         return ModuleNodeMapper.getInstance().get(info);
       }
     } finally {
       try {
         if (becameWorkingCopy) {
           discardWorkingCopy();
         }
       } finally {
         ModuleNodeMapper.getInstance().unlock();
       }
     }
   } catch (JavaModelException e) {
     Util.log(
         e,
         "Exception thrown when trying to get Groovy module node for "
             + this.getElementName()); // $NON-NLS-1$
   }
   // return null if not found. Means that there was a problem with build structure
   return null;
 }
 @Override
 public void discardWorkingCopy() throws JavaModelException {
   // GRECLIPSE-804 must synchronize
   ModuleNodeMapper.getInstance().lock();
   try {
     PerWorkingCopyInfo info = getPerWorkingCopyInfo();
     if (workingCopyInfoWillBeDiscarded(info)) {
       ModuleNodeMapper.getInstance().remove(info);
     }
     super.discardWorkingCopy();
   } finally {
     ModuleNodeMapper.getInstance().unlock();
   }
 }
 /**
  * @param perWorkingCopyInfo
  * @param compilationUnitDeclaration
  */
 protected void maybeCacheModuleNode(
     JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo,
     GroovyCompilationUnitDeclaration compilationUnitDeclaration) {
   ModuleNodeMapper.getInstance()
       .maybeCacheModuleNode(perWorkingCopyInfo, compilationUnitDeclaration);
 }