Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

perhaps an easier way to handle markers

  • Loading branch information...
commit e95aa7bc90be58525999644a873c43f7997ca5d3 1 parent 4ecf700
geoffroy authored
Showing with 32 additions and 2 deletions.
  1. +32 −2 src/opaide/editors/messages/OpaMessagesBank.java
View
34 src/opaide/editors/messages/OpaMessagesBank.java
@@ -27,7 +27,7 @@
private IOpaMessageListener myOpaMessageListener = new IOpaMessageListener() {
@Override
public void newMessage(OpaMessage someEvt) {
- addMessage(someEvt);
+ addMessage2(someEvt);
}
};
public IOpaMessageListener getOpaMessageListener(){ return myOpaMessageListener; };
@@ -47,9 +47,39 @@ private void initializeProject(IProject project) {
}
}
+ private void addMessage2(OpaMessage omsg) {
+ IProject theTargetProject = omsg.getProject();
+ if (omsg instanceof OpaNewCompilationLaunched) {
+ try {
+ for (IMarker m : theTargetProject.findMarkers(null, true, IResource.DEPTH_INFINITE)) {
+ m.delete();
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ } else if (omsg instanceof OpaErrorMessage) {
+ OpaErrorMessage errorMsg = (OpaErrorMessage) omsg;
+ IMarker marker;
+ try {
+ marker = errorMsg.getOpaSrcLocation().getTheFile().createMarker(IMarker.PROBLEM);
+ if (! marker.exists()) { return; };
+ marker.setAttribute(IMarker.MESSAGE, "Error:" + "\n" + errorMsg.getRawErrorMsg());
+ marker.setAttribute(IMarker.CHAR_START, errorMsg.getOpaSrcLocation().getGlobalCharStart());
+ marker.setAttribute(IMarker.CHAR_END, errorMsg.getOpaSrcLocation().getGlobalCharEnd());
+ marker.setAttribute(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
+ marker.setAttribute(IMarker.TRANSIENT, Boolean.TRUE);
+ marker.setAttribute(IMarker.LINE_NUMBER, errorMsg.getOpaSrcLocation().getTheLine());
+ marker.setAttribute(OpaSrcEditor.RAWMSGKEY, errorMsg.getRawErrorMsg());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
private void addMessage(OpaMessage omsg) {
System.out.println("OpaMessagesBank.addMessage()");
- IProject theTargetProject = omsg.getProject();
+ IProject theTargetProject = omsg.getProject();
initializeProject(theTargetProject);
// we must add a message to a specific resource
HashMap<IResource, List<OpaMessage>> target = retrieveMessagesForProject(theTargetProject);
Please sign in to comment.
Something went wrong with that request. Please try again.