Beispiel #1
0
 public static String formatResourceDiagnostics(
     List<Resource.Diagnostic> diagnostics, String messagePrefix, String newLine) {
   if (diagnostics.size() <= 0) {
     return null;
   }
   StringBuilder s = new StringBuilder();
   s.append(messagePrefix);
   for (Resource.Diagnostic diagnostic : diagnostics) {
     s.append(newLine);
     String location = diagnostic.getLocation();
     if (location != null) {
       s.append(location);
       s.append(":");
     }
     s.append(diagnostic.getLine());
     try {
       int column = diagnostic.getColumn();
       s.append(":");
       s.append(column);
     } catch (Exception e) {
     } // UnsupportedOperationException is normal
     s.append(": ");
     s.append(diagnostic.getMessage());
   }
   return s.toString();
 }
 private void logErrors(Resource csResource) {
   for (Resource.Diagnostic diagnostic : csResource.getErrors()) {
     log(
         diagnostic.getMessage()
             + " (line "
             + diagnostic.getLine()
             + ", column "
             + diagnostic.getColumn()
             + ") in "
             + csResource.getURI().toString(),
         Project.MSG_ERR);
   }
 }
  protected boolean adjustMarker(IMarker marker, Diagnostic diagnostic) throws CoreException {
    if (diagnostic.getData() != null) {
      for (Object element : diagnostic.getData()) {
        if (element instanceof Resource.Diagnostic) {
          Resource.Diagnostic resourceDiagnostic = (Resource.Diagnostic) element;
          if (resourceDiagnostic.getLocation() != null) {
            marker.setAttribute(
                IMarker.LOCATION,
                EMFEditUIPlugin.getPlugin()
                    .getString(
                        "_UI_MarkerLocation",
                        new String[] {
                          Integer.toString(resourceDiagnostic.getLine()),
                          Integer.toString(resourceDiagnostic.getColumn())
                        }));

            marker.setAttribute(IMarker.LINE_NUMBER, resourceDiagnostic.getLine());
            return true;
          }
        }
      }
    }
    return false;
  }