コード例 #1
0
  private final void handleOutputLine(String line) {
    Matcher m = warningErrorPattern.matcher(line);

    if (m.find()) {
      String filename = m.group(1);
      int lineNumber = Integer.parseInt(m.group(2));
      // int colNumber = Integer.parseInt(m.group(3));
      String msg = m.group(4);

      // Determine the severity
      int severity = IMarker.SEVERITY_INFO;
      if (msg.toLowerCase().contains("error")) severity = IMarker.SEVERITY_ERROR;
      else if (msg.toLowerCase().contains("warning")) severity = IMarker.SEVERITY_WARNING;

      // Find the resource and create a marker
      for (Resource r : sourceResources) {
        IResource res = getIResource(r);
        if (filename.equals(res.getName())) {
          IMarker marker;
          try {
            marker = res.createMarker(IMarker.PROBLEM);
            marker.setAttribute(IMarker.MESSAGE, msg);
            marker.setAttribute(IMarker.SEVERITY, severity);
            marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
            marker.setAttribute(PreferenceConstants.OCARINA_MARKER, "true");
          } catch (CoreException e) {
            throw new RuntimeException(e);
          }
        }
      }
    }

    out().println(line);
  }
コード例 #2
0
 public void setConditionWithEnable(boolean enabled, String condition) throws CoreException {
   fCondition = condition;
   IMarker marker = getMarker();
   marker.setAttribute(IPHPDebugConstants.Condition, condition);
   fConditionEnabled = enabled;
   marker.setAttribute(IPHPDebugConstants.ConditionEnabled, new Boolean(enabled));
   int lineNumber = ((Integer) marker.getAttribute(IMarker.LINE_NUMBER)).intValue();
   if (enabled) {
     String message =
         MessageFormat.format(
             PHPDebugCoreMessages.ConditionalBreakPointMessage_1,
             new String[] {marker.getResource().getName(), Integer.toString(lineNumber)});
     message +=
         MessageFormat.format(
             PHPDebugCoreMessages.ConditionalBreakPointMessage_2, new String[] {condition});
     marker.setAttribute(IMarker.MESSAGE, message);
   } else {
     marker.setAttribute(
         IMarker.MESSAGE,
         MessageFormat.format(
             PHPDebugCoreMessages.LineBreakPointMessage_1,
             new String[] {marker.getResource().getName(), Integer.toString(lineNumber)}));
   }
   addConditionToBP();
   setConditionChanged(true);
 }
コード例 #3
0
 /** @since 2.7 */
 protected void addMarkerAndLogError(URI uri, Throwable e) {
   for (Pair<IStorage, IProject> storage : getStorage2UriMapper().getStorages(uri)) {
     IResource resource = null;
     if (storage.getFirst() instanceof IResource) {
       resource = (IResource) storage.getFirst();
     } else {
       resource = storage.getSecond();
     }
     if (resource != null) {
       try {
         IMarker marker = resource.createMarker(MarkerTypes.NORMAL_VALIDATION);
         marker.setAttribute(IMarker.MESSAGE, e.getMessage() + " - See error log for details");
         marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
         marker.setAttribute(IMarker.LINE_NUMBER, 1);
       } catch (CoreException ce) {
         logger.error("Could not create marker", ce);
       }
     }
   }
   Throwable cause = e;
   if (cause instanceof CoreException) {
     cause = cause.getCause();
   }
   if (uri == null) {
     logger.error("Error during compilation.", e);
   } else {
     logger.error("Error during compilation of '" + uri + "'.", e);
   }
 }
