Package org.eclipse.imp.builder

Examples of org.eclipse.imp.builder.MarkerCreatorWithBatching


    return goodglobal;
  }
 
  @Override
  public TGlobal parse(String input, IProgressMonitor monitor) {
    MarkerCreatorWithBatching mcwb = msgHandler instanceof MarkerCreatorWithBatching ?
        (MarkerCreatorWithBatching) msgHandler : null;
    // when we build, we'll get a MarkerCreatorWithBatching
    // Hence, if we do not have one, we just scan&parse, otherwise we do a full compile
    TGlobal g = parse(input, mcwb == null, monitor);
    int u = TGlobal.unique(g);
    System.err.printf("frege parse: done, unique=%d, adding errors ", u);
    tokensIteratorDone = false;
    TList msgs = PreludeList.reverse(TSubSt.messages(TGlobal.sub(g)));
    int maxmsgs = 9;
    
    while (!monitor.isCanceled() && maxmsgs > 0) {
      TList.DCons node = msgs._Cons();
      if (node == null) break;
      msgs = node.mem2.<TList>forced();
      TMessage msg = Delayed.<TMessage>forced( node.mem1 );
      if (mcwb != null) {
        // do also warnings and hints
        int sev = IMarker.SEVERITY_ERROR;
        if (TMessage.level(msg) == TSeverity.HINT) sev = IMarker.SEVERITY_INFO;
        else if (TMessage.level(msg) == TSeverity.WARNING)
          sev = IMarker.SEVERITY_WARNING;
        try {
          mcwb.addMarker(sev,
              TMessage.text(msg)
                .replaceAll("\n", "   "),
              TToken.line( TPosition.first(TMessage.pos(msg)) ),
              TPosition.start(TMessage.pos(msg)),
              TPosition.end(TMessage.pos(msg)));
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);
View Full Code Here

        {
            HaxeParseController parseController = new HaxeParseController();

            // TODO:  Pick a version of the marker creator (or just go with this one)
            //MarkerCreator markerCreator = new MarkerCreator(file,parseController, PROBLEM_MARKER_ID);
            MarkerCreatorWithBatching markerCreator = new MarkerCreatorWithBatching(file, parseController, this);

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

            ISourceProject sourceProject = ModelFactory.open(file.getProject());
View Full Code Here

TOP

Related Classes of org.eclipse.imp.builder.MarkerCreatorWithBatching

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.