Package frege.imp.parser

Examples of frege.imp.parser.FregeParseController$FregeData


        // editor is not null
        try {
          if (!editor.isEditable()) return;
          IParseController pc = editor.getParseController();
          if (pc == null || !(pc instanceof FregeParseController)) return;
          final FregeParseController fpc = (FregeParseController) pc;
          TGlobal global = fpc.getCurrentAst();
              if (global == null) return;
              // global.mem$sub.mem$cache.put(TTree.DNil.it);
              // fpc.global = FregeParseController.runSTG(action, global);
             
              final IDocument document= editor.
                  getDocumentProvider().
                  getDocument(editor.getEditorInput());
             
              fpc.resetHash();
              fpc.msgHandler.clearMessages();
          theEditor.removeParserAnnotations();
          document.replace(0,1, document.get(0, 1));             
        }
          catch (Exception e) {
View Full Code Here


     
    }
   
    boolean success = false;
    try {
      FregeParseController parseController = new FregeParseController();

      MarkerCreatorWithBatching markerCreator = new MarkerCreatorWithBatching(file, parseController, this);

      parseController.getAnnotationTypeInfo().addProblemMarkerType(
          getErrorMarkerID());

      ISourceProject sourceProject = ModelFactory.open(file.getProject());
      parseController.initialize(file.getProjectRelativePath(),
          sourceProject, markerCreator);

      String contents = BuilderUtils.getFileContents(file);
      final TGlobal result = parseController.parse(contents, new CompProgress());
      if (FregeParseController.errors(result) == 0) {
        // run the eclipse java compiler
        final String target = Main.targetPath(result, ".java");
       
        getPlugin().writeInfoMsg("built: " + target);
        // get the frege path and build path
        final String bp = TOptions.dir( TGlobal.options(result) );
        final TList ourPath = frege.compiler.Utilities.ourPath(TGlobal.options(result));
        final String fp = Delayed.<String>forced(
            PreludeText.joined(
                              System.getProperty("path.separator"),
                              ourPath
                ));
        final TList srcPath = TOptions.sourcePath(TGlobal.options(result));
        final String sp = Delayed.<String>forced(
            PreludeText.joined(
                          System.getProperty("path.separator"),
                          srcPath
            ));
        // construct the commandline
        final String cmdline = "-cp " + "\"" + fp + "\""
            + " -d " + "\"" + bp + "\""
            + " -sourcepath " + "\"" + sp + "\""
            + " -Xemacs -1.7 -encoding UTF-8 "
            + "\"" + target + "\"";
        getPlugin().writeInfoMsg("batch-compile " + cmdline);
        final StringWriter errs = new StringWriter();
        success = org.eclipse.jdt.core.compiler.batch.BatchCompiler.compile(
           cmdline,
           new PrintWriter(System.out),
           new PrintWriter(errs),
           new CompProgress());
       
        /* write java error messages to some file.
        if (errs.toString().length() > 0) try {
          FileWriter f = new FileWriter(target + ".errors");
          f.append(errs.toString());
          f.close();
        }
        catch (IOException e) {
          getPlugin().writeErrorMsg("could not write java compiler errors " + e.getMessage());
        }
        */
       
        if (!success) {
          TPosition pos = Global.packageStart(result).<TPosition>forced();
          TToken module = TPosition.first(pos);
          int line = TToken.line(module);
          int chStart = TToken.offset(module);
          int chEnd = chStart + TToken.length(module);
          String msg = errs.toString();
          String[] msgs = msg.split(System.getProperty("line.terminator", "\n"));
          Pattern p = Pattern.compile(":\\d+:\\s+error:(.*)");
          for (String s : msgs) {
            if (s == null) continue;
            // getPlugin().writeInfoMsg(s);
            Matcher m = p.matcher(s);
            if (m.find()) {
              String se = m.group(1);
              markerCreator.addMarker(
                  IMarker.SEVERITY_ERROR,
                  se, line, chStart, chEnd);
            }
          }
          getPlugin().writeErrorMsg("java compiler failed on " + target);
          markerCreator.addMarker(IMarker.SEVERITY_INFO,
              "Java compiler errors are almost always caused by bad native declarations. "
                + "When you're sure this is out of the question you've found a compiler bug, "
                + "please report under https://github.com/frege/frege/issues and attach a copy of "
                + target,
              line, chStart, chEnd);
        }
        else {
          // notify that we have a new module
          parseController.justCompiled();
        }
      }

      if (markerCreator instanceof MarkerCreatorWithBatching) {
        ((MarkerCreatorWithBatching) markerCreator).flush(monitor);
View Full Code Here

TOP

Related Classes of frege.imp.parser.FregeParseController$FregeData

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.