<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><div>Hello Slava !</div><div><br></div><div>Thanks for your reply. My comments are in-line:&nbsp;</div><div><br></div><div>On 29 Jul 2014, at 21:15, Viacheslav Kabanovich &lt;<a href="mailto:glory@exadel.com">glory@exadel.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
  
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">In CDI, the model is updated only on build. We have cache of Java
      libraries, which listens to changes in Java classpath with
      IElementChangedListener and on a change we only mark that the
      cache is to be updated before the next build (Eclipse starts the
      build right after listeners are notified about the classpath
      change). In this way, we only rebuild libraries that are changed.<br></div></div></blockquote><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><div class="moz-cite-prefix"><br>
      For as-you-type validation, we create each time new CDI model
      which wraps the main model and for all resources but the one to be
      validated it just redirects requests to the main model. For the
      validated resource we call builder with current content. CDI model
      objects remain unchanged in the main model, but as-you-type
      validation gets up-to-date objects from the temporary model.<br></div></div></blockquote><div><br></div><div>That looks close to the concept of "Working Copies" that JDT uses, and this is something I was about to try, actually. Keeping the "Primary Copy" for a given resource unchanged, and creating a "Working Copy" during the as-you-type-validation.</div><br><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><div class="moz-cite-prefix">
      <br>
      All other features, e.g. content assist, search, etc. do not have
      access to the up-to-date model and get aware of changes only after
      save/rebuild.<br></div></div></blockquote><div><br></div>That would not work for me. For example:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(119, 119, 119);">@Path<span style="color: #000000">(</span><span style="color: #3933ff">"/"</span><span style="color: #000000">)</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span style="color: #931a68">public</span> <span style="color: #931a68">class</span> CarResource {</div><p style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(119, 119, 119);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>@PathParam<span style="color: #000000">(</span><span style="color: #3933ff">"id"</span><span style="color: #000000">)</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #931a68">private</span> Integer <span style="color: #0326cc">id</span>;</div><p style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(119, 119, 119);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>@GET</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="color: #777777">@Path</span><span style="color: #000000">(</span>"{id}"<span style="color: #000000">)</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #931a68">public</span> Object getCar() {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(147, 26, 104);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                </span></span>return<span style="color: #000000"> </span>null<span style="color: #000000">;</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">}</div></div><div><br></div><div>if the user changes <span style="font-family: Monaco; font-size: 11px; color: rgb(119, 119, 119);">@Path</span><span style="font-family: Monaco; font-size: 11px;">(</span><span style="color: rgb(57, 51, 255); font-family: Monaco; font-size: 11px;">"{id}"</span><span style="font-family: Monaco; font-size: 11px;">)</span>&nbsp;to something like&nbsp;<span style="font-family: Monaco; font-size: 11px; color: rgb(119, 119, 119);">@Path</span><span style="font-family: Monaco; font-size: 11px;">(</span><span style="color: rgb(57, 51, 255); font-family: Monaco; font-size: 11px;">"{carId}"</span><span style="font-family: Monaco; font-size: 11px;">)</span>, then the content assist on the value for&nbsp;<span style="color: rgb(119, 119, 119); font-family: Monaco; font-size: 11px;">@PathParam</span>&nbsp;(on the 'id' field above) should propose "carId" instead of "id". So the model needs to be updated before the resource was changed.</div><div><br><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><div class="moz-cite-prefix">
      <br>
      If I had to manage model that would change both in build and on
      unsaved resource modifications, I would have extended this
      approach with main and wrapper models. Each modification would
      update model objects for the resource in the wrapper model but
      would not touch the main model. Build would update model objects
      for the resource in the main model and cleared that resource from
      the wrapper model making it to redirect requests to the main model
      for that resource. The operations to be synchronized would be only
      those marking resource in wrapper model as either modified (with
      up-to-date objects associated) or saved (to be requested from the
      main model).<br>
      <br></div></div></blockquote><div><br></div><div>Yes, again, this reminds me the way JDT works with primary copies and working copies, AFAIU. I may consider this option and see how much it impacts the current code.&nbsp;</div><br><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><div class="moz-cite-prefix">
      Unfortunately, I see that this will not help you to avoid parsing
      the compilation unit in as-you-type validator, as it runs in a
      separate thread and can be called before Java element changed
      event. In CDI, we do not use CompilationUnit AST, only IType, so
      that we do not have to parse the source.<br></div></div></blockquote><div><br></div>I know that the AST is slower to compute, but it includes binding resolution, which is really helpful in cases where the user would use constants instead of String values, for example. And it also helps resolving fully qualified name for Java elements.</div><div><br></div><div><br></div><div><br></div><div>Best regards,</div><div>/Xavier</div><div><br><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000"><div class="moz-cite-prefix">
      <br>
      Best regards,<br>
      Slava Kabanovich<br>
      <br>
      On 07/29/2014 06:53 AM, Xavier Coulon wrote:<br>
    </div>
    <blockquote cite="mid:427E16D4-4807-440B-B489-934BC2366534@redhat.com" type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      Hello,
      <div><br>
      </div>
      <div>I recently opened&nbsp;<a moz-do-not-send="true" href="https://issues.jboss.org/browse/JBIDE-17290">https://issues.jboss.org/browse/JBIDE-17290</a>
        because I realised that since I added the "as-you-type"
        validation in the JAX-RS tooling, I have two concurrent updates
        in the JAX-RS model: a JavaElementChangedListener that updates
        the JAX-RS elements in the model after the user edited a
        compilation unit, but the 'as-you-type' validator needs to
        perform the same updates in order to be sure that the validation
        occurs after the last changes have been taken into account.
        Actually, the two processes occur in parallel and I have no idea
        how to make sure that the JavaElementListener-related task is
        executed and completes before the validation start. I should
        point that the JavaElementChangedListener is not related to the
        JAX-RS Builder which is called when a file is saved - that's
        another story, since there are also updates at this level.</div>
      <div><br>
      </div>
      <div>I don't want to get rid of the JavaElementChangedListener
        because the notification event provides me with the modified
        CompilationUnit AST, which is required for later processing (I
        don't want to parse the compilation unit unless it's absolutely
        necessary). Furthermore, it feels weird that the updates would
        only occur during the validation, so I'd rather avoid such
        updates in the validator.&nbsp;</div>
      <div><br>
      </div>
      <div>Do you have any suggestion on how I could simplify and
        improve this part of the tooling ? Since we're now preparing for
        CR1, an easy-and-acceptable-by-Max solution would be preferred
        ;-)</div>
      <div><br>
      </div>
      <div>How is the situation handled in the CDI tooling ?&nbsp;</div>
      <div><br>
      </div>
      <div>Thanks for reading this mail and thanks for your help !</div>
      <div>
        <div>
          <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;">
              <div style="word-wrap: break-word; -webkit-nbsp-mode:
                space; -webkit-line-break: after-white-space; ">Best
                regards,</div>
              <div style="word-wrap: break-word; -webkit-nbsp-mode:
                space; -webkit-line-break: after-white-space; ">/Xavier<br>
                <br>
                <br>
              </div>
            </span>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
jbosstools-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:jbosstools-dev@lists.jboss.org">jbosstools-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/jbosstools-dev">https://lists.jboss.org/mailman/listinfo/jbosstools-dev</a></pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br></body></html>