0 Replies Latest reply on Oct 17, 2011 4:49 AM by xcoulon

    Asking for feedback about problem management in Java WorkingCopy

    xcoulon

      Hello,

      I'm currently refactoring a large part of the JAX-RS plugin to support JavaElementChanges instead of ResourceChanges, in order to fix some issues and eventually provide faster computation and feedbacks to the user. So far, it's going not too bad, but I'm facing a problem with Eclipse's Problem management in Java Working copies (what an irony).

       

      Let me give you an example:

       

      package org.jboss.samples.rs.webservices;
      
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
      
      @Target({ ElementType.TYPE })
      @Retention(RetentionPolicy.RUNTIME)
      @HttpMethod("FOO")
      public @interface FooHttpMethod {
      }
      

       

       

       

      when a user adds the @HttpMethod("FOO") annotation to the FooHttpMethod Type, a set of JavaElementChanges is triggered, but at that particular time the 'import javax.ws.rs.HttpMethod' statement is missing, and so there are 2 problems in the CompilationUnit (one for the unknown annotation type and one for the unknown annotation 'value' attribute).

       

      In the code, I can do the following method call while scanning the event delta hierarchy:

       

      final IProblem[] problems = compilationUnitAST.getProblems();
      

       

      This gives me the *current* problems in the working copy. Using a map in a singleton, I can compare those new problems with the one that were reported before the change, compute a diff and find those that were actually fixed. Yet, I can't really use these fixed problems to apply changes to the JAX-RS metamodel, because the fixed problems refer to portions of the source code that may have moved ! In the current example, adding the required import statement moves the @HttpMethod annotation declaration down, and the problem's startLocation is now somewhere around the @Retention annotation declaration :-/

       

      So my question is : how do you usually address this kind of issue ?  Ie, how can I know that the @HttpMethod problems are now fixed ? Or that the @HttpMethod annotation was removed from the source code ?

       

      (I'd like to keep the JavaElementChanges support that I refactored and not move back to the ResourceChange support)

       

      Also, do you know why the method:

      compilationUnit.getElementAt(solvedProblem.getSourceStart())
      

      returns the SourceType and not the Annotation (even if it is the wrong one) ?

       

      Thank you in advance

      /Xavier