[jbosstools-dev] Question about org.jboss.tools.common.refactoring.MarkerResolutionUtils
Xavier Coulon
xcoulon at redhat.com
Thu Jun 26 18:09:09 EDT 2014
Alexey,
Thanks for your response !
It's done: https://issues.jboss.org/browse/JBIDE-17708 + https://github.com/jbosstools/jbosstools-base/pull/291
Please, beware that since I have TP/build issues on my machine, I could not run an 'mvn clean verify' before submitting the PR.
Best regards,
/Xavier
On 26 Jun 2014, at 23:27, Alexey Kazakov <akazakov at exadel.com> wrote:
> Hi,
>
> Yes, it makes sense. Please go ahead and open a JIRA with your PR.
>
> On 06/26/2014 09:22 AM, Xavier Coulon wrote:
>> Hello,
>>
>> I'm writing a JUnit test to verify that a quickfix for a JAX-RS problem works fine, but my test fails because the change is not applied during the call to Change#perform().
>> When digging into the code, I found that my problem is in the following method of org.jboss.tools.common.refactoring.MarkerResolutionUtils:
>>
>>
>> @SuppressWarnings("unchecked")
>> public static <T extends IJavaElement> T findWorkingCopy(ICompilationUnit compilationUnit, T element) throws JavaModelException{
>> if(element instanceof IAnnotation){
>> IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
>> if(parent instanceof IAnnotatable){
>> for(IAnnotation a : ((IAnnotatable)parent).getAnnotations()){
>> if(a.getElementName().equals(element.getElementName()))
>> return (T)a;
>> }
>> }
>> }else if(element instanceof ILocalVariable && ((ILocalVariable) element).isParameter()){
>> IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
>> if(parent instanceof IMethod){
>> for(ILocalVariable parameter : ((IMethod)parent).getParameters()){
>> if(parameter.getElementName().equals(element.getElementName()) && parameter.getTypeSignature().equals(((ILocalVariable)element).getTypeSignature()))
>> return (T)parameter;
>> }
>> }
>> }else{
>> IJavaElement[] elements = compilationUnit.findElements(element);
>> if(elements != null){
>> for(IJavaElement e : elements){
>> if(e.getClass().equals(element.getClass()))
>> return (T)e;
>> }
>> }
>> }
>> return null;
>> }
>>
>>
>>
>> In the code above, the last if/else block checks if e.getClass().equals(element.getClass()), which does not work in my case because I have org.eclipse.jdt.internal.core.SourceType vs org.eclipse.jdt.internal.core.ResolvedSourceType. I wonder if we should not replace this part with a comparison of a comparision of getHandleIdentifier() of both elements, which would make more sense, I believe.
>> For example, in my unit tests, it would be: =org.jboss.tools.ws.jaxrs.tests.sampleproject/src\/main\/java<org.jboss.tools.ws.jaxrs.sample.services{BAZ.java[BAZ in both cases ;-)
>> WDYT ?
>>
>> If the change I suggest makes sense, I'll be more than happy to open a JIRA and attach a PR to it ;-)
>>
>> Thanks.
>>
>> Best regards,
>> /Xavier
>>
>>
>>
>>
>>
>> _______________________________________________
>> jbosstools-dev mailing list
>> jbosstools-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jbosstools-dev
>
> _______________________________________________
> jbosstools-dev mailing list
> jbosstools-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jbosstools-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jbosstools-dev/attachments/20140627/f6287af4/attachment-0001.html
More information about the jbosstools-dev
mailing list