Package org.overturetool.vdmj.syntax

Examples of org.overturetool.vdmj.syntax.ClassReader


    int pwarn = 0;
    long duration = 0;

    for (File file : files)
    {
      ClassReader reader = null;

      try
      {
        if (file.getName().endsWith(".lib"))
        {
          FileInputStream fis = new FileInputStream(file);
          GZIPInputStream gis = new GZIPInputStream(fis);
          ObjectInputStream ois = new ObjectInputStream(gis);

          ClassList loaded = null;
          long begin = System.currentTimeMillis();

          try
          {
            loaded = (ClassList) ois.readObject();
          } catch (Exception e)
          {
            println(file + " is not a valid VDM++ library");
            perrs++;
            continue;
          } finally
          {
            ois.close();
          }

          long end = System.currentTimeMillis();
          loaded.setLoaded();
          classes.addAll(loaded);
          classes.remap();

          infoln("Loaded " + plural(loaded.size(), "class", "es")
              + " from " + file + " in " + (double) (end - begin)
              / 1000 + " secs");
        } else
        {
          if (replaceNewIdentifier.isEmpty()
              && architecture.isEmpty() && deploy.isEmpty())
          {
            long before = System.currentTimeMillis();
            LexTokenReader ltr = new LexTokenReader(file, Settings.dialect, filecharset);
            reader = new ClassReader(ltr);
            classes.addAll(reader.readClasses());
            long after = System.currentTimeMillis();
            duration += (after - before);
          } else
          {
            long before = System.currentTimeMillis();

            BacktrackInputReader fileReader = new BacktrackInputReader(file, filecharset);
            StringBuffer buf = new StringBuffer();
            char c;
            while ((c = fileReader.readCh()) != (char) -1)
            {
              buf.append(c);
            }
            fileReader.close();

            String patchedContent = patch(buf.toString());
            logChangedFileContent(patchedContent, file);

            LexTokenReader ltr = new LexTokenReader(patchedContent, Settings.dialect, file);
            reader = new ClassReader(ltr);
            classes.addAll(reader.readClasses());
            long after = System.currentTimeMillis();
            duration += (after - before);
          }
        }
      } catch (InternalException e)
      {
        println(e.toString());
        perrs++;
      } catch (Throwable e)
      {
        println(e.toString());
        perrs++;
      }

      if (reader != null && reader.getErrorCount() > 0)
      {
        perrs += reader.getErrorCount();
        reader.printErrors(Console.out);
      }

      if (reader != null && reader.getWarningCount() > 0)
      {
        pwarn += reader.getWarningCount();
        reader.printWarnings(Console.out);
      }
    }

    int n = classes.notLoaded();
View Full Code Here

TOP

Related Classes of org.overturetool.vdmj.syntax.ClassReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.