コード例 #4
0
  private IMarker addMarker(
      IResource resource,
      String type,
      String message,
      int lineNumber,
      int severity,
      boolean isTransient) {
    IMarker marker = null;
    try {
      if (resource.isAccessible()) {
        if (lineNumber == -1) {
          lineNumber = 1;
        }

        // mkleint: this strongly smells like some sort of workaround for a problem with bad marker
        // cleanup.
        // adding is adding and as such shall always be performed.
        marker = findMarker(resource, type, message, lineNumber, severity, isTransient);
        if (marker != null) {
          // This marker already exists
          return marker;
        }
        marker = resource.createMarker(type);
        marker.setAttribute(IMarker.MESSAGE, message);
        marker.setAttribute(IMarker.SEVERITY, severity);
        marker.setAttribute(IMarker.TRANSIENT, isTransient);

        marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
        log.debug("Created marker '{}' on resource '{}'.", message, resource.getFullPath());
      }
    } catch (CoreException ex) {
      log.error("Unable to add marker; " + ex.toString(), ex); // $NON-NLS-1$
    }
    return marker;
  }
コード例 #5
0
 /**
  * Propagates the given marker to the given source line
  *
  * @param marker The marker to propagate
  * @param file The features file
  * @param line The marker line at the features file
  */
 protected void propagateMarker(IMarker marker, IFile file, int line) {
   if (file != null && file.exists()) {
     Object severity = null;
     String message = marker.getAttribute(IMarker.MESSAGE, NO_ATTRIBUTE);
     if (NO_ATTRIBUTE.equals(message)) {
       return;
     }
     try {
       severity = marker.getAttribute(IMarker.SEVERITY);
     } catch (CoreException e) {
       severity = IMarker.SEVERITY_ERROR;
     }
     if (!hasSameMarker(message, line, file)) {
       IMarker newMarker = null;
       try {
         newMarker = file.createMarker(FeatureHouseCorePlugin.BUILDER_PROBLEM_MARKER);
         newMarker.setAttribute(IMarker.LINE_NUMBER, line);
         newMarker.setAttribute(IMarker.MESSAGE, message);
         newMarker.setAttribute(IMarker.SEVERITY, severity);
       } catch (CoreException e) {
         FeatureHouseCorePlugin.getDefault().logError(e);
       }
     }
   }
 }
コード例 #6
0
 /**
  * Create a marker on the given resource
  *
  * @param resource the resource
  * @param severity the severity constant
  * @param message the message
  * @param lineNumber the line number
  */
 public void createMarker(IResource resource, int severity, String message, Integer lineNumber) {
   try {
     IMarker marker = resource.createMarker(MARKER_TYPE);
     marker.setAttribute(IMarker.MESSAGE, message);
     marker.setAttribute(IMarker.SEVERITY, severity);
     marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
   } catch (CoreException e) {
     logException(e.getMessage(), e);
   }
 }
コード例 #7
0
 private void addMarker(int lineNumber, String text, int severity) {
   try {
     IMarker m = resource.createMarker(IMarker.PROBLEM);
     m.setAttribute(IMarker.LINE_NUMBER, lineNumber + 1);
     m.setAttribute(IMarker.MESSAGE, text);
     m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
     m.setAttribute(IMarker.SEVERITY, severity);
   } catch (CoreException e) {
     e.printStackTrace();
   }
 }
コード例 #8
0
ファイル: MarkerUtils.java プロジェクト: jakobc/erlide
 public static IMarker createErlangLineBreakpointMarker(
     final IResource resource, final int lineNumber, final String modelIdentifier)
     throws CoreException {
   final IMarker marker = resource.createMarker("org.erlide.core.erlang.lineBreakpoint.marker");
   marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE);
   marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
   marker.setAttribute(IBreakpoint.ID, modelIdentifier);
   marker.setAttribute(
       IMarker.MESSAGE, "Line Breakpoint: " + resource.getName() + " [line: " + lineNumber + "]");
   return marker;
 }
