コード例 #1
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
  public void checkForClashes(final IBackend backend, final IProject project) {
    try {
      final OtpErlangList res = InternalErlideBuilder.getCodeClashes(backend);
      for (final OtpErlangObject elem : res) {
        final OtpErlangTuple t = (OtpErlangTuple) elem;
        final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
        final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();

        // add marker only for modules belonging to this project!
        final IResource r1 = project.findMember(f1);
        final IResource r2 = project.findMember(f2);
        if (r1 != null || r2 != null) {
          MarkerUtils.addMarker(
              project,
              null,
              project,
              "Code clash between " + f1 + " and " + f2,
              0,
              IMarker.SEVERITY_WARNING,
              "");
        }
      }

    } catch (final Exception e) {
    }
    try {
      final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
      final Collection<IPath> sd = erlProject.getSourceDirs();
      final String[] dirList = new String[sd.size()];
      int j = 0;
      for (final IPath sp : sd) {
        dirList[j++] = project.getLocation().toPortableString() + "/" + sp;
      }
      final OtpErlangList res = InternalErlideBuilder.getSourceClashes(backend, dirList);
      for (int i = 0; i < res.arity(); i++) {
        final OtpErlangTuple t = (OtpErlangTuple) res.elementAt(i);
        final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
        final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();
        MarkerUtils.addMarker(
            project,
            null,
            project,
            "Duplicated module name in " + f1 + " and " + f2,
            0,
            IMarker.SEVERITY_WARNING,
            "");
      }
    } catch (final Exception e) {
      ErlLogger.debug(e);
    }
  }
コード例 #2
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
  public void completeCompile(
      final IProject project,
      final IResource source,
      final OtpErlangObject compilationResult,
      final IBackend backend,
      final OtpErlangList compilerOptions) {
    if (compilationResult == null) {
      MarkerUtils.addProblemMarker(
          source, null, null, "Could not compile file", 0, IMarker.SEVERITY_ERROR);
      return;
    }
    final OtpErlangTuple t = (OtpErlangTuple) compilationResult;
    // ErlLogger.debug("** " + t);

    if ("ok".equals(((OtpErlangAtom) t.elementAt(0)).atomValue())) {
      final String beamf = source.getFullPath().removeFileExtension().lastSegment();
      InternalErlideBuilder.loadModule(project, beamf);
      refreshDirs(project, t.elementAt(2));
    } else {
      // ErlLogger.debug(">>>> compile error... %s\n   %s",
      // resource.getName(), t);
    }

    // process compilation messages
    if (t.elementAt(1) instanceof OtpErlangList) {
      final OtpErlangList l = (OtpErlangList) t.elementAt(1);
      MarkerUtils.addErrorMarkers(source, l);
    } else {
      ErlLogger.warn("bad result from builder: %s", t);
    }

    completeCompileForYrl(project, source, backend, compilerOptions);
  }
コード例 #3
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
  public IRpcFuture startCompileErl(
      final IProject project,
      final BuildResource bres,
      final String outputDir0,
      final IBackend backend,
      final OtpErlangList compilerOptions,
      final boolean force) {
    final IPath projectPath = project.getLocation();
    final IResource res = bres.getResource();
    final String s = res.getFileExtension();
    if (!"erl".equals(s)) {
      ErlLogger.warn("trying to compile " + res.getName() + "?!?!");
    }

    MarkerUtils.deleteMarkers(res);

    String outputDir;
    outputDir = getRealOutputDir(bres, outputDir0, projectPath);

    final Collection<IPath> includeDirs = getAllIncludeDirs(project);

    // delete beam file
    final IPath beamPath = getBeamForErl(res);
    final IResource beam = project.findMember(beamPath);

    try {
      final boolean shouldCompile = force || shouldCompile(project, res, beam);

      if (shouldCompile) {
        if (beam != null) {
          try {
            beam.delete(true, null);
          } catch (final Exception e) {
            ErlLogger.warn(e);
          }
        }
        if (isDebugging()) {
          ErlLogger.debug("compiling %s", res.getName());
        }

        createTaskMarkers(project, res);
        return InternalErlideBuilder.compileErl(
            backend, res.getLocation(), outputDir, includeDirs, compilerOptions);

      } else {
        return null;
      }
    } catch (final Exception e) {
      ErlLogger.warn(e);
      return null;
    }
  }
コード例 #4
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
  public IRpcFuture startCompileYrl(
      final IProject project,
      final IResource resource,
      final IBackend backend,
      final OtpErlangList compilerOptions) {
    // final IPath projectPath = project.getLocation();
    // final OldErlangProjectProperties prefs = new
    // OldErlangProjectProperties(project);

    MarkerUtils.deleteMarkers(resource);
    // try {
    // resource.deleteMarkers(PROBLEM_MARKER, true,
    // IResource.DEPTH_INFINITE);
    // } catch (final CoreException e1) {
    // }

    final IPath erl = getErlForYrl(resource);
    final IResource br = project.findMember(erl);

    // we should check timestamps, but yrl files are rare, so it doesn't
    // matter much

    try {
      if (br != null && br.exists()) {
        try {
          br.delete(true, null);
        } catch (final Exception e) {
          ErlLogger.warn(e);
        }
      }

      final String input = resource.getLocation().toString();
      final String output = resource.getLocation().removeFileExtension().toString();
      return InternalErlideBuilder.compileYrl(backend, input, output);
    } catch (final Exception e) {
      e.printStackTrace();
      return null;
    }
  }