[jbosstools-issues] [JBoss JIRA] (JBIDE-18113) Wrong 'dirty regions' values passed to the 'as-you-type' validator

Jeff MAURY (JIRA) issues at jboss.org
Wed Apr 18 12:15:16 EDT 2018


     [ https://issues.jboss.org/browse/JBIDE-18113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff MAURY updated JBIDE-18113:
-------------------------------
    Fix Version/s: 4.6.x
                       (was: 4.5.x)


> Wrong 'dirty regions' values passed to the 'as-you-type' validator
> ------------------------------------------------------------------
>
>                 Key: JBIDE-18113
>                 URL: https://issues.jboss.org/browse/JBIDE-18113
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: common
>    Affects Versions: 4.2.0.Beta3
>            Reporter: Xavier Coulon
>            Assignee: Victor Rubezhny
>             Fix For: 4.6.x
>
>
> The as-you-type validator received an array of dirty regions that can be wrong when the region contains a String.
> Steps to reproduce:
> - grab the latest changes in jbosstools-webservices repo
> - start a runtime workbench
> - create a new dynamic web project targeting Wildfly 8.x (the example below uses JAX-RS 2.0 APIs)
> - add support for JAX-RS
> - create a class with the following content:
> {code}
> package jaxrs;
> import java.io.IOException;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.PathParam;
> import javax.ws.rs.container.ContainerRequestContext;
> import javax.ws.rs.container.ContainerResponseContext;
> import javax.ws.rs.container.ContainerResponseFilter;
> import javax.ws.rs.core.Response;
> import javax.ws.rs.ext.Provider;
> @Path("/")
> public class RestService {
>   
>  @GET
>  @Path("/{ide}")
>  public Response get(@PathParam("ide") String id) {
>  System.out.println("Just passed in method");
>  return Response.ok().build();
>  }
>      
>  @Provider
>     public static class AuthorizedResponseFilter implements ContainerResponseFilter {
>  @Override  
>  public void filter(ContainerRequestContext arg0,
>  ContainerResponseContext arg1) throws IOException {
>  System.out.println("Just passed in filter");
>  }
>     }
> } 
> {code}
> - In your development workspace, open {{org.jboss.tools.ws.jaxrs.ui.internal.validation.JaxrsMetamodelValidator}} and put a breakpoint on line 441
> - Back in the runtime workspace, remove the @Provider annotation and see the value for 'dirtyRegion'. In my last test, this one alone looked good (offset=559)
> - DO NOT SAVE THE FILE
> - remove the @Path("/") annotation on the RestService type, this time you should have *4* dirty regions, with unexpected values (ie, pointing at other locations in the document).
> As [~akazakov] commented in a private mail:
> {quote}
> JaxrsMetamodelValidator implements IJavaElementValidator and IStringValidator.
> When you remove @Provider then you get the region with offset of the removed JavaElement because you validator implements IJavaElementValidator.
> This interface tells our validation manager that the validator is interested in validating of changes in java elements.
> When you remove @Path("/") you also remove a string ("/") and since your validator implements IStringValidator this validator is notified and you got a list of the regions of all the strings of the file: 4 regions in your case.
> The problem is that you also should have been notified about removed java element because this annotation is not just a String. It's also a java element. That looks like a bug for me.
> So if you remove any code with a string inside then you will get a list of strings of the file (but only if you implements IStringValidator).
> If you don't implement IStringValidator and remove any java element which contains a string you won't be notified at all. This is a bug.
> {quote}



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jbosstools-issues mailing list