コード例 #9
0
ファイル: HLintBuilder.java プロジェクト: prark/eclipsefp
 static void createMarker(final IResource resource, final Suggestion s) throws CoreException {
   if (s.getSeverity() != Severity.IGNORE) {
     IMarker marker = resource.createMarker(HaskellCorePlugin.ID_HLINT_MARKER);
     marker.setAttribute(IMarker.MESSAGE, s.getMessage());
     marker.setAttribute(
         IMarker.SEVERITY,
         s.getSeverity() == Severity.ERROR ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_INFO);
     // marker.setAttribute( IMarker.CHAR_START, 0 );
     // marker.setAttribute( IMarker.CHAR_END, 1 );
     marker.setAttribute(IMarker.LINE_NUMBER, s.getLocation().getLine());
   }
 }
コード例 #10
0
 @Override
 public void handleError(IStatus status) {
   try {
     IMarker m = file.createMarker(IMarker.PROBLEM);
     // m.setAttribute(IMarker.LINE_NUMBER, line);
     m.setAttribute(IMarker.MESSAGE, status.toString());
     m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
     m.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
   } catch (CoreException e) {
     // an error while marking an error, lets throw it
     throw new RuntimeException(e);
   }
 }
コード例 #11
0
 /*
  * (non-Javadoc)
  *
  * @see featureide.core.internal.IMarkerHandler#createModelMarker(java.lang.String,
  *      int)
  */
 public void createModelMarker(String message, int severity, int lineNumber) {
   try {
     IResource resource = modelFile.exists() ? modelFile : project;
     IMarker marker = resource.createMarker(MODEL_MARKER);
     if (marker.exists()) {
       marker.setAttribute(IMarker.MESSAGE, message);
       marker.setAttribute(IMarker.SEVERITY, severity);
       marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
     }
   } catch (CoreException e) {
     e.printStackTrace();
   }
 }
コード例 #12
0
 /**
  * Creates a marker with the specified type on this resource. Marker type ids are the id of an
  * extension installed in the <code>org.eclipse.core.resources.markers</code> extension point. The
  * specified type string must not be <code>null</code>.
  *
  * @param resource An IResource for which a marker must be added
  * @param message The message of the marker we want to display in the Problem View.
  * @param severity The severity of the marker
  * @param type the type of the marker to create
  * @return an optional Marker (none if problem during creation).
  */
 public static Option<IMarker> addMarkerFor(
     final IResource resource, final String message, final int severity, String type) {
   try {
     if (resource != null) {
       final IMarker marker = resource.createMarker(type);
       marker.setAttribute(IMarker.SEVERITY, severity);
       marker.setAttribute(IMarker.MESSAGE, message);
       return Options.newSome(marker);
     }
   } catch (final CoreException e) {
     DslCommonPlugin.getDefault().getLog().log(e.getStatus());
   }
   return Options.newNone();
 }
コード例 #13
0
ファイル: MarkerUtils.java プロジェクト: jakobc/erlide
 public static IMarker createSearchResultMarker(
     final IErlModule module, final String type, final int offset, final int length)
     throws CoreException {
   boolean setPath = false;
   IResource resource = module.getCorrespondingResource();
   if (resource == null) {
     resource = ResourcesPlugin.getWorkspace().getRoot();
     setPath = true;
   }
   final IMarker marker = resource.createMarker(type);
   marker.setAttribute(IMarker.CHAR_START, offset);
   marker.setAttribute(IMarker.CHAR_END, offset + length);
   if (setPath) {
     marker.setAttribute(PATH_ATTRIBUTE, module.getFilePath());
   }
   return marker;
 }
コード例 #14
0
 /**
  * Sets the attribute of this IMarker with the given name. <br>
  *
  * @see IMarker#setAttribute(String, Object)
  * @param marker The concerned marker
  * @param attributeName the name of the attribute
  * @param value the value, or <code>null</code> if the attribute is to be undefined
  */
 public static void setAttribute(IMarker marker, String attributeName, Object value) {
   try {
     if (marker != null) {
       marker.setAttribute(attributeName, value);
     }
   } catch (final CoreException e) {
     DslCommonPlugin.getDefault().getLog().log(e.getStatus());
   }
 }
