예제 #1
0
 /** Cancels reloading this resource. The running parser and post processors are terminated. */
 protected void cancelReload() {
   // Cancel parser
   genericity.language.gbind.IGbindTextParser parserCopy = parser;
   if (parserCopy != null) {
     parserCopy.terminate();
   }
   // Cancel post processor(s)
   genericity.language.gbind.IGbindResourcePostProcessor runningPostProcessorCopy =
       runningPostProcessor;
   if (runningPostProcessorCopy != null) {
     runningPostProcessorCopy.terminate();
   }
   // Cancel reference resolving
   genericity.language.gbind.util.GbindInterruptibleEcoreResolver interruptibleResolverCopy =
       interruptibleResolver;
   if (interruptibleResolverCopy != null) {
     interruptibleResolverCopy.terminate();
   }
 }
예제 #2
0
  protected void doLoad(java.io.InputStream inputStream, java.util.Map<?, ?> options)
      throws java.io.IOException {
    synchronized (loadingLock) {
      if (processTerminationRequested()) {
        return;
      }
      this.loadOptions = options;
      delayNotifications = true;
      resetLocationMap();
      String encoding = getEncoding(options);
      java.io.InputStream actualInputStream = inputStream;
      Object inputStreamPreProcessorProvider = null;
      if (options != null) {
        inputStreamPreProcessorProvider =
            options.get(genericity.language.gbind.IGbindOptions.INPUT_STREAM_PREPROCESSOR_PROVIDER);
      }
      if (inputStreamPreProcessorProvider != null) {
        if (inputStreamPreProcessorProvider
            instanceof genericity.language.gbind.IGbindInputStreamProcessorProvider) {
          genericity.language.gbind.IGbindInputStreamProcessorProvider provider =
              (genericity.language.gbind.IGbindInputStreamProcessorProvider)
                  inputStreamPreProcessorProvider;
          genericity.language.gbind.mopp.GbindInputStreamProcessor processor =
              provider.getInputStreamProcessor(inputStream);
          actualInputStream = processor;
        }
      }

      parser = getMetaInformation().createParser(actualInputStream, encoding);
      parser.setOptions(options);
      genericity.language.gbind.IGbindReferenceResolverSwitch referenceResolverSwitch =
          getReferenceResolverSwitch();
      referenceResolverSwitch.setOptions(options);
      genericity.language.gbind.IGbindParseResult result = parser.parse();
      // dispose parser, we don't need it anymore
      parser = null;

      if (processTerminationRequested()) {
        // do nothing if reload was already restarted
        return;
      }

      clearState();
      getContentsInternal().clear();
      org.eclipse.emf.ecore.EObject root = null;
      if (result != null) {
        root = result.getRoot();
        if (root != null) {
          if (isLayoutInformationRecordingEnabled()) {
            layoutUtil.transferAllLayoutInformationToModel(root);
          }
          if (processTerminationRequested()) {
            // the next reload will add new content
            return;
          }
          getContentsInternal().add(root);
        }
        java.util.Collection<
                genericity.language.gbind.IGbindCommand<
                    genericity.language.gbind.IGbindTextResource>>
            commands = result.getPostParseCommands();
        if (commands != null) {
          for (genericity.language.gbind.IGbindCommand<genericity.language.gbind.IGbindTextResource>
              command : commands) {
            command.execute(this);
          }
        }
      }
      getReferenceResolverSwitch().setOptions(options);
      if (getErrors().isEmpty()) {
        if (!runPostProcessors(options)) {
          return;
        }
        if (root != null) {
          runValidators(root);
        }
      }
      notifyDelayed();
    }
  }