示例#1
0
 public static void createTaskMarkers(final IProject project, final IResource resource) {
   final IErlProject p = ErlangCore.getModel().findProject(project);
   if (p != null) {
     try {
       if (BuilderUtils.isDebugging()) {
         ErlLogger.debug("Creating task markers " + resource.getName());
       }
       // getMarkersFor(resource, p);
       getNoScanMarkersFor(resource, p);
     } catch (final ErlModelException e) {
     }
   }
 }
示例#2
0
  /**
   * Add error markers from a list of error tuples
   *
   * @param resource
   * @param errorList
   */
  public static void addErrorMarkers(final IResource resource, final OtpErlangList errorList) {
    for (final OtpErlangObject odata : errorList.elements()) {
      try {
        final OtpErlangTuple data = (OtpErlangTuple) odata;

        String msg = ErlUtils.asString(data.elementAt(2));
        if (msg.length() > 1000) {
          msg = msg.substring(0, 1000) + "......";
        }
        final String fileName = (String) TypeConverter.erlang2java(data.elementAt(1), String.class);
        IResource res = resource;
        if (!BuilderUtils.samePath(resource.getLocation().toString(), fileName)) {
          final IProject project = resource.getProject();
          res = BuilderUtils.findResourceByLocation(project, fileName);
          if (res == null) {
            try {
              final IErlModel model = ErlangCore.getModel();
              final String includeFile =
                  ModelUtils.findIncludeFile(
                      project,
                      fileName,
                      model.getExternal(model.findProject(project), ErlangCore.EXTERNAL_INCLUDES));
              if (includeFile != null) {
                res = ResourceUtil.openExternal(includeFile);
              }
            } catch (final Exception e) {
              ErlLogger.warn(e);
            }
          }
        }
        int line = 0;
        if (data.elementAt(0) instanceof OtpErlangLong) {
          try {
            line = ((OtpErlangLong) data.elementAt(0)).intValue();
          } catch (final OtpErlangRangeException e) {
          }
        }
        int sev = IMarker.SEVERITY_INFO;
        try {
          switch (((OtpErlangLong) data.elementAt(3)).intValue()) {
            case 0:
              sev = IMarker.SEVERITY_ERROR;
              break;
            case 1:
              sev = IMarker.SEVERITY_WARNING;
              break;
            default:
              sev = IMarker.SEVERITY_INFO;
              break;
          }
        } catch (final OtpErlangRangeException e) {
        }

        if (res != null) {
          addMarker(res, resource, msg, line, sev, "");
        } else {
          addMarker(
              resource.getProject(), null, "can't find " + fileName, 0, IMarker.SEVERITY_ERROR, "");
          addMarker(resource, null, "?? " + msg, line, sev, "");
        }
      } catch (final Exception e) {
        ErlLogger.warn(e);
        ErlLogger.warn("got: %s", odata);
      }
    }
  }