コード例 #15
0
ファイル: MarkerHelper.java プロジェクト: pdorobisz/erlide
 public static void addTaskMarker(
     final IResource file,
     final IResource compiledFile,
     final String message,
     int lineNumber,
     final int priority) {
   try {
     final IMarker marker = file.createMarker(TASK_MARKER);
     marker.setAttribute(IMarker.MESSAGE, message);
     marker.setAttribute(IMarker.PRIORITY, priority);
     marker.setAttribute(IMarker.SOURCE_ID, compiledFile.getFullPath().toString());
     if (lineNumber == -1) {
       lineNumber = 1;
     }
     marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
   } catch (final CoreException e) {
   }
 }
コード例 #16
0
  /**
   * This method changes all validator markers on the IResource and its children. All markers owned
   * by "from" have their owner reassigned to "to".
   */
  public static void updateOwner(String from, String to, IResource resource) throws CoreException {
    IMarker[] ownedMarkers = getValidationTasks(resource, from);
    if (ownedMarkers == null) {
      return;
    }

    for (int i = 0; i < ownedMarkers.length; i++) {
      IMarker marker = ownedMarkers[i];
      marker.setAttribute(VALIDATION_MARKER_OWNER, to);
    }
  }
コード例 #17
0
ファイル: MarkerHelper.java プロジェクト: pdorobisz/erlide
 public static void addProblemMarker(
     final IResource file,
     final IResource compiledFile,
     final String message,
     int lineNumber,
     final int severity) {
   try {
     final IMarker marker = file.createMarker(PROBLEM_MARKER);
     marker.setAttribute(IMarker.MESSAGE, message);
     marker.setAttribute(IMarker.SEVERITY, severity);
     if (compiledFile != null) {
       marker.setAttribute(IMarker.SOURCE_ID, compiledFile.getFullPath().toString());
     }
     if (lineNumber == -1) {
       lineNumber = 1;
     }
     marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
   } catch (final CoreException e) {
   }
 }
コード例 #18
0
 public static void updateAllSonarMarkerSeverity() throws CoreException {
   for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
     if (project.isAccessible()) {
       for (IMarker marker :
           project.findMarkers(SonarCorePlugin.MARKER_ID, true, IResource.DEPTH_INFINITE)) {
         boolean isNew = marker.getAttribute(SONAR_MARKER_IS_NEW_ATTR, false);
         marker.setAttribute(
             IMarker.SEVERITY, isNew ? markerSeverityForNewIssues : markerSeverity);
       }
     }
   }
 }
コード例 #19
0
 /** @generated */
 public static IMarker addMarker(
     IFile file, String elementId, String location, String message, int statusSeverity) {
   IMarker marker = null;
   try {
     marker = file.createMarker(MARKER_TYPE);
     marker.setAttribute(IMarker.MESSAGE, message);
     marker.setAttribute(IMarker.LOCATION, location);
     marker.setAttribute(
         org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId);
     int markerSeverity = IMarker.SEVERITY_INFO;
     if (statusSeverity == IStatus.WARNING) {
       markerSeverity = IMarker.SEVERITY_WARNING;
     } else if (statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) {
       markerSeverity = IMarker.SEVERITY_ERROR;
     }
     marker.setAttribute(IMarker.SEVERITY, markerSeverity);
   } catch (CoreException e) {
     UMLDiagramEditorPlugin.getInstance()
         .logError("Failed to create validation marker", e); // $NON-NLS-1$
   }
   return marker;
 }
コード例 #20
0
  public static IMarker createMarker(IFile file, IDocument document, IRegion region) {
    String waypointDefinition;

    try {
      waypointDefinition = document.get(region.getOffset(), region.getLength());
    } catch (BadLocationException e) {
      e.printStackTrace();
      return null;
    }

    IMarker marker;
    try {
      marker = file.createMarker(JavaWaypoint.MARKER_ID);
      marker.setAttribute(IMarker.MESSAGE, waypointDefinition);
      marker.setAttribute(IMarker.CHAR_START, region.getOffset());
      marker.setAttribute(IMarker.CHAR_END, region.getOffset() + region.getLength());
    } catch (CoreException e) {
      e.printStackTrace();
      return null;
    }

    return marker;
  }
コード例 #21
0
  private static IMarker[] getValidationTasks(IResource resource, int severity, int depth) {
    IMarker[] tempMarkers = null;
    int validCount = 0;
    IMarker[] allMarkers = null;
    try {
      allMarkers = resource.findMarkers(VALIDATION_MARKER, true, depth);
    } catch (CoreException e) {
      if (Tracing.isLogging()) ValidationPlugin.getPlugin().handleException(e);
      return NO_MARKERS;
    }

    // Now filter in the markers, based on severity type.
    if (allMarkers.length != 0) {
      tempMarkers = new IMarker[allMarkers.length];
      for (IMarker marker : allMarkers) {
        Integer filterSeverity = null;
        try {
          filterSeverity = (Integer) marker.getAttribute(VALIDATION_MARKER_SEVERITY);
        } catch (CoreException e) {
          // Someone may have deleted the marker on us. All we can do is skip it.
          continue;
        }
        if (filterSeverity == null) {
          // odd...marker wasn't created correctly. How could this happen?
          // Default to the current severity and add it to the list.
          try {
            // 226541 - I was seeing markers with valid severities being reset, so I added this
            // additional test.
            if (marker.getAttribute(IMarker.SEVERITY, -1) == -1)
              marker.setAttribute(IMarker.SEVERITY, getSeverity(severity));
          } catch (Exception e) {
            ValidationPlugin.getPlugin().handleException(e);
            continue;
          }
        } else if ((severity & filterSeverity.intValue()) == 0) {
          continue;
        }
        tempMarkers[validCount++] = marker;
      }
    }

    if (validCount == 0) {
      return NO_MARKERS;
    }

    IMarker[] validMarkers = new IMarker[validCount];
    System.arraycopy(tempMarkers, 0, validMarkers, 0, validCount);
    return validMarkers;
  }
コード例 #22
0
ファイル: MarkerUtils.java プロジェクト: jakobc/erlide
 public static void addDialyzerWarningMarker(
     final IResource file,
     final String path,
     final String message,
     int lineNumber,
     final int severity) {
   try {
     final IMarker marker;
     if (file != null) {
       marker = file.createMarker(DIALYZE_WARNING_MARKER);
     } else {
       final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
       marker = workspaceRoot.createMarker(DIALYZE_WARNING_MARKER);
       marker.setAttribute(PATH_ATTRIBUTE, path);
     }
     marker.setAttribute(IMarker.MESSAGE, message);
     marker.setAttribute(IMarker.SEVERITY, severity);
     if (lineNumber == -1) {
       lineNumber = 1;
     }
     marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
   } catch (final CoreException e) {
   }
 }
コード例 #23
0
  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;
  }
コード例 #24
0
  @SuppressWarnings("restriction")
  private void addMissingDirWarning(IProject project, SourceLocation sourceLocation, File dir)
      throws CoreException {

    IMarker marker =
        markerManager.addMarker(
            project.getFile("pom.xml"),
            MISSING_ENDORSED_DIRS_MARKER,
            "Endorsed directory '"
                + dir.getAbsolutePath()
                + "' is missing. "
                + "You may need to a perform a Maven command line build in order to create it.",
            sourceLocation.getLineNumber(),
            IMarker.SEVERITY_ERROR);
    marker.setAttribute("outputDirectory", dir.getAbsolutePath());
  }
コード例 #25
0
 IMarker createMarkerFromSearchMatch(IFile file, SearchMatch match) {
   IMarker marker = null;
   try {
     if (CHOICE_METHOD_DECLARATION.equals(mChoice)) {
       HashMap<String, Object> map = new HashMap<String, Object>();
       map.put(IMarker.CHAR_START, new Integer(match.getOffset()));
       map.put(IMarker.CHAR_END, new Integer(match.getOffset() + match.getLength()));
       marker = file.createMarker(IMarker.TEXT);
       marker.setAttributes(map);
     } else if (CHOICE_ERROR_LINE.equals(mChoice)) {
       marker = file.createMarker(IMarker.TEXT);
       marker.setAttribute(IMarker.LINE_NUMBER, mLineNumber);
     }
   } catch (CoreException e) {
     Status s = new Status(Status.ERROR, DdmsPlugin.PLUGIN_ID, e.getMessage(), e);
     DdmsPlugin.getDefault().getLog().log(s);
   }
   return marker;
 }
  @Override
  public void connectorXReferenceAdded(final Connector connector, final IXReference xref) {
    //    	Thread thread = new Thread(new Runnable() {
    //
    //			@Override
    //			public void run() {
    if (connector.isEnvisaged()
        || ignoreViolations()
        || !isAttachedToProject(xref.getSource().getResource().getProject())) return;

    IResource resource = xref.getSource().getResource();

    try {
      IMarker marker = resource.createMarker(defaults.MARKER_TYPE);
      marker.setAttribute(IMarker.SEVERITY, getViolationSeverity());
      marker.setAttribute(
          IMarker.MESSAGE,
          "Element "
              + xref.getTarget().getName()
              + " should not be accessed in this context "
              + "("
              + connector.getSource().getName()
              + "->"
              + connector.getTarget().getName()
              + ")");

      marker.setAttribute(IMarker.CHAR_START, xref.getOffset());
      marker.setAttribute(IMarker.CHAR_END, xref.getOffset() + xref.getLength());
      marker.setAttribute(IMarker.LINE_NUMBER, xref.getLine());
      marker.setAttribute(defaults.MODEL, model.getResource().getFullPath());
      marker.setAttribute(defaults.CONNECTOR_ID, connector.toString());
      violations.put(ArchitectureModel.xrefStringFactory.toString(xref), marker.getId());
    } catch (CoreException ex) {
      // TODO: Do something better here;
      ex.printStackTrace();
    }

    //			}
    //		});thread.start();

  }
  public void setViolationSeverity(int severity) {
    validateSeverity(severity);
    int oldSeverity = getViolationSeverity();

    if (severity != oldSeverity) {
      getModelProperties().setViolationSeverity(severity);

      for (IProject project : projects) {
        try {
          if (oldSeverity == -1) {
            model.accept(new ModelProblemCollector(this, project));
          } else if (severity != -1) {
            for (IMarker marker :
                project.findMarkers(defaults.MARKER_TYPE, true, IResource.DEPTH_INFINITE))
              marker.setAttribute(IMarker.SEVERITY, severity);
          } else project.deleteMarkers(defaults.MARKER_TYPE, true, IResource.DEPTH_INFINITE);
        } catch (CoreException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
  }
コード例 #28
0
  void doHandleErrorsJob(Task[] errors, IFile file) {
    synchronized (this) // prevent simultaneous error updates on the same file
    {
      if (ResourcesPlugin.getWorkspace().isTreeLocked()) {
        IdeLog.logWarning(
            PHPEditorPlugin.getDefault(),
            "Error updating the document errors. The workspace tree is locked.",
            PHPEditorPlugin.DEBUG_SCOPE); // $NON-NLS-1$
      }

      if (file == null || !file.exists()) {
        return;
      }
      int depth = IResource.DEPTH_INFINITE;
      try {

        IMarker[] problemMarkers = file.findMarkers(IMarker.TASK, true, depth);
        for (IMarker m : problemMarkers) {
          Object attribute2 = m.getAttribute(APTANA_TASK);
          if (attribute2 != null && attribute2.equals("true")) // $NON-NLS-1$
          {
            m.delete();
          }
        }
        for (Task t : errors) {
          IMarker problemMarker = file.createMarker(IMarker.TASK);
          problemMarker.setAttribute(IMarker.PRIORITY, t.getPriority());
          problemMarker.setAttribute(IMarker.CHAR_START, t.getStart());
          problemMarker.setAttribute(IMarker.CHAR_END, t.getEnd());
          problemMarker.setAttribute(APTANA_TASK, Boolean.TRUE.toString());
          problemMarker.setAttribute(IMarker.MESSAGE, t.getDescription());
          problemMarker.setAttribute(IMarker.LINE_NUMBER, t.getLineNumber());
        }
      } catch (Exception e) {
        IdeLog.logWarning(
            PHPEditorPlugin.getDefault(),
            "Error updating the PHP task-tags.",
            e,
            PHPEditorPlugin.DEBUG_SCOPE); // $NON-NLS-1$
      }
    }
  }
コード例 #29
0
  public static IMarker createOrUpdateKbProblemMarker(
      IMarker m, IResource r, String message, int kind) throws CoreException {
    String preferenceValue = getPreference(r.getProject(), kind);

    String s =
        KBSeverityPreferences.getInstance()
            .getProjectPreference(
                r.getProject(), ELSeverityPreferences.ENABLE_BLOCK_PREFERENCE_NAME);

    if (SeverityPreferences.IGNORE.equals(preferenceValue) || JavaCore.DISABLED.equals(s)) {
      if (m != null) {
        m.delete();
      }
      return null;
    }

    if (m == null) {
      m = r.createMarker(KB_BUILDER_PROBLEM_MARKER_TYPE);
      m.setAttribute(KbBuilderMarker.ATTR_KIND, KbBuilderMarker.KIND_KB_NATURE_OR_BUILDER_MISSING);
      if (kind == KIND_KB_NATURE_OR_BUILDER_MISSING) {
        r.setPersistentProperty(KbProjectFactory.NATURE_MOCK, "true"); // $NON-NLS-1$
        KbProjectFactory.getKbProject(r.getProject(), true);
      }
    }

    int severity = IMarker.SEVERITY_WARNING;

    if (SeverityPreferences.ERROR.equals(preferenceValue)) {
      severity = IMarker.SEVERITY_ERROR;
    }
    String location =
        MessageFormat.format(
            KbMessages.KBPROBLEM_LOCATION, new Object[] {r.getProject().getName()});

    m.setAttribute(ATTR_KIND, kind);
    m.setAttribute(IMarker.LOCATION, location);
    m.setAttribute(IMarker.MESSAGE, message);
    m.setAttribute(IMarker.SEVERITY, severity);
    m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
    return m;
  }
コード例 #30
0
ファイル: HtmlProblem.java プロジェクト: kiberkli/wolips
 public IMarker createMarker(IFile file, String severityPreference) {
   IMarker marker = null;
   try {
     marker = _htmlFile.createMarker(Activator.TEMPLATE_PROBLEM_MARKER);
     marker.setAttribute(IMarker.MESSAGE, getMessage());
     int severity;
     if (isWarning() || PreferenceConstants.WARNING.equals(severityPreference)) {
       severity = IMarker.SEVERITY_WARNING;
     } else {
       severity = IMarker.SEVERITY_ERROR;
     }
     marker.setAttribute(IMarker.SEVERITY, new Integer(severity));
     marker.setAttribute(IMarker.LINE_NUMBER, _lineNumber);
     marker.setAttribute(IMarker.CHAR_START, _position.getOffset());
     marker.setAttribute(IMarker.CHAR_END, _position.getOffset() + _position.getLength());
     marker.setAttribute(IMarker.TRANSIENT, false);
   } catch (CoreException e) {
     Activator.getDefault().log(e);
   }
   return marker;
 }